public void AddEntityRemovedListener(OnEntityRemovedCallback callback) { for (int i = 0; i < this._onEntityRemovedCallbackCount; i++) { if (this._onEntityRemovedCallbacks[i] == callback) { throw new Exception("Callback already added."); } } if (this._onEntityRemovedCallbackCount == this._onEntityRemovedCallbacks.Length) { Array.Resize(ref this._onEntityRemovedCallbacks, 2 * this._onEntityRemovedCallbackCount); } this._onEntityRemovedCallbacks[this._onEntityRemovedCallbackCount++] = callback; }
public bool RemoveEntityRemovedListener(OnEntityRemovedCallback callback) { for (int i = 0; i < this._onEntityRemovedCallbackCount; i++) { if (this._onEntityRemovedCallbacks[i] == callback) { this._onEntityRemovedCallbackCount--; // Can't swap with last because listeners are ordered. Array.Copy(this._onEntityRemovedCallbacks, i + 1, this._onEntityRemovedCallbacks, i, this._onEntityRemovedCallbackCount - i); return(true); } } // Not found. return(false); }