1
This commit is contained in:
@@ -34,21 +34,47 @@ namespace BITKit.IO
|
||||
var scriptableObject = objs[index];
|
||||
var entity = new Entity();
|
||||
|
||||
var idComponent = new IdComponent();
|
||||
var idComponent = new IdComponent()
|
||||
{
|
||||
Name = scriptableObject.name
|
||||
};
|
||||
|
||||
entity.ServiceCollection.AddSingleton(idComponent);
|
||||
|
||||
var type = scriptableObject.GetType();
|
||||
|
||||
var typeName = type.Name;
|
||||
|
||||
entity.ServiceCollection.AddSingleton(type, scriptableObject);
|
||||
|
||||
foreach (var x in type.GetInterfaces())
|
||||
{
|
||||
entity.ServiceCollection.AddSingleton(x, scriptableObject);
|
||||
}
|
||||
|
||||
while (type is not null)
|
||||
{
|
||||
if (type.BaseType is null) break;
|
||||
entity.ServiceCollection.AddSingleton(type.BaseType, scriptableObject);
|
||||
type = type.BaseType;
|
||||
typeName += $":{type.Name}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
_entitiesService.Register(entity);
|
||||
|
||||
logger?.LogInformation($"已加载:{scriptableObject.name}:{type.Name},剩余:{index + 1}/{objs.Count}");
|
||||
logger?.LogInformation($"已加载:{scriptableObject.name}:{typeName},剩余:{index + 1}/{objs.Count}");
|
||||
_registeredEntities.Add(entity);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
logger?.LogInformation("加载完成");
|
||||
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
Reference in New Issue
Block a user