| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using System.Threading; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCLServices.MapRendererV2.MapLayers.UsersMarkers.ColdArea |
| | 6 | | { |
| | 7 | | internal struct ExclusionAreaProvider |
| | 8 | | { |
| | 9 | | private ExclusionArea exclusionArea; |
| | 10 | |
|
| | 11 | | private readonly int commsRadiusThreshold; |
| | 12 | | private readonly KernelConfig kernelConfig; |
| | 13 | |
|
| 96 | 14 | | public ExclusionAreaProvider(KernelConfig kernelConfig, int commsRadiusThreshold) : this() |
| | 15 | | { |
| 96 | 16 | | this.kernelConfig = kernelConfig; |
| 96 | 17 | | this.commsRadiusThreshold = commsRadiusThreshold; |
| 96 | 18 | | } |
| | 19 | |
|
| | 20 | | public async UniTask Initialize(CancellationToken cancellationToken) |
| | 21 | | { |
| 96 | 22 | | var kernelConfigPromise = kernelConfig.EnsureConfigInitialized(); |
| 274 | 23 | | await kernelConfigPromise.WithCancellation(cancellationToken); |
| 7 | 24 | | exclusionArea.Radius = (int)kernelConfigPromise.value.comms.commRadius + commsRadiusThreshold; |
| 7 | 25 | | } |
| | 26 | |
|
| | 27 | | public void SetExclusionAreaCenter(Vector2Int center) |
| | 28 | | { |
| 0 | 29 | | exclusionArea.Position = center; |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | public readonly bool Contains(in Vector2Int coords) => |
| 0 | 33 | | exclusionArea.Contains(in coords); |
| | 34 | | } |
| | 35 | | } |