| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- 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<T>(Component parent) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- 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<T, A>(Component parent, A a) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- 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<T, A, B>(Component parent, A a, B b) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- 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<T, A, B, C>(Component parent, A a, B b, C c) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- 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<T>() where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- ComponentWithId componentWithId = component as ComponentWithId;
- if (componentWithId != null)
- {
- componentWithId.Id = component.InstanceId;
- }
- Game.EventSystem.Awake(component);
- return component;
- }
- public static T Create<T, A>(A a) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- ComponentWithId componentWithId = component as ComponentWithId;
- if (componentWithId != null)
- {
- componentWithId.Id = component.InstanceId;
- }
- Game.EventSystem.Awake(component, a);
- return component;
- }
- public static T Create<T, A, B>(A a, B b) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- ComponentWithId componentWithId = component as ComponentWithId;
- if (componentWithId != null)
- {
- componentWithId.Id = component.InstanceId;
- }
- Game.EventSystem.Awake(component, a, b);
- return component;
- }
- public static T Create<T, A, B, C>(A a, B b, C c) where T : Component
- {
- T component = Game.ObjectPool.Fetch<T>();
- 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<T>(long id) where T : ComponentWithId
- {
- T component = Game.ObjectPool.Fetch<T>();
- component.Id = id;
- Game.EventSystem.Awake(component);
- return component;
- }
- public static T CreateWithId<T, A>(long id, A a) where T : ComponentWithId
- {
- T component = Game.ObjectPool.Fetch<T>();
- component.Id = id;
- Game.EventSystem.Awake(component, a);
- return component;
- }
- public static T CreateWithId<T, A, B>(long id, A a, B b) where T : ComponentWithId
- {
- T component = Game.ObjectPool.Fetch<T>();
- component.Id = id;
- Game.EventSystem.Awake(component, a, b);
- return component;
- }
- public static T CreateWithId<T, A, B, C>(long id, A a, B b, C c) where T : ComponentWithId
- {
- T component = Game.ObjectPool.Fetch<T>();
- component.Id = id;
- Game.EventSystem.Awake(component, a, b, c);
- return component;
- }
- }
- }
|