Example #1
0
        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));
            }
        }
Example #2
0
 public NativeEventAttribute(EventScriptType eventScriptType)
 {
     this.EventScriptType = eventScriptType;
 }
Example #3
0
 public EventKey(EventScriptType eventScriptType, uint gameObject)
 {
     this.eventScriptType = eventScriptType;
     this.gameObject      = gameObject;
 }
Example #4
0
 public GameEventAttribute(EventScriptType eventScriptType)
 {
     EventScriptType = eventScriptType;
 }