public static T Create <T, A, B>(Entity domain, A a, B b) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, true); component.Domain = domain; component.Id = Utility.IdGenerater.GenerateId(); HotfixSystem.Awake(component, a, b); return(component); }
public static Entity Create(Entity domain, Type type) { Entity component = Entity.Create(type, true); component.Domain = domain; component.Id = Utility.IdGenerater.GenerateId(); HotfixSystem.Awake(component); return(component); }
public static T Create <T, A>(A a) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, true); component.Domain = null; component.Id = Utility.IdGenerater.GenerateId(); HotfixSystem.Awake(component, a); return(component); }
private Entity CreateWithComponentParent(Type type, bool isFromPool = true) { Entity component = Create(type, isFromPool); component.Id = parent.Id; component.ComponentParent = parent; HotfixSystem.Awake(component); return(component); }
public static T CreateWithParent <T, A, B, C, D>(Entity parent, A a, B b, C c, D d, bool fromPool = true) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, true); component.Id = Utility.IdGenerater.GenerateId(); component.Parent = parent; HotfixSystem.Awake(component, a, b, c, d); return(component); }
public static T CreateWithParent <T, A>(Entity parent, A a) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, true); component.Id = Utility.IdGenerater.GenerateId(); component.Parent = parent; HotfixSystem.Awake(component, a); return(component); }
public static T CreateWithParentAndId <T, A, B, C, D>(Entity parent, long id, A a, B b, C c, D d, bool fromPool = true) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, true); component.Id = id; component.Parent = parent; HotfixSystem.Awake(component, a, b, c, d); return(component); }
public static T CreateWithParentAndId <T, A>(Entity parent, long id, A a) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, true); component.Id = id; component.Parent = parent; HotfixSystem.Awake(component, a); return(component); }
private T CreateWithComponentParent <T, A, B, C>(A a, B b, C c, bool isFromPool = true) where T : Entity { Type type = typeof(T); Entity component = Create(type, isFromPool); component.Id = this.Id; component.ComponentParent = this; HotfixSystem.Awake(component, a, b, c); return((T)component); }
public override void Dispose() { if (this.IsDisposed) { return; } HotfixSystem.Remove(this.InstanceId); this.InstanceId = 0; // 清理Component if (this.components != null) { foreach (var kv in this.components) { kv.Value.Dispose(); } this.components.Clear(); dictPool.Recycle(this.components); this.components = null; // 从池中创建的才需要回到池中,从db中不需要回收 if (this.componentsDB != null) { this.componentsDB.Clear(); if (this.IsFromPool) { hashSetPool.Recycle(this.componentsDB); this.componentsDB = null; } } } // 清理Children if (this.children != null) { foreach (Entity child in this.children.Values) { child.Dispose(); } this.children.Clear(); childrenPool.Recycle(this.children); this.children = null; if (this.childrenDB != null) { this.childrenDB.Clear(); // 从池中创建的才需要回到池中,从db中不需要回收 if (this.IsFromPool) { hashSetPool.Recycle(this.childrenDB); this.childrenDB = null; } } } // 触发Destroy事件 HotfixSystem.Destroy(this); this.domain = null; if (this.parent != null && !this.parent.IsDisposed) { if (this.IsComponent) { this.parent.RemoveComponent(this); } else { this.parent.RemoveChild(this); } } this.parent = null; if (this.IsFromPool) { ObjectPool.Instance.Recycle(this); } //else //{ // base.Dispose(); //} status = EntityStatus.None; }