Esempio n. 1
0
        public void AddEvent_containMultiTrigger_TheAddedEventGetsFired()
        {
            TriggerManager tm = new TriggerManager();

            bool eventfired = false;

            MultiTrigger mt = new MultiTrigger();

            tm.Register(mt);

            mt.AddAction<XmasEvent>(e => eventfired = true);

            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            tm.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsTrue(eventfired);
        }
Esempio n. 2
0
        public void RemoveAction_containMultiTrigger_TheActionIsNotFired()
        {
            TriggerManager tm = new TriggerManager();

            bool actionfired = false;

            MultiTrigger mt = new MultiTrigger();

            Action<UnitTakesDamagePostEvent> action = (e => actionfired = true);
            mt.AddAction(action);
            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            tm.Register(mt);

            mt.RemoveAction(action);

            tm.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsFalse(actionfired);
        }
Esempio n. 3
0
        public void RemoveCondition_containMultiTrigger_TheActionIsFired()
        {
            TriggerManager tm = new TriggerManager();

            bool actionfired = false;

            MultiTrigger mt = new MultiTrigger();

            Predicate<UnitTakesDamagePostEvent> cond = (e => false);
            mt.AddCondition(cond);
            mt.AddAction<XmasEvent>(e => actionfired = true);
            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            tm.Register(mt);

            mt.RemoveCondition(cond);

            tm.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsTrue(actionfired);
        }
 internal ThreadSafeEventQueue(TriggerManager unsafeTriggers)
 {
     foreignTriggermanager = unsafeTriggers;
     foreignTriggermanager.EventRaised += foreignTriggermanager_EventRaised;
 }