예제 #1
0
파일: Entity.cs 프로젝트: tammukul/Lemma
        public void SetMain(BaseMain _main)
        {
            if (this.GUID == 0)
            {
                this.GUID = Entity.CurrentGUID;
            }

            Entity.CurrentGUID = Math.Max(Entity.CurrentGUID, this.GUID + 1);
            Entity.guidTable.Add(this.GUID, this);

            this.main = _main;

            if (!string.IsNullOrEmpty(this.ID))
            {
                Entity.idTable.Add(this.ID, this);
            }

            if (_main.EditorEnabled)
            {
                this.OnSave         = new Command();
                this.EditorSelected = new Property <bool>();
                string oldId = this.ID;
                this.Add(new NotifyBinding(delegate()
                {
                    if (!string.IsNullOrEmpty(oldId))
                    {
                        Entity.idTable.Remove(oldId);
                    }
                    if (!string.IsNullOrEmpty(this.ID))
                    {
                        Entity.idTable.Add(this.ID, this);
                    }
                    oldId = this.ID;
                }, this.ID));
            }

            Entity.componentCache.AddRange(this.components.Values);
            for (int i = 0; i < Entity.componentCache.Count; i++)
            {
                IComponent c = Entity.componentCache[i];
                c.Entity = this;
                this.main.AddComponent(c);
            }
            Entity.componentCache.Clear();
        }
예제 #2
0
파일: Entity.cs 프로젝트: schmittens/Lemma
        public void SetMain(BaseMain _main)
        {
            if (this.GUID == 0)
            {
                this.GUID = Entity.CurrentGUID;
            }

            Entity.CurrentGUID = Math.Max(Entity.CurrentGUID, this.GUID + 1);
            Entity.guidTable.Add(this.GUID, this);

            this.main = _main;

            if (!string.IsNullOrEmpty(this.ID))
            {
                Entity.idTable.Add(this.ID, this);
            }

            if (_main.EditorEnabled)
            {
                this.OnSave         = new Command();
                this.EditorSelected = new Property <bool>();
                string oldId = this.ID;
                this.Add(new NotifyBinding(delegate()
                {
                    if (!string.IsNullOrEmpty(oldId))
                    {
                        Entity.idTable.Remove(oldId);
                    }
                    if (!string.IsNullOrEmpty(this.ID))
                    {
                        Entity.idTable.Add(this.ID, this);
                    }
                    oldId = this.ID;
                }, this.ID));
            }

            foreach (IComponent c in this.components.Values.ToList())
            {
                c.Entity = this;
                this.main.AddComponent(c);
            }
        }
예제 #3
0
 public void SetMain(BaseMain _main)
 {
     this.Active = true;
     this.main   = (MainClass)_main;
 }
예제 #4
0
파일: Entity.cs 프로젝트: schmittens/Lemma
 public Entity(BaseMain _main, string _type)
     : this()
 {
     // Called by a Factory
     this.Type = _type;
 }