/// <summary> /// Clear all events in EventManager. For game ending or restarting. /// </summary> public void ClearAllEvents() { foreach (SideEffectExecute.TriggerTime tt in Enum.GetValues(typeof(SideEffectExecute.TriggerTime))) { Events[tt] = new Dictionary <int, SideEffectExecute>(); RemoveEvents[tt] = new Dictionary <int, SideEffectExecute>(); } ObsoleteSEEs.Clear(); }
public void Invoke_RemoveSEE(SideEffectExecute.TriggerTime tt, ExecutorInfo executorInfo) { Dictionary <int, SideEffectExecute> seeDict = RemoveEvents[tt]; SideEffectExecute[] sees = seeDict.Values.ToArray(); for (int i = 0; i < sees.Length; i++) { SideEffectExecute see = sees[i]; if (ObsoleteSEEs.ContainsKey(see.ID)) { continue; //To prevent removed side effects from being removed again. } if (seeDict.ContainsKey(see.ID)) { bool isTrigger = IsExecuteTrigger(executorInfo, see.M_ExecutorInfo, see.M_ExecuteSetting.RemoveTriggerRange); if (isTrigger) { Trigger_TryRemove(see); // invoke main trigger_remove method. (some side effects like buffs have a remove_time attribute. e.g. Remove this buff after 3 turns) } } } RemoveAllUselessSEEs(); }
private void InvokeCore(InvokeInfo invokeInfo) { SideEffectExecute.TriggerTime tt = invokeInfo.TriggerTime; ExecutorInfo executorInfo = invokeInfo.ExecutorInfo; Dictionary <int, SideEffectExecute> seeDict = Events[tt]; SideEffectExecute[] sees = seeDict.Values.ToArray(); for (int i = 0; i < sees.Length; i++) { SideEffectExecute see = sees[i]; if (ObsoleteSEEs.ContainsKey(see.ID)) { continue; //To prevent executed side effects from being executed again. } if (seeDict.ContainsKey(see.ID)) { bool isTrigger = false; if (see.M_ExecuteSetting is ScriptExecuteSettingBase scriptExecuteSettingBase) { isTrigger = scriptExecuteSettingBase.IsTrigger(executorInfo, see.M_ExecutorInfo); } else { isTrigger = IsExecuteTrigger(executorInfo, see.M_ExecutorInfo, see.M_ExecuteSetting.TriggerRange); //To check out if this event invokes any side effect. } if (isTrigger) { Trigger(see, executorInfo, tt, see.M_ExecuteSetting.TriggerRange); // invoke main trigger method. } } } Invoke_RemoveSEE(tt, executorInfo); //Remove executed side effects with zero time left. }