public ConditionManager(Condition condition, IMastAdapter mastInterface) { if (condition == null) { throw new NullReferenceException("Condition must not be null"); } if (mastInterface == null) { throw new NullReferenceException("IMastAdapter must not be null."); } Condition = condition; MastInterface = mastInterface; if (condition.type == ConditionType.@event) { eventHandler = ReflectionHelper.AttachEvent(MastInterface, condition.name, this, "OnEventFired"); } //Wire up our child conditions. Note - only top level conditions can be based on events, or things would get weird. foreach (Condition c in Condition.condition) { if (c.type == ConditionType.@event) { throw new Exception("Event classed conditions can not be children"); } ConditionManager cm = new ConditionManager(c, MastInterface) { ParentCondition = this }; Children.Add(cm); } }
public ConditionManager(Condition condition, IMastAdapter mastInterface) { if (condition == null) { throw new NullReferenceException("Condition must not be null"); } if (mastInterface == null) { throw new NullReferenceException("IMastAdapter must not be null."); } Condition = condition; MastInterface = mastInterface; if (condition.type == ConditionType.@event) { eventHandler = ReflectionHelper.AttachEvent(MastInterface, condition.name, this, "OnEventFired"); } //Wire up our child conditions. Note - only top level conditions can be based on events, or things would get weird. foreach (Condition c in Condition.condition) { if (c.type == ConditionType.@event) { throw new Exception("Event classed conditions can not be children"); } ConditionManager cm = new ConditionManager(c, MastInterface) { ParentCondition = this }; Children.Add(cm); } }
/// <summary> /// This is called by the engine's timer /// </summary> public void Evaluate() { if (!IsActive) { ConditionManager cm = EvaluateConditionList(StartConditions); if (cm != null) { ActivateTrigger(); } } else { ConditionManager cm = EvaluateConditionList(EndConditions); if (cm != null) { DeactivateTrigger(); } } }
//private bool spent = false; internal TriggerManager(Trigger trigger, IMastAdapter mastInterface) { if (trigger == null) { throw new NullReferenceException("Trigger must not be null."); } if (mastInterface == null) { throw new NullReferenceException("IMastAdapter must not be null."); } Trigger = trigger; MastInterface = mastInterface; foreach (Condition c in trigger.startConditions) { ConditionManager cm = new ConditionManager(c, MastInterface); //We need to wire up events, for event type conditions, and this is also used for some property calculations around time //if (c.type == ConditionType.@event) { cm.EventFired += new EventHandler(OnConditionEventFired); //} StartConditions.Add(cm); } foreach (Condition c in trigger.endConditions) { ConditionManager cm = new ConditionManager(c, MastInterface) { IsEndCondition = true }; //if (c.type == ConditionType.@event) { cm.EventFired += new EventHandler(OnConditionEventFired); //} EndConditions.Add(cm); } //we just need this for 'per clip' events, to reset the flag //ReflectionHelper.AttachEvent(MastInterface, "OnItemEnd", this, "OnItemEnd"); }
//private bool spent = false; internal TriggerManager(Trigger trigger, IMastAdapter mastInterface) { if (trigger == null) { throw new NullReferenceException("Trigger must not be null."); } if (mastInterface == null) { throw new NullReferenceException("IMastAdapter must not be null."); } Trigger = trigger; MastInterface = mastInterface; foreach (Condition c in trigger.startConditions) { ConditionManager cm = new ConditionManager(c, MastInterface); //We need to wire up events, for event type conditions, and this is also used for some property calculations around time //if (c.type == ConditionType.@event) { cm.EventFired += new EventHandler(OnConditionEventFired); //} StartConditions.Add(cm); } foreach (Condition c in trigger.endConditions) { ConditionManager cm = new ConditionManager(c, MastInterface) { IsEndCondition = true }; //if (c.type == ConditionType.@event) { cm.EventFired += new EventHandler(OnConditionEventFired); //} EndConditions.Add(cm); } //we just need this for 'per clip' events, to reset the flag //ReflectionHelper.AttachEvent(MastInterface, "OnItemEnd", this, "OnItemEnd"); }