| | 1 | | using DCL; |
| | 2 | | using Variables.SpawnPoints; |
| | 3 | |
|
| | 4 | | public class SpawnPointsDisplayerPlugin : IPlugin |
| | 5 | | { |
| | 6 | | private readonly BaseDictionary<string, SceneSpawnPointsData> spawnPointsVariable; |
| | 7 | | private ISpawnPointsDataHandler spawnPointsDataHandler; |
| | 8 | |
|
| 0 | 9 | | public SpawnPointsDisplayerPlugin() : this( |
| | 10 | | DataStore.i.debugConfig.showSceneSpawnPoints, |
| 0 | 11 | | new SpawnPointsDataHandler(new SpawnPointIndicatorInstantiator())) { } |
| | 12 | |
|
| 4 | 13 | | internal SpawnPointsDisplayerPlugin( |
| | 14 | | in BaseDictionary<string, SceneSpawnPointsData> spawnPointsVariable, |
| | 15 | | in ISpawnPointsDataHandler spawnPointsDataHandler) |
| | 16 | | { |
| 4 | 17 | | this.spawnPointsVariable = spawnPointsVariable; |
| 4 | 18 | | this.spawnPointsDataHandler = spawnPointsDataHandler; |
| | 19 | |
|
| 4 | 20 | | spawnPointsVariable.OnAdded += OnSpawnPointAdded; |
| 4 | 21 | | spawnPointsVariable.OnRemoved += OnSpawnPointRemoved; |
| 4 | 22 | | } |
| | 23 | |
|
| | 24 | | public void Dispose() |
| | 25 | | { |
| 5 | 26 | | spawnPointsVariable.OnAdded -= OnSpawnPointAdded; |
| 5 | 27 | | spawnPointsVariable.OnRemoved -= OnSpawnPointRemoved; |
| | 28 | |
|
| 5 | 29 | | spawnPointsDataHandler?.Dispose(); |
| 5 | 30 | | spawnPointsDataHandler = null; |
| 5 | 31 | | } |
| | 32 | |
|
| | 33 | | private void OnSpawnPointAdded(string sceneId, SceneSpawnPointsData spawnPointsInfo) |
| | 34 | | { |
| 3 | 35 | | spawnPointsDataHandler.RemoveSpawnPoints(sceneId); |
| 3 | 36 | | if (spawnPointsInfo.enabled.HasValue && spawnPointsInfo.enabled.Value) |
| | 37 | | { |
| 2 | 38 | | spawnPointsDataHandler.CreateSpawnPoints(sceneId, spawnPointsInfo.spawnPoints); |
| | 39 | | } |
| 3 | 40 | | } |
| | 41 | |
|
| | 42 | | private void OnSpawnPointRemoved(string sceneId, SceneSpawnPointsData spawnPointsInfo) |
| | 43 | | { |
| 1 | 44 | | spawnPointsDataHandler.RemoveSpawnPoints(sceneId); |
| 1 | 45 | | } |
| | 46 | | } |