mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
update metaID
This commit is contained in:
parent
d1a874e62e
commit
78b49e3f7b
@ -51,11 +51,11 @@ namespace DCFApixels.DragonECS
|
|||||||
//}
|
//}
|
||||||
public static bool IsGenericID(string id)
|
public static bool IsGenericID(string id)
|
||||||
{
|
{
|
||||||
return Regex.IsMatch(id, @"^[^,<>\s]*$");
|
return id[id.Length - 1] == '>' || Regex.IsMatch(id, @"^[^,<>\s]*$");
|
||||||
}
|
}
|
||||||
public static bool IsValidID(string input)
|
public static bool IsValidID(string id)
|
||||||
{
|
{
|
||||||
return input[input.Length - 1] == '>' || Regex.IsMatch(input, @"^[a-zA-Z0-9_]+$");
|
return Regex.IsMatch(id, @"^[a-zA-Z0-9_]+$");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
#region CollisionList
|
#region CollisionList
|
||||||
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
[DebuggerDisplay("HasAnyCollision: {IsHasAnyCollision} ListsCount: {ListsCount}")]
|
[DebuggerDisplay("HasAnyCollision: {IsHasAnyCollision} ListsCount: {Count}")]
|
||||||
public class CollisionList : IEnumerable<CollisionList.Collision>
|
public class CollisionList : IEnumerable<CollisionList.Collision>
|
||||||
{
|
{
|
||||||
private LinkedList[] _linkedLists;
|
private LinkedList[] _linkedLists;
|
||||||
@ -193,6 +193,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_listsCount = 0;
|
_listsCount = 0;
|
||||||
foreach (var meta in metas)
|
foreach (var meta in metas)
|
||||||
{
|
{
|
||||||
|
if (meta.IsHasMetaID() == false) { continue; }
|
||||||
if (listIndexes.TryGetValue(meta.MetaID, out int headIndex))
|
if (listIndexes.TryGetValue(meta.MetaID, out int headIndex))
|
||||||
{
|
{
|
||||||
hasCollision = true;
|
hasCollision = true;
|
||||||
@ -281,6 +282,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[DebuggerDisplay("Count: {Count}")]
|
[DebuggerDisplay("Count: {Count}")]
|
||||||
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public readonly struct Collision : IEnumerable<TypeMeta>
|
public readonly struct Collision : IEnumerable<TypeMeta>
|
||||||
{
|
{
|
||||||
private readonly CollisionList _collisions;
|
private readonly CollisionList _collisions;
|
||||||
@ -298,7 +300,7 @@ namespace DCFApixels.DragonECS
|
|||||||
internal Collision(CollisionList collisions, int head, int count)
|
internal Collision(CollisionList collisions, int head, int count)
|
||||||
{
|
{
|
||||||
_collisions = collisions;
|
_collisions = collisions;
|
||||||
if(count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
_head = 0;
|
_head = 0;
|
||||||
_metaID = string.Empty;
|
_metaID = string.Empty;
|
||||||
@ -346,8 +348,18 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
|
||||||
|
|
||||||
|
#region DebuggerProxy
|
||||||
|
private class DebuggerProxy
|
||||||
|
{
|
||||||
|
public Type[] Types;
|
||||||
|
public DebuggerProxy(Collision collision)
|
||||||
|
{
|
||||||
|
Types = collision.Select(o => o.Type).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
#region DebuggerProxy
|
#region DebuggerProxy
|
||||||
private class DebuggerProxy
|
private class DebuggerProxy
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ using DCFApixels.DragonECS.Internal;
|
|||||||
using DCFApixels.DragonECS.PoolsCore;
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
#if DEBUG || !REFLECTION_DISABLED
|
#if DEBUG || !REFLECTION_DISABLED
|
||||||
@ -275,6 +276,7 @@ namespace DCFApixels.DragonECS
|
|||||||
return _metaID;
|
return _metaID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool IsHasMetaID() { return string.IsNullOrEmpty(MetaID) == false; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TypeCode
|
#region TypeCode
|
||||||
@ -381,7 +383,17 @@ namespace DCFApixels.DragonECS
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
public static bool IsHasMeta(Type type)
|
public static bool TryGetCustomMeta(Type type, out TypeMeta meta)
|
||||||
|
{
|
||||||
|
if (IsHasCustomMeta(type))
|
||||||
|
{
|
||||||
|
meta = type.ToMeta();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
meta = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public static bool IsHasCustomMeta(Type type)
|
||||||
{
|
{
|
||||||
#if DEBUG || !REFLECTION_DISABLED
|
#if DEBUG || !REFLECTION_DISABLED
|
||||||
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(EcsMetaAttribute), false).Length > 0;
|
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(EcsMetaAttribute), false).Length > 0;
|
||||||
@ -393,7 +405,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static bool IsHasMetaID(Type type)
|
public static bool IsHasMetaID(Type type)
|
||||||
{
|
{
|
||||||
#if DEBUG || !REFLECTION_DISABLED
|
#if DEBUG || !REFLECTION_DISABLED
|
||||||
return type.HasAttribute<MetaIDAttribute>();
|
return TryGetCustomMeta(type, out TypeMeta meta) && meta.IsHasMetaID();
|
||||||
#else
|
#else
|
||||||
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMetaID)} method does not work.");
|
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMetaID)} method does not work.");
|
||||||
return false;
|
return false;
|
||||||
@ -449,6 +461,15 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Obsolete
|
||||||
|
[Obsolete("Use TryGetCustomMeta(type)")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public static bool IsHasMeta(Type type)
|
||||||
|
{
|
||||||
|
return IsHasCustomMeta(type);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region MetaGenerator
|
#region MetaGenerator
|
||||||
private static class MetaGenerator
|
private static class MetaGenerator
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user