forked from Katarn2000x/DiplomacyFixes
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Events.cs
139 lines (120 loc) · 3.74 KB
/
Events.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using DiplomacyFixes.DiplomaticAction.Alliance;
using DiplomacyFixes.DiplomaticAction.WarPeace;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem;
namespace DiplomacyFixes
{
class Events
{
public static Events Instance { get; set; }
private readonly MbEvent<Hero> _messengerSent = new MbEvent<Hero>();
private readonly MbEvent<Kingdom> _peaceProposalSent = new MbEvent<Kingdom>();
private readonly MbEvent<Town> _fiefGranted = new MbEvent<Town>();
private readonly MbEvent<AllianceEvent> _allianceFormed = new MbEvent<AllianceEvent>();
private readonly MbEvent<AllianceEvent> _allianceBroken = new MbEvent<AllianceEvent>();
private readonly MbEvent<Settlement> _playerSettlementTaken = new MbEvent<Settlement>();
private readonly MbEvent<WarDeclaredEvent> _warDeclared = new MbEvent<WarDeclaredEvent>();
private List<object> _listeners;
public Events()
{
_listeners = new List<object>
{
_allianceBroken,
_allianceFormed,
_fiefGranted,
_messengerSent,
_peaceProposalSent,
_playerSettlementTaken,
_warDeclared
};
}
public static IMbEvent<AllianceEvent> AllianceFormed
{
get
{
return Instance._allianceFormed;
}
}
public static IMbEvent<AllianceEvent> AllianceBroken
{
get
{
return Instance._allianceBroken;
}
}
public static IMbEvent<Hero> MessengerSent
{
get
{
return Instance._messengerSent;
}
}
public static IMbEvent<Kingdom> PeaceProposalSent
{
get
{
return Instance._peaceProposalSent;
}
}
public static IMbEvent<Town> FiefGranted
{
get
{
return Instance._fiefGranted;
}
}
public static IMbEvent<Settlement> PlayerSettlementTaken
{
get
{
return Instance._playerSettlementTaken;
}
}
public static IMbEvent<WarDeclaredEvent> WarDeclared
{
get
{
return Instance._warDeclared;
}
}
internal void OnMessengerSent(Hero hero)
{
Instance._messengerSent.Invoke(hero);
}
internal void OnPeaceProposalSent(Kingdom kingdom)
{
Instance._peaceProposalSent.Invoke(kingdom);
}
internal void OnFiefGranted(Town fief)
{
Instance._fiefGranted.Invoke(fief);
}
internal void OnAllianceFormed(AllianceEvent allianceEvent)
{
Instance._allianceFormed.Invoke(allianceEvent);
}
internal void OnAllianceBroken(AllianceEvent allianceEvent)
{
Instance._allianceBroken.Invoke(allianceEvent);
}
internal void OnPlayerSettlementTaken(Settlement currentSettlement)
{
Instance._playerSettlementTaken.Invoke(currentSettlement);
}
internal void OnWarDeclared(WarDeclaredEvent warDeclaredEvent)
{
Instance._warDeclared.Invoke(warDeclaredEvent);
}
public static void RemoveListeners(object o)
{
Events.Instance.RemoveListenersInternal(o);
}
internal void RemoveListenersInternal(object obj)
{
foreach (dynamic listener in _listeners)
{
listener.ClearListeners(obj);
}
}
}
}