示例#1
0
        public bool TryGetElement <T>(out T element)
        {
            if (GameElementUtils.TryFind(this.elementMap, out T result))
            {
                element = result;
                return(true);
            }

            element = default(T);
            return(false);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 public T GetElement <T>()
 {
     return(GameElementUtils.Find <T>(this.elementMap));
 }