-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gamestate.d
48 lines (42 loc) · 1.28 KB
/
Gamestate.d
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
/***********************************\
GAMESTATE
\***********************************/
//========================================
// Globals Gamestate-Variable
//========================================
// Konstanten in Userconst.d
var int Gamestate;
//========================================
// [intern] Variablen
//========================================
var int _Gamestate_Event;
//========================================
// Listener für Gamestate hinzufügen
//========================================
func void Gamestate_AddListener(var func f) {
Event_AddOnce(_Gamestate_Event, f);
};
//========================================
// Listener für Gamestate entfernen
//========================================
func void Gamestate_RemoveListener(var func f) {
Event_Remove(_Gamestate_Event, f);
};
//========================================
// [intern] Initialisierung
//========================================
func void _Gamestate_InitLate() {
Event_Execute(_Gamestate_Event, Gamestate);
};
func void _Gamestate_Init(var int state) {
if(!_Gamestate_Event) {
_Gamestate_Event = Event_Create();
};
Gamestate = state;
if(state == Gamestate_NewGame) {
FF_ApplyExt(_Gamestate_InitLate, 1, 1);
}
else {
_Gamestate_InitLate();
};
};