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(); }
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); } }
public void SetMain(BaseMain _main) { this.Active = true; this.main = (MainClass)_main; }
public Entity(BaseMain _main, string _type) : this() { // Called by a Factory this.Type = _type; }