| | 1 | | using System; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using UnityEngine; |
| | 4 | | using Object = UnityEngine.Object; |
| | 5 | |
|
| | 6 | | internal interface ISpawnPointIndicator : IDisposable |
| | 7 | | { |
| | 8 | | void SetName(in string name); |
| | 9 | | void SetPosition(in Vector3 position); |
| | 10 | | void SetSize(in Vector3 size); |
| | 11 | | void SetRotation(in Quaternion? rotation); |
| | 12 | | } |
| | 13 | |
|
| | 14 | | internal class SpawnPointIndicator : ISpawnPointIndicator |
| | 15 | | { |
| | 16 | | private SpawnPointIndicatorMonoBehaviour spawnPointIndicatorBehaviour; |
| | 17 | | private Vector3 position; |
| | 18 | |
|
| 4 | 19 | | public SpawnPointIndicator(SpawnPointIndicatorMonoBehaviour spawnPointIndicatorBehaviour) |
| | 20 | | { |
| 4 | 21 | | this.spawnPointIndicatorBehaviour = spawnPointIndicatorBehaviour; |
| 4 | 22 | | CommonScriptableObjects.worldOffset.OnChange += OnWorldReposition; |
| 4 | 23 | | } |
| | 24 | |
|
| | 25 | | void IDisposable.Dispose() |
| | 26 | | { |
| 1 | 27 | | CommonScriptableObjects.worldOffset.OnChange -= OnWorldReposition; |
| 1 | 28 | | if (!spawnPointIndicatorBehaviour.isDestroyed) |
| | 29 | | { |
| 1 | 30 | | Object.Destroy(spawnPointIndicatorBehaviour.gameObject); |
| | 31 | | } |
| 1 | 32 | | } |
| | 33 | |
|
| | 34 | | void ISpawnPointIndicator.SetName(in string name) |
| | 35 | | { |
| 0 | 36 | | spawnPointIndicatorBehaviour.SetName(name); |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | void ISpawnPointIndicator.SetPosition(in Vector3 position) |
| | 40 | | { |
| 1 | 41 | | this.position = position; |
| 1 | 42 | | spawnPointIndicatorBehaviour.SetPosition(PositionUtils.WorldToUnityPosition(position)); |
| 1 | 43 | | } |
| | 44 | |
|
| | 45 | | void ISpawnPointIndicator.SetSize(in Vector3 size) |
| | 46 | | { |
| 1 | 47 | | spawnPointIndicatorBehaviour.SetSize(size); |
| 1 | 48 | | } |
| | 49 | |
|
| | 50 | | void ISpawnPointIndicator.SetRotation(in Quaternion? rotation) |
| | 51 | | { |
| 2 | 52 | | spawnPointIndicatorBehaviour.SetRotation(rotation); |
| 2 | 53 | | } |
| | 54 | |
|
| | 55 | | void OnWorldReposition(Vector3 current, Vector3 previous) |
| | 56 | | { |
| 0 | 57 | | spawnPointIndicatorBehaviour.SetPosition(PositionUtils.WorldToUnityPosition(position)); |
| 0 | 58 | | } |
| | 59 | | } |