|
| 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 214 of file BaseModManager.cs.
215 {
217 if (num.HasValue)
218 {
219 return num.GetValueOrDefault() > 0;
220 }
221 return false;
222 }
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 {
66 if (langSetting == null)
67 {
70 }
71 FileInfo[] files =
new DirectoryInfo(langSetting.
dir +
"Data").GetFiles();
72 foreach (FileInfo fileInfo in files)
73 {
74 switch (fileInfo.Name)
75 {
76 case "Alias.xlsx":
77 Lang.alias =
new ExcelData(fileInfo.FullName);
78 break;
79 case "Name.xlsx":
80 Lang.names =
new ExcelData(fileInfo.FullName);
81 break;
82 case "chara_talk.xlsx":
84 break;
85 case "god_talk.xlsx":
87 break;
88 case "chara_tone.xlsx":
90 break;
91 }
92 }
93 }
static TalkDataList listTalk
static GodTalkDataList listGodTalk
static ToneDataList tones
static Dictionary< string, LangSetting > langs
References ExcelDataList.Add(), ExcelDataList.Clear(), Debug, LangSetting.dir, Lang.langCode, MOD.langs, MOD.listGodTalk, 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 190 of file BaseModManager.cs.
191 {
193 {
194 return;
195 }
196 foreach (Action<object>
item in value.ToList())
197 {
198 try
199 {
201 }
202 catch (Exception arg)
203 {
204 Debug.LogError(
$"#event '{eventId}' throws error in one of the handlers\n{arg}");
205 }
206 }
207 }
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 112 of file BaseModManager.cs.
113 {
114 if (handler != null)
115 {
116 Action<object> action = delegate
117 {
118 handler();
119 };
120 (string, Delegate) key = (eventId, handler);
123 }
124 }
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 99 of file BaseModManager.cs.
100 {
101 if (handler != null)
102 {
104 {
105 value = new HashSet<Action<object>>();
107 }
108 value.Add(handler);
109 }
110 }
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 126 of file BaseModManager.cs.
127 {
128 if (handler == null)
129 {
130 return;
131 }
132 Action<object> action = delegate(object data)
133 {
134 if (!(data is T obj))
135 {
136 if (data != null)
137 {
138 throw new InvalidCastException(
$"{handler.Method.DeclaringType?.Assembly.GetName()} " +
"expects " + typeof(T).Name +
", got " + data.GetType().Name);
139 }
140 handler(default(T));
141 }
142 else
143 {
144 handler(obj);
145 }
146 };
147 (string, Delegate) key = (eventId, handler);
150 }
References $, _typedEventHandlers, and SubscribeEvent().
◆ UnsubscribeEvent() [1/2]
| static void BaseModManager.UnsubscribeEvent |
( |
string |
eventId, |
|
|
Action |
handler |
|
) |
| |
|
inlinestatic |
Definition at line 164 of file BaseModManager.cs.
165 {
166 if (handler != null)
167 {
168 (string, Delegate) key = (eventId, handler);
170 {
173 }
174 }
175 }
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: