| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- using System;
- namespace ETModel
- {
- public static class EntityFactory
- {
- public static Entity CreateWithParent(Type type, Entity parent)
- {
- Entity component = Entity.Create(type, true);
- component.Id = IdGenerater.GenerateId();
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component);
- return component;
- }
- public static T CreateWithParent<T>(Entity parent) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Id = IdGenerater.GenerateId();
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component);
- 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 = IdGenerater.GenerateId();
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component, a);
- return component;
- }
- public static T CreateWithParent<T, A, B>(Entity parent, A a, B b) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Id = IdGenerater.GenerateId();
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component, a, b);
- return component;
- }
- public static T CreateWithParent<T, A, B, C>(Entity parent, A a, B b, C c, bool fromPool = true) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Id = IdGenerater.GenerateId();
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component, a, b, c);
- 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 = IdGenerater.GenerateId();
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component, a, b, c, d);
- return component;
- }
-
-
- public static Entity CreateWithParentAndId(Type type, Entity parent, long id)
- {
- Entity component = Entity.Create(type, true);
- component.Id = id;
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component);
- return component;
- }
- public static T CreateWithParentAndId<T>(Entity parent, long id) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Id = id;
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component);
- 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;
-
- EventSystem.Instance.Awake(component, a);
- return component;
- }
- public static T CreateWithParentAndId<T, A, B>(Entity parent, long id, A a, B b) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Id = id;
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component, a, b);
- return component;
- }
- public static T CreateWithParentAndId<T, A, B, C>(Entity parent, long id, A a, B b, C c, bool fromPool = true) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Id = id;
- component.Parent = parent;
-
- EventSystem.Instance.Awake(component, a, b, c);
- 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;
-
- EventSystem.Instance.Awake(component, a, b, c, d);
- return component;
- }
-
-
- public static Entity Create(Entity domain, Type type)
- {
- Entity component = Entity.Create(type, true);
- component.Domain = domain;
- component.Id = IdGenerater.GenerateId();
-
- EventSystem.Instance.Awake(component);
- return component;
- }
- public static T Create<T>(Entity domain) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = IdGenerater.GenerateId();
- EventSystem.Instance.Awake(component);
- return component;
- }
- public static T Create<T, A>(Entity domain, A a) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = IdGenerater.GenerateId();
- EventSystem.Instance.Awake(component, a);
- return component;
- }
- 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 = IdGenerater.GenerateId();
- EventSystem.Instance.Awake(component, a, b);
- return component;
- }
- public static T Create<T, A, B, C>(Entity domain, A a, B b, C c) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = IdGenerater.GenerateId();
- EventSystem.Instance.Awake(component, a, b, c);
- return component;
- }
- public static T CreateWithId<T>(Entity domain, long id) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = id;
- EventSystem.Instance.Awake(component);
- return component;
- }
- public static T CreateWithId<T, A>(Entity domain, long id, A a) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = id;
- EventSystem.Instance.Awake(component, a);
- return component;
- }
- public static T CreateWithId<T, A, B>(Entity domain, long id, A a, B b) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = id;
- EventSystem.Instance.Awake(component, a, b);
- return component;
- }
- public static T CreateWithId<T, A, B, C>(Entity domain, long id, A a, B b, C c) where T : Entity
- {
- Type type = typeof (T);
- T component = (T)Entity.Create(type, true);
- component.Domain = domain;
- component.Id = id;
- EventSystem.Instance.Awake(component, a, b, c);
- return component;
- }
- }
- }
|