public void Recycle(ECS_Disposer obj) { Type type = obj.GetType(); ECS_Queue <ECS_Disposer> queue; if (!this.dictionary.TryGetValue(type, out queue)) { queue = new ECS_Queue <ECS_Disposer>(); this.dictionary.Add(type, queue); } queue.Enqueue(obj); }
public void Awake <P1, P2, P3>(ECS_Disposer disposer, P1 p1, P2 p2, P3 p3) { IObjectEvent objectEvent; if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent)) { return; } IAwake <P1, P2, P3> iAwake = objectEvent as IAwake <P1, P2, P3>; if (iAwake == null) { return; } objectEvent.Set(disposer); iAwake.Awake(p1, p2, p3); }
public void Awake(ECS_Disposer disposer) { IObjectEvent objectEvent; if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent)) { return; } IAwake iAwake = objectEvent as IAwake; if (iAwake == null) { return; } objectEvent.Set(disposer); iAwake.Awake(); }
public void Update(float deltaTime) { this.Start(); while (this.updates.Count > 0) { ECS_Disposer disposer = this.updates.Dequeue(); if (disposer.Id == 0) { continue; } IObjectEvent objectEvent; if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent)) { continue; } this.updates2.Enqueue(disposer); IUpdate iUpdate = objectEvent as IUpdate; if (iUpdate == null) { continue; } objectEvent.Set(disposer); #if UNITY_EDITOR iUpdate.Update(deltaTime); #else try { iUpdate.Update(deltaTime); } catch (Exception e) { Logger.LogError(e.ToString()); } #endif } ObjectHelper.Swap(ref this.updates, ref this.updates2); }
private void Start() { while (this.starts.Count > 0) { ECS_Disposer disposer = this.starts.Dequeue(); IObjectEvent objectEvent; if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent)) { continue; } IStart iStart = objectEvent as IStart; if (iStart == null) { continue; } objectEvent.Set(disposer); iStart.Start(); } }
public void Add(ECS_Disposer disposer) { IObjectEvent objectEvent; if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent)) { return; } if (objectEvent is IUpdate) { this.updates.Enqueue(disposer); } if (objectEvent is IStart) { this.starts.Enqueue(disposer); } if (objectEvent is ILateUpdate) { this.lateUpdates.Enqueue(disposer); } }