mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
Update EcsTypeCodeManager.cs
This commit is contained in:
parent
a580adffa2
commit
aeb0977d74
@ -12,46 +12,6 @@ using Unity.IL2CPP.CompilerServices;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Internal
|
namespace DCFApixels.DragonECS.Internal
|
||||||
{
|
{
|
||||||
#if ENABLE_IL2CPP
|
|
||||||
[Il2CppSetOption(Option.NullChecks, false)]
|
|
||||||
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
||||||
#endif
|
|
||||||
[DebuggerDisplay("{" + nameof(GetDebuggerDisplay) + "(),nq}")]
|
|
||||||
internal readonly struct EcsTypeCodeKey : IEquatable<EcsTypeCodeKey>
|
|
||||||
{
|
|
||||||
public readonly Type Type;
|
|
||||||
public readonly string NameKey;
|
|
||||||
public EcsTypeCodeKey(Type type, string nameKey)
|
|
||||||
{
|
|
||||||
Type = type;
|
|
||||||
NameKey = nameKey;
|
|
||||||
}
|
|
||||||
public bool Equals(EcsTypeCodeKey other)
|
|
||||||
{
|
|
||||||
return Type == other.Type && NameKey == other.NameKey;
|
|
||||||
}
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return obj is EcsTypeCodeKey other && Equals(other);
|
|
||||||
}
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(Type, NameKey);
|
|
||||||
}
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(NameKey))
|
|
||||||
{
|
|
||||||
return Type.ToString();
|
|
||||||
}
|
|
||||||
return $"{Type} {NameKey}";
|
|
||||||
}
|
|
||||||
public static implicit operator EcsTypeCodeKey(Type type) { return new EcsTypeCodeKey(type, string.Empty); }
|
|
||||||
private string GetDebuggerDisplay()
|
|
||||||
{
|
|
||||||
return ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//TODO разработать возможность ручного устанавливания ID типам.
|
//TODO разработать возможность ручного устанавливания ID типам.
|
||||||
//это может быть полезно как детерминированность для сети
|
//это может быть полезно как детерминированность для сети
|
||||||
#if ENABLE_IL2CPP
|
#if ENABLE_IL2CPP
|
||||||
@ -83,7 +43,6 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static EcsTypeCode Get<T>() { return EcsTypeCodeCache<T>.code; }
|
public static EcsTypeCode Get<T>() { return EcsTypeCodeCache<T>.code; }
|
||||||
public static bool Has(Type type) { return _codes.ContainsKey(type); }
|
public static bool Has(Type type) { return _codes.ContainsKey(type); }
|
||||||
public static bool Has<T>() { return _codes.ContainsKey(typeof(T)); }
|
|
||||||
public static EcsTypeCodeKey FindTypeOfCode(EcsTypeCode typeCode)
|
public static EcsTypeCodeKey FindTypeOfCode(EcsTypeCode typeCode)
|
||||||
{
|
{
|
||||||
foreach (var item in _codes)
|
foreach (var item in _codes)
|
||||||
@ -123,4 +82,40 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
return this.AutoToString(false);
|
return this.AutoToString(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if ENABLE_IL2CPP
|
||||||
|
[Il2CppSetOption(Option.NullChecks, false)]
|
||||||
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
|
#endif
|
||||||
|
[DebuggerDisplay("{" + nameof(ToString) + "()}")]
|
||||||
|
internal readonly struct EcsTypeCodeKey : IEquatable<EcsTypeCodeKey>
|
||||||
|
{
|
||||||
|
public readonly Type Type;
|
||||||
|
public readonly string NameKey;
|
||||||
|
public EcsTypeCodeKey(Type type, string nameKey)
|
||||||
|
{
|
||||||
|
Type = type;
|
||||||
|
NameKey = nameKey;
|
||||||
|
}
|
||||||
|
public bool Equals(EcsTypeCodeKey other)
|
||||||
|
{
|
||||||
|
return Type == other.Type && NameKey == other.NameKey;
|
||||||
|
}
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return obj is EcsTypeCodeKey other && Equals(other);
|
||||||
|
}
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(Type, NameKey);
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(NameKey))
|
||||||
|
{
|
||||||
|
return Type.ToString();
|
||||||
|
}
|
||||||
|
return $"{Type} {NameKey}";
|
||||||
|
}
|
||||||
|
public static implicit operator EcsTypeCodeKey(Type type) { return new EcsTypeCodeKey(type, string.Empty); }
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user