|
|
@@ -2,9 +2,9 @@
|
|
|
|
|
|
namespace ET
|
|
|
{
|
|
|
- public static class EntityFactory
|
|
|
+ public partial class Entity
|
|
|
{
|
|
|
- public static T CreateWithParent<T>(Entity parent, bool isFromPool = false) where T : Entity
|
|
|
+ public static T Create<T>(Entity parent, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -15,7 +15,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParent<T, A>(Entity parent, A a, bool isFromPool = false) where T : Entity
|
|
|
+ public static T Create<T, A>(Entity parent, A a, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -26,7 +26,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParent<T, A, B>(Entity parent, A a, B b, bool isFromPool = false) where T : Entity
|
|
|
+ public static T Create<T, A, B>(Entity parent, A a, B b, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -37,7 +37,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParent<T, A, B, C>(Entity parent, A a, B b, C c, bool isFromPool = false) where T : Entity
|
|
|
+ public static T Create<T, A, B, C>(Entity parent, A a, B b, C c, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -48,7 +48,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParent<T, A, B, C, D>(Entity parent, A a, B b, C c, D d, bool isFromPool = false) where T : Entity
|
|
|
+ public static T Create<T, A, B, C, D>(Entity parent, A a, B b, C c, D d, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -59,7 +59,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParentAndId<T>(Entity parent, long id, bool isFromPool = false) where T : Entity
|
|
|
+ public static T CreateWithId<T>(Entity parent, long id, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -70,7 +70,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParentAndId<T, A>(Entity parent, long id, A a, bool isFromPool = false) where T : Entity
|
|
|
+ public static T CreateWithId<T, A>(Entity parent, long id, A a, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -81,7 +81,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParentAndId<T, A, B>(Entity parent, long id, A a, B b, bool isFromPool = false) where T : Entity
|
|
|
+ public static T CreateWithId<T, A, B>(Entity parent, long id, A a, B b, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -92,7 +92,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParentAndId<T, A, B, C>(Entity parent, long id, A a, B b, C c, bool isFromPool = false) where T : Entity
|
|
|
+ public static T CreateWithId<T, A, B, C>(Entity parent, long id, A a, B b, C c, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -103,7 +103,7 @@ namespace ET
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithParentAndId<T, A, B, C, D>(Entity parent, long id, A a, B b, C c, D d, bool isFromPool = false) where T : Entity
|
|
|
+ public static T CreateWithId<T, A, B, C, D>(Entity parent, long id, A a, B b, C c, D d, bool isFromPool = false) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
T component = (T) Entity.Create(type, isFromPool);
|
|
|
@@ -113,95 +113,81 @@ namespace ET
|
|
|
EventSystem.Instance.Awake(component, a, b, c, d);
|
|
|
return component;
|
|
|
}
|
|
|
-
|
|
|
- public static T Create<T>(Entity domain, bool isFromPool = false) where T : Entity
|
|
|
- {
|
|
|
- Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = IdGenerater.Instance.GenerateId();
|
|
|
- EventSystem.Instance.Awake(component);
|
|
|
- return component;
|
|
|
- }
|
|
|
-
|
|
|
- public static T Create<T, A>(Entity domain, A a, bool isFromPool = false) where T : Entity
|
|
|
- {
|
|
|
- Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = IdGenerater.Instance.GenerateId();
|
|
|
- EventSystem.Instance.Awake(component, a);
|
|
|
- return component;
|
|
|
- }
|
|
|
-
|
|
|
- public static T Create<T, A, B>(Entity domain, A a, B b, bool isFromPool = false) where T : Entity
|
|
|
- {
|
|
|
- Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = IdGenerater.Instance.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, bool isFromPool = false) where T : Entity
|
|
|
- {
|
|
|
- Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = IdGenerater.Instance.GenerateId();
|
|
|
- EventSystem.Instance.Awake(component, a, b, c);
|
|
|
- return component;
|
|
|
- }
|
|
|
|
|
|
- public static T Create<T, A, B, C, D>(Entity domain, A a, B b, C c, D d, bool isFromPool = false) where T : Entity
|
|
|
- {
|
|
|
- Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = IdGenerater.Instance.GenerateId();
|
|
|
- EventSystem.Instance.Awake(component, a, b, c, d);
|
|
|
+ private static Entity Create(Type type, bool isFromPool)
|
|
|
+ {
|
|
|
+ Entity component;
|
|
|
+ if (isFromPool)
|
|
|
+ {
|
|
|
+ component = (Entity)ObjectPool.Instance.Fetch(type);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ component = (Entity)Activator.CreateInstance(type);
|
|
|
+ }
|
|
|
+ component.IsFromPool = isFromPool;
|
|
|
+ component.IsCreate = true;
|
|
|
+ component.Id = 0;
|
|
|
+ return component;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Entity CreateWithComponentParent(Type type, bool isFromPool = true)
|
|
|
+ {
|
|
|
+ Entity component = Create(type, isFromPool);
|
|
|
+
|
|
|
+ component.Id = this.Id;
|
|
|
+ component.ComponentParent = this;
|
|
|
+
|
|
|
+ EventSystem.Instance.Awake(component);
|
|
|
return component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithId<T>(Entity domain, long id, bool isFromPool = false) where T : Entity
|
|
|
+ private T CreateWithComponentParent<T>(bool isFromPool = true) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = id;
|
|
|
+ Entity component = Create(type, isFromPool);
|
|
|
+
|
|
|
+ component.Id = this.Id;
|
|
|
+ component.ComponentParent = this;
|
|
|
+
|
|
|
EventSystem.Instance.Awake(component);
|
|
|
- return component;
|
|
|
+ return (T)component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithId<T, A>(Entity domain, long id, A a, bool isFromPool = false) where T : Entity
|
|
|
+ private T CreateWithComponentParent<T, A>(A a, bool isFromPool = true) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = id;
|
|
|
+ Entity component = Create(type, isFromPool);
|
|
|
+
|
|
|
+ component.Id = this.Id;
|
|
|
+ component.ComponentParent = this;
|
|
|
+
|
|
|
EventSystem.Instance.Awake(component, a);
|
|
|
- return component;
|
|
|
+ return (T)component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithId<T, A, B>(Entity domain, long id, A a, B b, bool isFromPool = false) where T : Entity
|
|
|
+ private T CreateWithComponentParent<T, A, B>(A a, B b, bool isFromPool = true) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = id;
|
|
|
+ Entity component = Create(type, isFromPool);
|
|
|
+
|
|
|
+ component.Id = this.Id;
|
|
|
+ component.ComponentParent = this;
|
|
|
+
|
|
|
EventSystem.Instance.Awake(component, a, b);
|
|
|
- return component;
|
|
|
+ return (T)component;
|
|
|
}
|
|
|
|
|
|
- public static T CreateWithId<T, A, B, C>(Entity domain, long id, A a, B b, C c, bool isFromPool = false) where T : Entity
|
|
|
+ private T CreateWithComponentParent<T, A, B, C>(A a, B b, C c, bool isFromPool = true) where T : Entity
|
|
|
{
|
|
|
Type type = typeof (T);
|
|
|
- T component = (T) Entity.Create(type, isFromPool);
|
|
|
- component.Domain = domain;
|
|
|
- component.Id = id;
|
|
|
+ Entity component = Create(type, isFromPool);
|
|
|
+
|
|
|
+ component.Id = this.Id;
|
|
|
+ component.ComponentParent = this;
|
|
|
+
|
|
|
EventSystem.Instance.Awake(component, a, b, c);
|
|
|
- return component;
|
|
|
+ return (T)component;
|
|
|
}
|
|
|
}
|
|
|
}
|