Example #1
0
        public Entity AddComponent(BaseComponent c, bool overwriteIfExists = false)
        {
            var componentType = c.GetType().Name;
            if (this.HasComponent(componentType) && !overwriteIfExists)
            {
                throw new ApplicationException("Component already exists on this entity");
            }

            this.Components[componentType] = c;
            this.OnComponentAdded(c);
            return this;
        }
Example #2
0
 protected void OnComponentRemoved(BaseComponent c)
 {
     if (this.ComponentRemoved != null)
         ComponentRemoved(this, new ComponentChangedEventArgs() { Component = c });
 }