forked from SimBlocks/OneWorldSDKforUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TileLoadContext.cs
118 lines (98 loc) · 3.04 KB
/
TileLoadContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//Copyright SimBlocks LLC 2021
//https://www.simblocks.io/
//The source code in this file is licensed under the MIT License. See the LICENSE text file for full terms.
using System;
using System.Collections.Generic;
using sbio.owsdk.Unity.Events;
using sbio.owsdk.Utilities;
using sbio.owsdk.Tiles;
using sbio.owsdk.WMS;
using UnityEngine;
namespace sbio.owsdk.Unity
{
[CreateAssetMenu(menuName = "OWSDK/Tile Context", order = 120)]
public class TileLoadContext : ScriptableObject
, ITileLoadContext
{
#region ScriptableObject
public GameEvent MapperChanged;
public TerrainTileEvent TileActivated;
public TerrainTileEvent TileIsVisible;
public TerrainTileEvent TileObjectActive;
public TerrainTileEvent TileObjectInactive;
public TerrainTileEvent TileIsInvisible;
public TerrainTileEvent TileDeactivated;
public TerrainTileEvent TileUnloaded;
#endregion
public event Action TileMapperChanged
{
add { MapperChanged.Event += value; }
remove { MapperChanged.Event -= value; }
}
public event Action<TerrainTileIndex> Activated
{
add { TileActivated.Event += value; }
remove { TileActivated.Event -= value; }
}
public event Action<TerrainTileIndex> IsVisible
{
add { TileIsVisible.Event += value; }
remove { TileIsVisible.Event -= value; }
}
public event Action<TerrainTileIndex> ObjectActive
{
add { TileObjectActive.Event += value; }
remove { TileObjectActive.Event -= value; }
}
public event Action<TerrainTileIndex> ObjectInactive
{
add { TileObjectInactive.Event += value; }
remove { TileObjectInactive.Event -= value; }
}
public event Action<TerrainTileIndex> IsInvisible
{
add { TileIsInvisible.Event += value; }
remove { TileIsInvisible.Event -= value; }
}
public event Action<TerrainTileIndex> Deactivated
{
add { TileDeactivated.Event += value; }
remove { TileDeactivated.Event -= value; }
}
public event Action<TerrainTileIndex> Unloaded
{
add { TileUnloaded.Event += value; }
remove { TileUnloaded.Event -= value; }
}
public IDisposable RegisterTileLoader(ILoadTile loader)
{
#if DEBUG
//Make sure it's not in there already
if (m_TileLoaders.Contains(loader))
{
throw new InvalidOperationException(string.Format("The tile loader '{0}' is already registered", loader));
}
#endif
m_TileLoaders.Add(loader);
return new DisposableAction(() => m_TileLoaders.Remove(loader));
}
public IReadOnlyList<ILoadTile> ActiveLoaders
{
get { return m_TileLoaders; }
}
public ITileMapper ActiveTileMapper
{
get { return m_ActiveTileMapper; }
set
{
if (m_ActiveTileMapper != value)
{
m_ActiveTileMapper = value;
MapperChanged.Raise();
}
}
}
[NonSerialized] private readonly List<ILoadTile> m_TileLoaders = new List<ILoadTile>();
private ITileMapper m_ActiveTileMapper = WMSTileMapper.Instance;
}
}