public ScriptHandleResult ProcessCallbacks(uint objSelfId) { ScriptHandleResult result = ScriptHandleResult.NotHandled; NwObject objSelf = null; if (scriptHandler != null) { scriptHandler(); result = ScriptHandleResult.Handled; } else if (scriptHandlerWithMetaHandler != null) { objSelf = objSelfId.ToNwObject(); CallInfo meta = new CallInfo(scriptName, objSelf); scriptHandlerWithMetaHandler(meta); result = ScriptHandleResult.Handled; } if (conditionalHandler != null) { result = conditionalHandler() ? ScriptHandleResult.True : ScriptHandleResult.False; } else if (conditionalWithMetaHandler != null) { objSelf ??= objSelfId.ToNwObject(); CallInfo meta = new CallInfo(scriptName, objSelf); result = conditionalWithMetaHandler(meta) ? ScriptHandleResult.True : ScriptHandleResult.False; } return(result); }
ScriptHandleResult IScriptDispatcher.ExecuteScript(string scriptName, uint oidSelf) { ScriptHandleResult result = ScriptHandleResult.NotHandled; if (eventHandlers.TryGetValue(scriptName, out EventHandler handler)) { result = handler.ScriptEvent.Broadcast(oidSelf.ToNwObject()); if (handler.CallOriginal) { result = ScriptHandleResult.NotHandled; } } return(result); }
public ScriptHandleResult TryExecuteScript(string script, uint objectSelf) { try { ScriptHandleResult result = ScriptHandleResult.NotHandled; foreach (IScriptDispatcher dispatcher in dispatchers) { result = dispatcher.ExecuteScript(script, objectSelf); if (result != ScriptHandleResult.NotHandled) { break; } } return(result); } catch (Exception e) { Log.Error(e); return((int)ScriptHandleResult.Handled); } }
public int OnRunScript(string script, uint oidSelf) { ScriptHandleResult result = ScriptHandleResult.NotHandled; OnScriptContextBegin?.Invoke(); try { foreach (IScriptDispatcher dispatcher in dispatchers) { result = dispatcher.ExecuteScript(script, oidSelf); if (result != ScriptHandleResult.NotHandled) { break; } } } finally { OnScriptContextEnd?.Invoke(); } return((int)result); }