| | 1 | | using DCL.Helpers; |
| | 2 | | using System; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCLServices.MapRendererV2.MapLayers.PlayerMarker |
| | 6 | | { |
| | 7 | | internal class PlayerMarker : IPlayerMarker |
| | 8 | | { |
| | 9 | | private readonly PlayerMarkerObject markerObject; |
| | 10 | | private readonly float baseScale; |
| | 11 | |
|
| 0 | 12 | | public Vector2 Pivot => markerObject.pivot; |
| | 13 | |
|
| 96 | 14 | | public PlayerMarker(PlayerMarkerObject markerObject) |
| | 15 | | { |
| 96 | 16 | | this.markerObject = markerObject; |
| 96 | 17 | | baseScale = markerObject.transform.localScale.x; |
| 96 | 18 | | SetActive(false); |
| 96 | 19 | | } |
| | 20 | |
|
| | 21 | | public void Dispose() |
| | 22 | | { |
| 6 | 23 | | if (markerObject) |
| 6 | 24 | | Utils.SafeDestroy(markerObject.gameObject); |
| 6 | 25 | | } |
| | 26 | |
|
| | 27 | | public void SetPosition(Vector3 position) |
| | 28 | | { |
| 0 | 29 | | markerObject.transform.localPosition = position; |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | public void SetActive(bool active) |
| | 33 | | { |
| 184 | 34 | | markerObject.gameObject.SetActive(active); |
| 184 | 35 | | } |
| | 36 | |
|
| | 37 | | public void SetBackgroundVisibility(bool backgroundIsActive) |
| | 38 | | { |
| 0 | 39 | | markerObject.SetAnimatedCircleVisibility(backgroundIsActive); |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | public void SetRotation(Quaternion rot) |
| | 43 | | { |
| 0 | 44 | | markerObject.transform.localRotation = rot; |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | public void SetZoom(float baseZoom, float zoom) |
| | 48 | | { |
| 0 | 49 | | float newScale = Math.Max(zoom / baseZoom * baseScale, baseScale); |
| 0 | 50 | | markerObject.transform.localScale = new Vector3(newScale, newScale, 1f); |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | public void ResetToBaseScale() |
| | 54 | | { |
| 0 | 55 | | markerObject.transform.localScale = new Vector3(baseScale, baseScale, 1f); |
| 0 | 56 | | } |
| | 57 | | } |
| | 58 | | } |