|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Reflection; |
|
|
|
|
using System.Runtime.InteropServices; |
|
|
|
@ -70,16 +69,23 @@ public unsafe partial class Universe |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Entity Lookup<T>() |
|
|
|
|
=> Lookup(typeof(T)); |
|
|
|
|
public Entity Lookup(Type type) |
|
|
|
|
public Entity TryLookup<T>() |
|
|
|
|
=> TryLookup(typeof(T)); |
|
|
|
|
public Entity TryLookup(Type type) |
|
|
|
|
=> _byType.TryGetValue(type, out var e) ? new(this, e) : default; |
|
|
|
|
public Entity TryLookup(ecs_entity_t value) |
|
|
|
|
=> new(this, ecs_get_alive(this, value)); |
|
|
|
|
public Entity TryLookup(string path) |
|
|
|
|
=> new(this, ecs_lookup_path_w_sep(this, default, path, ".", default, true)); |
|
|
|
|
|
|
|
|
|
public Entity Lookup(string path) |
|
|
|
|
=> new(this, !path.Contains('.') ? ecs_lookup(this, path) |
|
|
|
|
: ecs_lookup_path_w_sep(this, default, path, ".", default, true)); |
|
|
|
|
public Entity Lookup<T>() |
|
|
|
|
=> TryLookup<T>().ThrowIfNone(); |
|
|
|
|
public Entity Lookup(Type type) |
|
|
|
|
=> TryLookup(type).ThrowIfNone(); |
|
|
|
|
public Entity Lookup(ecs_entity_t value) |
|
|
|
|
=> new(this, ecs_get_alive(this, value)); |
|
|
|
|
=> TryLookup(value).ThrowIfNone(); |
|
|
|
|
public Entity Lookup(string path) |
|
|
|
|
=> TryLookup(path).ThrowIfNone(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void RegisterAll(Assembly? from = null) |
|
|
|
@ -87,16 +93,11 @@ public unsafe partial class Universe |
|
|
|
|
from ??= Assembly.GetEntryAssembly()!; |
|
|
|
|
foreach (var type in from.GetTypes()) { |
|
|
|
|
var isPartOfModule = type.DeclaringType?.Has<ModuleAttribute>() == true; |
|
|
|
|
if (type.Has<RelationAttribute>()) { |
|
|
|
|
if (!isPartOfModule) RegisterRelation(type); |
|
|
|
|
} else if (type.Has<ComponentAttribute>()) { |
|
|
|
|
if (!isPartOfModule) RegisterComponent(type); |
|
|
|
|
} else if (type.Has<TagAttribute>()) { |
|
|
|
|
if (!isPartOfModule) RegisterTag(type); |
|
|
|
|
} else if (type.Has<EntityAttribute>()) { |
|
|
|
|
if (!isPartOfModule) RegisterEntity(type); |
|
|
|
|
} else if (type.Has<ModuleAttribute>()) |
|
|
|
|
RegisterModule(type); |
|
|
|
|
if (type.Has<RelationAttribute>()) { if (!isPartOfModule) RegisterRelation(type); } |
|
|
|
|
else if (type.Has<ComponentAttribute>()) { if (!isPartOfModule) RegisterComponent(type); } |
|
|
|
|
else if (type.Has<TagAttribute>()) { if (!isPartOfModule) RegisterTag(type); } |
|
|
|
|
else if (type.Has<EntityAttribute>()) { if (!isPartOfModule) RegisterEntity(type); } |
|
|
|
|
else if (type.Has<ModuleAttribute>()) RegisterModule(type); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -175,8 +176,7 @@ public unsafe partial class Universe |
|
|
|
|
public Entity Create(ecs_entity_desc_t desc) |
|
|
|
|
{ |
|
|
|
|
var entity = ecs_entity_init(Handle, &desc); |
|
|
|
|
Debug.Assert(entity.Data != 0, "ECS_INVALID_PARAMETER"); |
|
|
|
|
return new(this, entity); |
|
|
|
|
return new Entity(this, entity).ThrowIfNone(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|