Example #1
0
        public T AddComponent <T>() where T : Component, new()
        {
            T cmp = new T();

            // Shortcuts

            if (this.audio == null && cmp is AudioEmitter)
            {
                this.audio = (AudioEmitter)(Component)cmp;
            }

            if (this.body == null && cmp is BasicBody)
            {
                this.body = (BasicBody)(Component)cmp;
            }

            if (this.sprite == null && cmp is SpriteRenderer)
            {
                this.sprite = (SpriteRenderer)(Component)cmp;
            }

            if (this.camera == null && cmp is Camera)
            {
                this.camera = (Camera)(Component)cmp;
            }

            cmp.entity = this;
            cmp.OnCreate();

            _components.Add(cmp);

            return(cmp);
        }
Example #2
0
 public void Unregister(BasicBody body)
 {
     _bodies.Remove(body);
 }
Example #3
0
 public void Register(BasicBody body)
 {
     _bodies.Add(body);
 }