using System; namespace ETHotfix { public static class ComponentFactory { public static Component CreateWithParent(Type type, Component parent) { Component component = Game.ObjectPool.Fetch(type); component.Parent = parent; ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component); return component; } public static T CreateWithParent(Component parent) where T : Component { T component = Game.ObjectPool.Fetch(); component.Parent = parent; ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component); return component; } public static T CreateWithParent(Component parent, A a) where T : Component { T component = Game.ObjectPool.Fetch(); component.Parent = parent; ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component, a); return component; } public static T CreateWithParent(Component parent, A a, B b) where T : Component { T component = Game.ObjectPool.Fetch(); component.Parent = parent; ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component, a, b); return component; } public static T CreateWithParent(Component parent, A a, B b, C c) where T : Component { T component = Game.ObjectPool.Fetch(); component.Parent = parent; ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component, a, b, c); return component; } public static T Create() where T : Component { T component = Game.ObjectPool.Fetch(); ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component); return component; } public static T Create(A a) where T : Component { T component = Game.ObjectPool.Fetch(); ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component, a); return component; } public static T Create(A a, B b) where T : Component { T component = Game.ObjectPool.Fetch(); ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component, a, b); return component; } public static T Create(A a, B b, C c) where T : Component { T component = Game.ObjectPool.Fetch(); ComponentWithId componentWithId = component as ComponentWithId; if (componentWithId != null) { componentWithId.Id = component.InstanceId; } Game.EventSystem.Awake(component, a, b, c); return component; } public static T CreateWithId(long id) where T : ComponentWithId { T component = Game.ObjectPool.Fetch(); component.Id = id; Game.EventSystem.Awake(component); return component; } public static T CreateWithId(long id, A a) where T : ComponentWithId { T component = Game.ObjectPool.Fetch(); component.Id = id; Game.EventSystem.Awake(component, a); return component; } public static T CreateWithId(long id, A a, B b) where T : ComponentWithId { T component = Game.ObjectPool.Fetch(); component.Id = id; Game.EventSystem.Awake(component, a, b); return component; } public static T CreateWithId(long id, A a, B b, C c) where T : ComponentWithId { T component = Game.ObjectPool.Fetch(); component.Id = id; Game.EventSystem.Awake(component, a, b, c); return component; } } }