mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
Update WIP
This commit is contained in:
parent
36b696777b
commit
b97f409671
@ -10,6 +10,13 @@
|
|||||||
|
|
||||||
public class DestroyedTable : EcsTable
|
public class DestroyedTable : EcsTable
|
||||||
{
|
{
|
||||||
private EcsIncTag _destroyedTag;
|
public readonly EcsPool<tag> isDestroyed;
|
||||||
|
|
||||||
|
public static mem<tag> isDestroyedMem = "isDestroyed";
|
||||||
|
|
||||||
|
public DestroyedTable(ref TableBuilder builder) : base(ref builder)
|
||||||
|
{
|
||||||
|
isDestroyed = builder.Inc(isDestroyedMem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public static class MemberDeclarator
|
public static class MemberDeclarator
|
||||||
{
|
{
|
||||||
#if !DCFA_ECS_NO_SANITIZE_CHECKS
|
private static Dictionary<string, EcsMemberBase> _nameMembersPairs = new Dictionary<string, EcsMemberBase>(1024);
|
||||||
private static HashSet<string> _usedNames = new HashSet<string>(1024);
|
private static EcsMemberBase[] _members = new EcsMemberBase[1024];
|
||||||
#endif
|
|
||||||
private static EcsMemberBase[] _member = new EcsMemberBase[1024];
|
|
||||||
private static int _typesCount = 0;
|
private static int _typesCount = 0;
|
||||||
public static EcsMember<T> Declare<T>(string name)
|
public static EcsMember<T> Declare<T>(string name)
|
||||||
{
|
{
|
||||||
@ -22,33 +20,43 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
throw new EcsFrameworkException($"Maximum available members exceeded. The member of \"{name}\" was not declared");
|
throw new EcsFrameworkException($"Maximum available members exceeded. The member of \"{name}\" was not declared");
|
||||||
}
|
}
|
||||||
if (_usedNames.Contains(name))
|
if (_nameMembersPairs.ContainsKey(name))
|
||||||
{
|
{
|
||||||
throw new EcsFrameworkException($"The node with the name \"{name}\" has already been declared");
|
throw new EcsFrameworkException($"The node with the name \"{name}\" has already been declared");
|
||||||
}
|
}
|
||||||
_usedNames.Add(name);
|
|
||||||
#endif
|
#endif
|
||||||
if (_typesCount >= _member.Length)
|
if (_typesCount >= _members.Length)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _member, _member.Length << 1);
|
Array.Resize(ref _members, _members.Length << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
EcsMember<T> member = new EcsMember<T>(name, _typesCount);
|
EcsMember<T> member = new EcsMember<T>(name, _typesCount);
|
||||||
_member[_typesCount++] = member;
|
_nameMembersPairs.Add(name, member);
|
||||||
|
_members[_typesCount++] = member;
|
||||||
|
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EcsMember<T> GetOrDeclareMember<T>(string name)
|
||||||
|
{
|
||||||
|
if(_nameMembersPairs.TryGetValue(name,out EcsMemberBase memberBase))
|
||||||
|
{
|
||||||
|
return (EcsMember<T>)memberBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Declare<T>(name);
|
||||||
|
}
|
||||||
|
|
||||||
public static EcsMember<T> GetMemberInfo<T>(mem<T> member)
|
public static EcsMember<T> GetMemberInfo<T>(mem<T> member)
|
||||||
{
|
{
|
||||||
#if DEBUG && !DCFA_ECS_NO_SANITIZE_CHECKS
|
#if DEBUG && !DCFA_ECS_NO_SANITIZE_CHECKS
|
||||||
if (member.HasValue == false)
|
if (member.HasValue == false)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"The member argument is empty");
|
throw new ArgumentException($"The mem<{typeof(T).Name}> argument is empty");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return (EcsMember<T>)_member[member.UniqueID];
|
return (EcsMember<T>)_members[member.UniqueID];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using DCFApixels.DragonECS.Reflection;
|
using DCFApixels.DragonECS.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -74,5 +75,13 @@ namespace DCFApixels.DragonECS
|
|||||||
Add(index);
|
Add(index);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Equals/GetHashCode
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return base.Equals(obj);
|
||||||
|
}
|
||||||
|
public override int GetHashCode() => _type.GetHashCode();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
internal EcsFilter _filter;
|
internal EcsFilter _filter;
|
||||||
|
|
||||||
public EcsTable(ref TableBuilder tableBuilder) { }
|
public EcsTable(ref TableBuilder builder) { }
|
||||||
|
|
||||||
public EcsFilter Filter
|
public EcsFilter Filter
|
||||||
{
|
{
|
||||||
|
@ -77,13 +77,13 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal void OnEntityFieldAdd(int entityID, mem<T> chaangedField)
|
internal void OnEntityFieldAdd(int entityID, int changedPool)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void OnEntityFieldDel(int entityID, EcsMember chaangedField)
|
internal void OnEntityFieldDel(int entityID, int changedPool)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ namespace DCFApixels.DragonECS
|
|||||||
internal int IncludeCount;
|
internal int IncludeCount;
|
||||||
internal int ExcludeCount;
|
internal int ExcludeCount;
|
||||||
internal int Hash;
|
internal int Hash;
|
||||||
#if DEBUG && !LEOECSLITE_NO_SANITIZE_CHECKS
|
#if DEBUG && !DCFAECS_NO_SANITIZE_CHECKS
|
||||||
bool _built;
|
bool _built;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -115,16 +115,16 @@ namespace DCFApixels.DragonECS
|
|||||||
IncludeCount = 0;
|
IncludeCount = 0;
|
||||||
ExcludeCount = 0;
|
ExcludeCount = 0;
|
||||||
Hash = 0;
|
Hash = 0;
|
||||||
#if DEBUG && !LEOECSLITE_NO_SANITIZE_CHECKS
|
#if DEBUG && !DCFAECS_NO_SANITIZE_CHECKS
|
||||||
_built = false;
|
_built = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Mask Inc<T>(EcsMember member) where T : struct
|
public Mask Inc<T>(mem<T> member) where T : struct
|
||||||
{
|
{
|
||||||
var poolId = _world.GetPool<T>().GetId();
|
var poolId = _world.GetPool(member).ID;
|
||||||
#if DEBUG && !LEOECSLITE_NO_SANITIZE_CHECKS
|
#if DEBUG && !DCFAECS_NO_SANITIZE_CHECKS
|
||||||
if (_built) { throw new Exception("Cant change built mask."); }
|
if (_built) { throw new Exception("Cant change built mask."); }
|
||||||
if (Array.IndexOf(Include, poolId, 0, IncludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
if (Array.IndexOf(Include, poolId, 0, IncludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
||||||
if (Array.IndexOf(Exclude, poolId, 0, ExcludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
if (Array.IndexOf(Exclude, poolId, 0, ExcludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
||||||
@ -134,14 +134,11 @@ namespace DCFApixels.DragonECS
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
|
||||||
[UnityEngine.Scripting.Preserve]
|
|
||||||
#endif
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Mask Exc<T>(EcsMember member) where T : struct
|
public Mask Exc<T>(mem<T> member) where T : struct
|
||||||
{
|
{
|
||||||
var poolId = _world.GetPool<T>().GetId();
|
var poolId = _world.GetPool(member).ID;
|
||||||
#if DEBUG && !LEOECSLITE_NO_SANITIZE_CHECKS
|
#if DEBUG && !DCFAECS_NO_SANITIZE_CHECKS
|
||||||
if (_built) { throw new Exception("Cant change built mask."); }
|
if (_built) { throw new Exception("Cant change built mask."); }
|
||||||
if (Array.IndexOf(Include, poolId, 0, IncludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
if (Array.IndexOf(Include, poolId, 0, IncludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
||||||
if (Array.IndexOf(Exclude, poolId, 0, ExcludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
if (Array.IndexOf(Exclude, poolId, 0, ExcludeCount) != -1) { throw new Exception($"{typeof(T).Name} already in constraints list."); }
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
Мервтый мир - значение byte 255, зарезервированный адишник мира, все что ссылается на мертвый мир считается так же мертвым.
|
Мервтый мир - значение byte 255, зарезервированный адишник мира, все что ссылается на мертвый мир считается так же мертвым.
|
||||||
|
|
||||||
|
DCFAECS_NO_SANITIZE_CHECKS - отвключение дополнительных проверок
|
@ -56,7 +56,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static bool operator !=(in mem<T> left, in mem<T> right) => !left.Equals(right);
|
public static bool operator !=(in mem<T> left, in mem<T> right) => !left.Equals(right);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static implicit operator mem<T>(string name) => new mem<T>(MemberDeclarator.Declare<T>(name).UniqueID);
|
public static implicit operator mem<T>(string name) => new mem<T>(MemberDeclarator.GetOrDeclareMember<T>(name).UniqueID);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,15 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public EcsPool<T> Cache<T>(mem<T> member)
|
public EcsPool<T> Cache<T>(mem<T> member)
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
public EcsPool<T> Inc<T>(mem<T> member)
|
public EcsPool<T> Inc<T>(mem<T> member)
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
public EcsPool<T> Exc<T>(mem<T> member)
|
public EcsPool<T> Exc<T>(mem<T> member)
|
||||||
{
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user