|
| static readonly Dictionary< string, HashSet< Action< object > > > | _eventHandlers = new Dictionary<string, HashSet<Action<object>>>() |
| |
| static readonly Dictionary<(string, Delegate), Action< object > > | _typedEventHandlers = new Dictionary<(string, Delegate), Action<object>>() |
| |
Definition at line 7 of file BaseModManager.cs.
◆ HasEventSubscriber()
| static bool BaseModManager.HasEventSubscriber |
( |
string |
eventId | ) |
|
|
inlinestatic |
Definition at line 216 of file BaseModManager.cs.
217 {
219 if (num.HasValue)
220 {
221 return num.GetValueOrDefault() > 0;
222 }
223 return false;
224 }
static readonly Dictionary< string, HashSet< Action< object > > > _eventHandlers
References _eventHandlers.
◆ Init()
| virtual void BaseModManager.Init |
( |
string |
path, |
|
|
string |
defaultPackage = "_Elona" |
|
) |
| |
|
inlinevirtual |
◆ InitLang()
| void BaseModManager.InitLang |
( |
| ) |
|
|
inline |
Definition at line 59 of file BaseModManager.cs.
60 {
68 if (langSetting == null)
69 {
72 }
73 FileInfo[] files =
new DirectoryInfo(langSetting.
dir +
"Data").GetFiles();
74 foreach (FileInfo fileInfo in files)
75 {
76 switch (fileInfo.Name)
77 {
78 case "Alias.xlsx":
80 break;
81 case "Name.xlsx":
83 break;
84 case "chara_talk.xlsx":
86 break;
87 case "god_talk.xlsx":
89 break;
90 case "chara_tone.xlsx":
92 break;
93 }
94 }
95 }
static TalkDataList listTalk
static GodTalkDataList listGodTalk
static ToneDataList tones
static ExcelDataList listAlias
static Dictionary< string, LangSetting > langs
static ExcelDataList listName
References ExcelDataList.Add(), ExcelDataList.Clear(), Debug, LangSetting.dir, Lang.langCode, MOD.langs, MOD.listAlias, MOD.listGodTalk, MOD.listName, MOD.listTalk, and MOD.tones.
◆ ParseExtra()
| virtual void BaseModManager.ParseExtra |
( |
DirectoryInfo |
dir, |
|
|
BaseModPackage |
package |
|
) |
| |
|
inlinevirtual |
◆ PublishEvent()
| static void BaseModManager.PublishEvent |
( |
string |
eventId, |
|
|
object |
data = null |
|
) |
| |
|
inlinestatic |
Definition at line 192 of file BaseModManager.cs.
193 {
195 {
196 return;
197 }
198 foreach (Action<object>
item in value.ToList())
199 {
200 try
201 {
203 }
204 catch (Exception arg)
205 {
206 Debug.LogError(
$"#event '{eventId}' throws error in one of the handlers\n{arg}");
207 }
208 }
209 }
References $, _eventHandlers, Debug, and item.
Referenced by Card._OnDeserialized(), Feat.Apply(), Card.Create(), SourceManager.Init(), Scene.Init(), Game.Load(), Act.Perform(), PublishEvent< T >(), Game.Save(), Core.SetLang(), ReligionManager.SetOwner(), and Game.StartNewGame().
◆ PublishEvent< T >()
◆ SubscribeEvent() [1/2]
| static void BaseModManager.SubscribeEvent |
( |
string |
eventId, |
|
|
Action |
handler |
|
) |
| |
|
inlinestatic |
Definition at line 114 of file BaseModManager.cs.
115 {
116 if (handler != null)
117 {
118 Action<object> action = delegate
119 {
120 handler();
121 };
122 (string, Delegate) key = (eventId, handler);
125 }
126 }
static void SubscribeEvent(string eventId, Action< object > handler)
References _typedEventHandlers, and SubscribeEvent().
◆ SubscribeEvent() [2/2]
| static void BaseModManager.SubscribeEvent |
( |
string |
eventId, |
|
|
Action< object > |
handler |
|
) |
| |
|
inlinestatic |
Definition at line 101 of file BaseModManager.cs.
102 {
103 if (handler != null)
104 {
106 {
107 value = new HashSet<Action<object>>();
109 }
110 value.Add(handler);
111 }
112 }
References _eventHandlers.
Referenced by ElinActPerformAttribute.Register(), ElinCharaOnCreateAttribute.Register(), ElinPostLoadAttribute.Register(), ElinPostSaveAttribute.Register(), ElinPostSceneInitAttribute.Register(), ElinPreLoadAttribute.Register(), ElinPreSaveAttribute.Register(), ElinPreSceneInitAttribute.Register(), ElinThingOnCreateAttribute.Register(), ElinGameIOPropertyAttribute.Register(), SubscribeEvent(), and SubscribeEvent< T >().
◆ SubscribeEvent< T >()
Definition at line 128 of file BaseModManager.cs.
129 {
130 if (handler == null)
131 {
132 return;
133 }
134 Action<object> action = delegate(object data)
135 {
136 if (!(data is T obj))
137 {
138 if (data != null)
139 {
140 throw new InvalidCastException(
$"{handler.Method.DeclaringType?.Assembly.GetName()} " +
"expects " + typeof(T).Name +
", got " + data.GetType().Name);
141 }
142 handler(default(T));
143 }
144 else
145 {
146 handler(obj);
147 }
148 };
149 (string, Delegate) key = (eventId, handler);
152 }
References $, _typedEventHandlers, and SubscribeEvent().
◆ UnsubscribeEvent() [1/2]
| static void BaseModManager.UnsubscribeEvent |
( |
string |
eventId, |
|
|
Action |
handler |
|
) |
| |
|
inlinestatic |
Definition at line 166 of file BaseModManager.cs.
167 {
168 if (handler != null)
169 {
170 (string, Delegate) key = (eventId, handler);
172 {
175 }
176 }
177 }
static void UnsubscribeEvent(string eventId, Action< object > handler)
References _typedEventHandlers, and UnsubscribeEvent().
◆ UnsubscribeEvent() [2/2]
| static void BaseModManager.UnsubscribeEvent |
( |
string |
eventId, |
|
|
Action< object > |
handler |
|
) |
| |
|
inlinestatic |
◆ UnsubscribeEvent< T >()
◆ _eventHandlers
| readonly Dictionary<string, HashSet<Action<object> > > BaseModManager._eventHandlers = new Dictionary<string, HashSet<Action<object>>>() |
|
staticprivate |
◆ _typedEventHandlers
| readonly Dictionary<(string, Delegate), Action<object> > BaseModManager._typedEventHandlers = new Dictionary<(string, Delegate), Action<object>>() |
|
staticprivate |
◆ dirWorkshop
| DirectoryInfo BaseModManager.dirWorkshop |
◆ Instance
◆ isInitialized
| bool BaseModManager.isInitialized |
|
static |
◆ listChainLoad
| List<string> BaseModManager.listChainLoad = new List<string>() |
|
static |
◆ packages
◆ priorityIndex
| int BaseModManager.priorityIndex |
◆ rootDefaultPacakge
| string BaseModManager.rootDefaultPacakge |
|
static |
◆ rootMod
| string BaseModManager.rootMod |
|
static |
The documentation for this class was generated from the following file: