| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | | using Object = UnityEngine.Object; |
| | 4 | |
|
| | 5 | | namespace DCLServices.MapRendererV2.MapLayers.UsersMarkers.ColdArea |
| | 6 | | { |
| | 7 | | internal class ColdUserMarker : IColdUserMarker |
| | 8 | | { |
| | 9 | | private readonly ColdUserMarkerObject instance; |
| | 10 | |
|
| | 11 | | private string markerRealm; |
| | 12 | |
|
| | 13 | | private bool active; |
| | 14 | | private bool culled; |
| | 15 | |
|
| 0 | 16 | | public Vector2 Pivot => instance.pivot; |
| | 17 | |
|
| 8980 | 18 | | public ColdUserMarker(ColdUserMarkerObject instance) |
| | 19 | | { |
| 8980 | 20 | | this.instance = instance; |
| 8980 | 21 | | } |
| | 22 | |
|
| 0 | 23 | | public Vector3 CurrentPosition => instance.transform.localPosition; |
| | 24 | |
|
| 0 | 25 | | public Vector2Int Coords { get; private set; } |
| | 26 | |
|
| | 27 | | public void Dispose() |
| | 28 | | { |
| 600 | 29 | | Object.Destroy(instance.gameObject); |
| 600 | 30 | | } |
| | 31 | |
|
| | 32 | | public void OnRealmChanged(string realm) |
| | 33 | | { |
| 0 | 34 | | instance.innerCircle.color = |
| | 35 | | string.Equals(realm, markerRealm, StringComparison.OrdinalIgnoreCase) ? instance.sameRealmColor : instan |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public void SetActive(bool isActive) |
| | 39 | | { |
| 17720 | 40 | | active = isActive; |
| 17720 | 41 | | ResolveVisibility(); |
| 17720 | 42 | | } |
| | 43 | |
|
| | 44 | | public void SetCulled(bool culled) |
| | 45 | | { |
| 0 | 46 | | this.culled = culled; |
| 0 | 47 | | ResolveVisibility(); |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | private void ResolveVisibility() |
| | 51 | | { |
| 17720 | 52 | | instance.gameObject.SetActive(!culled && active); |
| 17720 | 53 | | } |
| | 54 | |
|
| | 55 | | public void SetData(string realm, string userRealm, Vector2Int coords, Vector3 position) |
| | 56 | | { |
| 0 | 57 | | markerRealm = realm; |
| 0 | 58 | | Coords = coords; |
| 0 | 59 | | instance.transform.localPosition = position; |
| | 60 | |
|
| | 61 | | #if UNITY_EDITOR |
| 0 | 62 | | instance.name = $"UsersPositionMarker({coords.x},{coords.y})"; |
| | 63 | | #endif |
| | 64 | |
|
| 0 | 65 | | OnRealmChanged(userRealm); |
| 0 | 66 | | } |
| | 67 | | } |
| | 68 | | } |