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); }
public void UnregisterTrigger(object obj) { if (_triggerList == null) { return; } if (obj is TriggerRecord) { TriggerRecord trigger = obj as TriggerRecord; lock (_locker) { _triggerList.Remove(trigger); } } }
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); } }
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); } }
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); } } }
/// <summary> /// 触发器进入 /// </summary> /// <param name="trigger"></param> public virtual bool OnTrigger(TriggerRecord trigger) { return(false); }
public VdsTrigger(TriggerRecord triggerTemplate) : base() { _triggerTemplate = triggerTemplate; }