Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }