public virtual bool AddElement(object element) { if (!this.elements.Add(element)) { return(false); } if (element is IGameElement gameElement) { gameElement.OnRegistered(this.GameSystem); GameElementUtils.SyncState(gameElement, this.State); } return(true); }
public bool AddElement(K key, V element) { if (this.elementMap.ContainsKey(key)) { return(false); } this.elementMap.Add(key, element); if (element is IGameElement gameElement) { gameElement.OnRegistered(this.GameSystem); GameElementUtils.SyncState(gameElement, this.State); } return(true); }
public bool AddElement(object element) { var type = element.GetType(); if (this.elementMap.ContainsKey(type)) { return(false); } this.elementMap.Add(type, element); if (element is IGameElement gameElement) { gameElement.OnRegistered(this.GameSystem); GameElementUtils.SyncState(gameElement, this.State); } return(true); }