public void DoEvent(int nEventID, System.Object vars = null) { ArrayList events; if (!mhtEvent.TryGetValue(nEventID, out events)) { return; } List <object> readyForDelete = new List <object>(); for (int i = 0; i < events.Count; i++) { LogicEventHandler handler = events[i] as LogicEventHandler; if (handler.Target.Equals(null)) { Debug.Log("handler.Target.Equals(null)"); readyForDelete.Add(events[i]); continue; } if (!handler(vars)) { break; } } if (readyForDelete.Count != 0) { for (int j = 0; j < readyForDelete.Count; j++) { events.Remove(readyForDelete[j]); } } }
private void Disconnect() { if (connected) { LogicCircuitManager logicCircuitManager = Game.Instance.logicCircuitManager; UtilityNetworkManager <LogicCircuitNetwork, LogicWire> logicCircuitSystem = Game.Instance.logicCircuitSystem; connected = false; int outputCell = base.OutputCell; logicCircuitSystem.RemoveFromNetworks(outputCell, this, true); logicCircuitManager.RemoveVisElem(output); output = null; int inputCellOne = base.InputCellOne; logicCircuitSystem.RemoveFromNetworks(inputCellOne, inputOne, true); logicCircuitManager.RemoveVisElem(inputOne); inputOne = null; if (base.RequiresTwoInputs) { int inputCellTwo = base.InputCellTwo; logicCircuitSystem.RemoveFromNetworks(inputCellTwo, inputTwo, true); logicCircuitManager.RemoveVisElem(inputTwo); inputTwo = null; } RefreshAnimation(); } }
private void CreatePhysicalPorts() { int num = Grid.PosToCell(base.transform.GetPosition()); if (num != cell) { cell = num; DestroyVisualizers(); if (outputPortInfo != null) { outputPorts = new List <ILogicUIElement>(); for (int i = 0; i < outputPortInfo.Length; i++) { Port info = outputPortInfo[i]; LogicEventSender logicEventSender = new LogicEventSender(info.id, GetActualCell(info.cellOffset), delegate(int new_value) { if ((UnityEngine.Object) this != (UnityEngine.Object)null) { OnLogicValueChanged(info.id, new_value); } }, OnLogicNetworkConnectionChanged, info.spriteType); outputPorts.Add(logicEventSender); Game.Instance.logicCircuitManager.AddVisElem(logicEventSender); Game.Instance.logicCircuitSystem.AddToNetworks(logicEventSender.GetLogicUICell(), logicEventSender, true); } if (serializedOutputValues != null && serializedOutputValues.Length == outputPorts.Count) { for (int j = 0; j < outputPorts.Count; j++) { LogicEventSender logicEventSender2 = outputPorts[j] as LogicEventSender; logicEventSender2.SetValue(serializedOutputValues[j]); } } } serializedOutputValues = null; if (inputPortInfo != null) { inputPorts = new List <ILogicUIElement>(); for (int k = 0; k < inputPortInfo.Length; k++) { Port info2 = inputPortInfo[k]; LogicEventHandler logicEventHandler = new LogicEventHandler(GetActualCell(info2.cellOffset), delegate(int new_value) { if ((UnityEngine.Object) this != (UnityEngine.Object)null) { OnLogicValueChanged(info2.id, new_value); } }, OnLogicNetworkConnectionChanged, info2.spriteType); inputPorts.Add(logicEventHandler); Game.Instance.logicCircuitManager.AddVisElem(logicEventHandler); Game.Instance.logicCircuitSystem.AddToNetworks(logicEventHandler.GetLogicUICell(), logicEventHandler, true); } } } }
public void RegisterCallback(int nEventID, LogicEventHandler handler) { ArrayList events; if (!mhtEvent.TryGetValue(nEventID, out events)) { events = new ArrayList(); mhtEvent.Add(nEventID, events); } events.Add(handler); }
/// <summary> /// Convenient method for linking the events of this <see cref="Story"/> to another /// <see cref="Procedure"/>. Also optionally add event handlers to /// <see cref="Procedure.Started"/> and <see cref="Procedure.Completed"/>. /// </summary> /// <param name="pro">The <see cref="Procedure"/> to link to.</param> /// <param name="started">Event handler for <see cref="Procedure.Started"/>.</param> /// <param name="completed"> /// Event handler for <see cref="Procedure.Completed"/>. /// </param> public void Link(Procedure pro, LogicEventHandler started = null, LogicEventHandler completed = null) { Event.Register(this, Started, (sender, e) => pro.Start()); Event.Register(this, Skipped, (sender, e) => pro.Skip()); Event.Register(this, Stopping, (sender, e) => pro.Stop()); Event.Register(pro, Completed, (sender, e) => Complete()); if (started != null) Event.Register(this, Started, started); if (completed != null) Event.Register(this, Completed, completed); }
protected override void OnSpawn() { inputOne = new LogicEventHandler(base.InputCellOne, UpdateState, null, LogicPortSpriteType.Input); if (base.RequiresTwoInputs) { inputTwo = new LogicEventHandler(base.InputCellTwo, UpdateState, null, LogicPortSpriteType.Input); } Subscribe(774203113, OnBuildingBrokenDelegate); Subscribe(-1735440190, OnBuildingFullyRepairedDelegate); BuildingHP component = GetComponent <BuildingHP>(); if ((Object)component == (Object)null || !component.IsBroken) { Connect(); } }
private void DestroyPhysicalPorts() { if (outputPorts != null) { foreach (ILogicEventSender outputPort in outputPorts) { Game.Instance.logicCircuitSystem.RemoveFromNetworks(outputPort.GetLogicCell(), outputPort, true); } } if (inputPorts != null) { for (int i = 0; i < inputPorts.Count; i++) { LogicEventHandler logicEventHandler = inputPorts[i] as LogicEventHandler; if (logicEventHandler != null) { Game.Instance.logicCircuitSystem.RemoveFromNetworks(logicEventHandler.GetLogicCell(), logicEventHandler, true); } } } }
public static void Register(Type type, string name, LogicEventHandler handler) { Register((object)type, name, handler); }
public static void Register(object target, string name, LogicEventHandler handler) { units.GetOrNew(target).GetOrNew(name).Register(handler); }
public static void Override(object target, string name, LogicEventHandler handler) { units.GetOrNew(target).GetOrNew(name).Override(handler); }
public static void Once(Type type, string name, LogicEventHandler handler) { Once((object)type, name, handler); }
public void Register(LogicEventHandler handler) { handlers.Add(handler); }
public void Override(LogicEventHandler handler) { handlers.Clear(); handlers.Add(handler); }
public void Once(LogicEventHandler handler) { handlers.Add(handler); onces.Add(handler); }