Beispiel #1
0
 public TriggerRecord ProduceImmediately()
 {
     if (_triggerTemplate != null)
     {
         object        copyObj   = _triggerTemplate.DeserializeXML(_triggerTemplate.SerializeXML());
         TriggerRecord resultObj = copyObj as TriggerRecord;
         return(resultObj);
     }
     if (_scriptNamespaceAndClassName == null)
     {
         return(null);
     }
     Assembly[] asmList = System.AppDomain.CurrentDomain.GetAssemblies();
     foreach (Assembly asm in asmList)
     {
         object obj = asm.CreateInstance(_scriptNamespaceAndClassName);
         if (obj != null)
         {
             TriggerRecord tObj      = obj as TriggerRecord;
             object        copyObj   = tObj.DeserializeXML(_scriptSerializeXml);
             TriggerRecord resultObj = copyObj as TriggerRecord;
             return(resultObj);
         }
     }
     return(null);
 }
Beispiel #2
0
 public void UnregisterTrigger(object obj)
 {
     if (_triggerList == null)
     {
         return;
     }
     if (obj is TriggerRecord)
     {
         TriggerRecord trigger = obj as TriggerRecord;
         lock (_locker)
         {
             _triggerList.Remove(trigger);
         }
     }
 }
Beispiel #3
0
        public void RemoveTriggerRecord(TriggerRecord trigger)
        {
            if (TriggerList == null)
            {
                return;
            }
            TriggerList.Remove(trigger);
            //remove from TriggerSystem
            long   nowTick  = DateTime.Now.Ticks;
            double interval = (nowTick - _lastStepTick) / TimeSpan.TicksPerMillisecond;

            if (interval < 50)
            {
                ((TriggerSystem)_currentView.MainTriggerSystem).UnregisterTrigger(trigger);
            }
        }
Beispiel #4
0
        public void AddTriggerRecord(TriggerRecord trigger)
        {
            if (TriggerList == null)
            {
                TriggerList = new List <TriggerRecord>();
            }
            trigger.ParentActor = this;
            TriggerList.Add(trigger);
            //add into TriggerSystem
            long   nowTick  = DateTime.Now.Ticks;
            double interval = (nowTick - _lastStepTick) / TimeSpan.TicksPerMillisecond;

            if (interval < 50)
            {
                ((TriggerSystem)_currentView.MainTriggerSystem).RegisterTrigger(trigger);
            }
        }
Beispiel #5
0
 public void RegisterTrigger(object obj)
 {
     if (_triggerList == null)
     {
         _triggerList = new List <TriggerRecord>();
     }
     if (obj is TriggerRecord)
     {
         TriggerRecord trigger = obj as TriggerRecord;
         int           i       = 0;
         for (; i < _triggerList.Count; ++i)
         {
             if (_triggerList[i].Priority > trigger.Priority)
             {
                 break;
             }
         }
         lock (_locker)
         {
             _triggerList.Insert(i, trigger);
         }
     }
 }
Beispiel #6
0
 /// <summary>
 /// 触发器进入
 /// </summary>
 /// <param name="trigger"></param>
 public virtual bool OnTrigger(TriggerRecord trigger)
 {
     return(false);
 }
Beispiel #7
0
 public VdsTrigger(TriggerRecord triggerTemplate)
     : base()
 {
     _triggerTemplate = triggerTemplate;
 }