public bool TryGetElement <T>(out T element) { if (GameElementUtils.TryFind(this.elementMap, out T result)) { element = result; return(true); } element = default(T); return(false); }
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); GameElementUtils.SyncState(gameElement, this.State); } return(true); }
public T GetElement <T>() { return(GameElementUtils.Find <T>(this.elementMap)); }