private void InitObjectHook <TObject, TEvent>(EventHandler eventHandler, TObject nwObject, EventScriptType eventScriptType) where TEvent : NativeEvent <TObject, TEvent>, new() where TObject : NwObject { string existingScript = NWScript.GetEventScript(nwObject, (int)eventScriptType); if (existingScript == eventHandler.ScriptName) { return; } Log.Debug($"Hooking native script event \"{eventScriptType}\" on object \"{nwObject.Name}\". Previous script: \"{existingScript}\""); NWScript.SetEventScript(nwObject, (int)eventScriptType, eventHandler.ScriptName); if (!string.IsNullOrEmpty(existingScript)) { eventHandler.Subscribe <TObject, TEvent>(nwObject, gameEvent => ContinueWithNative(existingScript, nwObject)); } }
public NativeEventAttribute(EventScriptType eventScriptType) { this.EventScriptType = eventScriptType; }
public EventKey(EventScriptType eventScriptType, uint gameObject) { this.eventScriptType = eventScriptType; this.gameObject = gameObject; }
public GameEventAttribute(EventScriptType eventScriptType) { EventScriptType = eventScriptType; }