public TriggerEvent(string modifierName, TriggerEventType type, ScriptFunctionDelegate f, IInfinityObject target, int adderObjectId, int priority) { _modifierName = modifierName; _type = type; _f = f; _target = target; _adderObjectId = adderObjectId; Priority = priority; }
public static bool TryGetLuaAction(this Table table, string key, out ScriptFunctionDelegate result, LogInfo info = default) { if (table.TryGetDynValue(key, out var dynValue, info)) { return(dynValue.TryGetLuaAction(out result, info)); } result = null; return(false); }
public ModifierScope(string modifierName, string targetTypeName, ScriptFunctionDelegate <List <ModifierEffect> > getEffect, IReadOnlyDictionary <string, ScriptFunctionDelegate> triggerEvent, IReadOnlyDictionary <string, int> triggerEventPriority) { _modifierName = modifierName; TargetTypeName = targetTypeName; _getEffect = getEffect; TriggerEvent = triggerEvent; TriggerEventPriority = triggerEventPriority; }
public static object TryDelegate(ScriptFunctionDelegate del, params object[] args) { try { return(del(args)); } catch (ScriptRuntimeException ex) { Debug.WriteLine("Doh! An error occured! {0}", ex.DecoratedMessage); } return(null); }
public void Bind(string eventName, DynValue fun) { if (!events.ContainsKey(eventName)) { ScriptFunctionDelegate del = fun.Function.GetDelegate(); events[eventName] = del; } else { events[eventName] += fun.Function.GetDelegate(); } }
public static bool TryInvoke(this ScriptFunctionDelegate f, string funcName, string context, params object[] args) { try { f.Invoke(args); return(true); } catch (Exception e) { Logger.Log(LogType.Error, $"Function {funcName} of " + context, "Function call failed! It may cause a serious problem, resulting game crash! Error Message: " + e.Message); return(false); } }
public SpecialActionCore(string name, string targetType, bool needCoordinate, ScriptFunctionDelegate <bool> isAvailable, ScriptFunctionDelegate <HashSet <HexTileCoord> > getAvailableTiles, ScriptFunctionDelegate <HashSet <HexTileCoord> > previewEffectRange, ScriptFunctionDelegate <Dictionary <string, int> > getCost, ScriptFunctionDelegate <bool> doAction) { Name = name; TargetType = targetType; NeedCoordinate = needCoordinate; _isAvailable = isAvailable; _getAvailableTiles = getAvailableTiles; _previewEffectRange = previewEffectRange; _getCost = getCost; _doAction = doAction; }
public static bool TryGetLuaAction(this DynValue dynValue, out ScriptFunctionDelegate result, LogInfo info = default) { if (dynValue.Type != DataType.Function) { if (info.Context != null) { Logger.Log(info.LogType, info.Context, "Value is defined, but it's not a function!"); } result = null; return(false); } result = dynValue.Function.GetDelegate(); return(true); }
public Function(ScriptFunctionDelegate func) { m_func = func; }