-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Callbacks.cs
122 lines (112 loc) · 4.45 KB
/
Callbacks.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
116
117
118
119
120
121
122
using UnityEngine;
namespace SALT
{
/// <summary>
/// Class with events
/// </summary>
public static class Callbacks
{
/// <summary>
/// Event for when the active scene is changed.
/// </summary>
public static event Callbacks.OnActiveSceneChangedDelegate OnActiveSceneChanged;
/// <summary>
/// Event for when the main menu is loaded.
/// </summary>
public static event Callbacks.OnLevelLoadedDelegate OnMainMenuLoaded;
/// <summary>
/// Event for when the main menu is unloaded.
/// </summary>
public static event Callbacks.OnLevelUnloadedDelegate OnMainMenuUnloaded;
/// <summary>
/// Event for when any level, that isn't the main menu, is loaded.
/// </summary>
public static event Callbacks.OnLevelLoadedDelegate OnLevelLoaded;
/// <summary>
/// Event for when any level, that isn't the main menu, is unloaded.
/// </summary>
public static event Callbacks.OnLevelUnloadedDelegate OnLevelUnloaded;
/// <summary>
/// Event for when a character is spawned
/// </summary>
public static event Callbacks.OnCharacterSpawnedDelegate OnCharacterSpawned;
/// <summary>
/// Event that's called when <see cref="MainScript.Start"/> ends.
/// </summary>
internal static event Callbacks.OnGameContextReadyDelegate OnGameContextReady;
/// <summary>
/// Triggers when the game's resolution is changed
/// </summary>
public static event OnResolutionChangedDelegate OnApplyResolution;
internal static void OnLoad()
{
Callbacks.OnGameContextReadyDelegate gameContextReady = Callbacks.OnGameContextReady;
if (gameContextReady == null)
return;
gameContextReady();
}
internal static void OnSceneLoaded()
{
if (Levels.isMainMenu())
{
Callbacks.OnLevelLoadedDelegate onMainMenuLoaded = Callbacks.OnMainMenuLoaded;
if (onMainMenuLoaded == null)
return;
onMainMenuLoaded();
return;
}
Callbacks.OnLevelLoadedDelegate onLevelLoaded = Callbacks.OnLevelLoaded;
if (onLevelLoaded == null)
return;
onLevelLoaded();
}
internal static void OnSceneUnloaded()
{
if (Levels.isMainMenu())
{
Callbacks.OnLevelUnloadedDelegate onMainMenuUnloaded = Callbacks.OnMainMenuUnloaded;
if (onMainMenuUnloaded == null)
return;
onMainMenuUnloaded();
return;
}
Callbacks.OnLevelUnloadedDelegate onLevelUnloaded = Callbacks.OnLevelUnloaded;
if (onLevelUnloaded == null)
return;
onLevelUnloaded();
}
internal static void OnActiveSceneChanged_Trigger(Level old, Level @new)
{
Callbacks.OnActiveSceneChangedDelegate onActiveSceneChanged = Callbacks.OnActiveSceneChanged;
if (onActiveSceneChanged == null)
return;
onActiveSceneChanged(old, @new);
}
internal static void OnApplyResolution_Trigger()
{
Callbacks.OnResolutionChangedDelegate onApplyResolution = Callbacks.OnApplyResolution;
if (onApplyResolution == null)
return;
onApplyResolution();
}
internal static void OnCharacterSpawned_Trigger(PlayerScript player, Character character)
{
Callbacks.OnCharacterSpawnedDelegate onCharacterSpawned = Callbacks.OnCharacterSpawned;
if (onCharacterSpawned == null)
return;
onCharacterSpawned(player, character);
}
/// <summary>
/// Delegate for when a level is loaded.
/// </summary>
public delegate void OnLevelLoadedDelegate();
/// <summary>
/// Delegate for when a level is unloaded.
/// </summary>
public delegate void OnLevelUnloadedDelegate();
public delegate void OnCharacterSpawnedDelegate(PlayerScript player, Character character);
public delegate void OnActiveSceneChangedDelegate(Level old, Level @new);
internal delegate void OnGameContextReadyDelegate();
public delegate void OnResolutionChangedDelegate();
}
}