|
|
@ -5,29 +5,18 @@ public abstract class EntityBase<TReturn> |
|
|
|
{ |
|
|
|
{ |
|
|
|
public abstract World World { get; } |
|
|
|
public abstract World World { get; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract TReturn Add(Id id); |
|
|
|
public abstract TReturn Add(Id id); |
|
|
|
public abstract TReturn Remove(Id id); |
|
|
|
public abstract TReturn Remove(Id id); |
|
|
|
public abstract bool Has(Id id); |
|
|
|
public abstract bool Has(Id id); |
|
|
|
|
|
|
|
|
|
|
|
public TReturn Add(string symbol) => Add(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
public TReturn Add(string symbol) => Add(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
public TReturn Add<T>() => Add(World.LookupByTypeOrThrow(typeof(T))); |
|
|
|
|
|
|
|
public TReturn Add(Entity relation, Entity target) => Add(Id.Pair(relation, target)); |
|
|
|
public TReturn Add(Entity relation, Entity target) => Add(Id.Pair(relation, target)); |
|
|
|
public TReturn Add<TRelation>(Entity target) => Add(World.LookupByTypeOrThrow<TRelation>(), target); |
|
|
|
|
|
|
|
public TReturn Add<TRelation, TTarget>() => Add(World.LookupByTypeOrThrow<TRelation>(), World.LookupByTypeOrThrow<TTarget>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TReturn Remove(string symbol) => Remove(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
public TReturn Remove(string symbol) => Remove(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
public TReturn Remove<T>() => Remove(World.LookupByTypeOrThrow(typeof(T))); |
|
|
|
|
|
|
|
public TReturn Remove(Entity relation, Entity target) => Remove(Id.Pair(relation, target)); |
|
|
|
public TReturn Remove(Entity relation, Entity target) => Remove(Id.Pair(relation, target)); |
|
|
|
public TReturn Remove<TRelation>(Entity target) => Remove(World.LookupByTypeOrThrow<TRelation>(), target); |
|
|
|
|
|
|
|
public TReturn Remove<TRelation, TTarget>() => Remove(World.LookupByTypeOrThrow<TRelation>(), World.LookupByTypeOrThrow<TTarget>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool Has(string symbol) => Has(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
public bool Has(string symbol) => Has(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
public bool Has<T>() => Has(World.LookupByTypeOrThrow(typeof(T))); |
|
|
|
|
|
|
|
public bool Has(Entity relation, Entity target) => Has(Id.Pair(relation, target)); |
|
|
|
public bool Has(Entity relation, Entity target) => Has(Id.Pair(relation, target)); |
|
|
|
public bool Has<TRelation>(Entity target) => Has(World.LookupByTypeOrThrow<TRelation>(), target); |
|
|
|
|
|
|
|
public bool Has<TRelation, TTarget>() => Has(World.LookupByTypeOrThrow<TRelation>(), World.LookupByTypeOrThrow<TTarget>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract T? GetOrNull<T>(Id id) where T : unmanaged; |
|
|
|
public abstract T? GetOrNull<T>(Id id) where T : unmanaged; |
|
|
|
public abstract T? GetOrNull<T>(Id id, T _ = null!) where T : class; |
|
|
|
public abstract T? GetOrNull<T>(Id id, T _ = null!) where T : class; |
|
|
@ -37,24 +26,10 @@ public abstract class EntityBase<TReturn> |
|
|
|
public abstract ref T GetRefOrThrow<T>(Id id) where T : unmanaged; |
|
|
|
public abstract ref T GetRefOrThrow<T>(Id id) where T : unmanaged; |
|
|
|
public abstract void Modified<T>(Id id); |
|
|
|
public abstract void Modified<T>(Id id); |
|
|
|
|
|
|
|
|
|
|
|
public T? GetOrNull<T>() where T : unmanaged => GetOrNull<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
public T? GetOrNull<T>(T _ = null!) where T : class => GetOrNull<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
public T GetOrThrow<T>() => GetOrThrow<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
public ref T GetMut<T>() where T : unmanaged => ref GetMut<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
public ref T GetRefOrNull<T>() where T : unmanaged => ref GetRefOrNull<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
public ref T GetRefOrThrow<T>() where T : unmanaged => ref GetRefOrThrow<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
public void Modified<T>() => Modified<T>(World.LookupByTypeOrThrow<T>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract TReturn Set<T>(Id id, in T value) where T : unmanaged; |
|
|
|
public abstract TReturn Set<T>(Id id, in T value) where T : unmanaged; |
|
|
|
public abstract TReturn Set<T>(Id id, T obj) where T : class; |
|
|
|
public abstract TReturn Set<T>(Id id, T obj) where T : class; |
|
|
|
|
|
|
|
|
|
|
|
public TReturn Set<T>(in T value) where T : unmanaged => Set(World.LookupByTypeOrThrow<T>(), value); |
|
|
|
|
|
|
|
public TReturn Set<T>(T obj) where T : class => Set(World.LookupByTypeOrThrow<T>(), obj); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TReturn ChildOf(Entity parent) => Add(World.ChildOf, parent); |
|
|
|
public TReturn ChildOf(Entity parent) => Add(World.ChildOf, parent); |
|
|
|
public TReturn ChildOf<TParent>() => Add(World.ChildOf, World.LookupByTypeOrThrow<TParent>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TReturn Disable() => Add(World.Disabled); |
|
|
|
public TReturn Disable() => Add(World.Disabled); |
|
|
|
public TReturn Enable() => Remove(World.Disabled); |
|
|
|
public TReturn Enable() => Remove(World.Disabled); |
|
|
|