1
This commit is contained in:
@@ -62,11 +62,28 @@ namespace BITKit.Entities
|
||||
else if(attribute?.CanBeNull is false)
|
||||
{
|
||||
BIT4Log.Warning<Entity>($"{name}未找到{obj.GetType().Name}需要的{type.FullName}");
|
||||
BIT4Log.Warning<Entity>(genericEvent.GetDiagnostics());
|
||||
//BIT4Log.Warning<Entity>(genericEvent.GetDiagnostics());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddService<T>(T service)
|
||||
{
|
||||
AddService(typeof(T),service);
|
||||
}
|
||||
|
||||
public void AddService(object service)
|
||||
{
|
||||
AddService(service.GetType(),service);
|
||||
}
|
||||
|
||||
public void AddService(Type type, object service)
|
||||
{
|
||||
genericEvent.Set(type,service);
|
||||
genericEvent.Set(type.FullName, service);
|
||||
genericEvent.SetDirect(type.FullName,service);
|
||||
}
|
||||
|
||||
private CancellationToken _cancellationToken;
|
||||
private bool isInitialized;
|
||||
private Core.Entites.IEntityComponent[] _components => entityComponents.Cast<Core.Entites.IEntityComponent>().ToArray();
|
||||
@@ -85,6 +102,7 @@ namespace BITKit.Entities
|
||||
try
|
||||
{
|
||||
var monoBehaviours = GetComponentsInChildren<MonoBehaviour>(true);
|
||||
entityComponents.ForEach(x => x.Initialize(this));
|
||||
foreach (var x in monoBehaviours)
|
||||
{
|
||||
foreach (var att in x
|
||||
@@ -95,9 +113,7 @@ namespace BITKit.Entities
|
||||
.OfType<CustomTypeAttribute>()
|
||||
)
|
||||
{
|
||||
genericEvent.Set(att.Type,x);
|
||||
genericEvent.Set(att.Type.FullName, x);
|
||||
genericEvent.SetDirect(att.Type.FullName,x);
|
||||
AddService(att.Type, x);
|
||||
}
|
||||
genericEvent.Set(x.GetType(),x);
|
||||
}
|
||||
@@ -105,7 +121,7 @@ namespace BITKit.Entities
|
||||
{
|
||||
Inject(x);
|
||||
}
|
||||
entityComponents.ForEach(x => x.Initialize(this));
|
||||
|
||||
|
||||
entityComponents.ForEach(x => x.OnAwake());
|
||||
entityComponents.ForEach(x => x.OnStart());
|
||||
|
@@ -11,6 +11,9 @@ namespace BITKit.Entities
|
||||
public interface IEntity :BITKit.Core.Entites.IEntity,IGenericEvent<string>, IDatabase, IProcessor, ICallback
|
||||
{
|
||||
IEntityComponent[] entityComponents { get; set; }
|
||||
void AddService<T>(T service);
|
||||
void AddService(object service);
|
||||
void AddService(Type type, object service);
|
||||
}
|
||||
public class IEntityReader : NetMessageReader<IEntity>
|
||||
{
|
||||
|
Reference in New Issue
Block a user