mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
Merge branch 'dev' into test-pool
This commit is contained in:
commit
5c013c77f0
@ -232,16 +232,17 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
this.colorCode = withoutAlpha ? colorCode | 255 : colorCode;
|
||||
}
|
||||
public MetaColor(string stringCode) : this()
|
||||
public static MetaColor FromHashCode(int hash)
|
||||
{
|
||||
return FromHashCode(hash, false);
|
||||
}
|
||||
public static MetaColor FromHashCode(int hash, bool withoutAlpha)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
const uint MAGIC_CONST = 0xA638_783E;
|
||||
uint colorCode = (uint)stringCode.GetHashCode();
|
||||
colorCode ^= MAGIC_CONST;
|
||||
uint colorCode = (uint)hash;
|
||||
colorCode = BitsUtility.NextXorShiftState(colorCode);
|
||||
this.colorCode = (uint)colorCode | 255;
|
||||
this.colorCode = UpContrast().colorCode;
|
||||
return new MetaColor(colorCode, withoutAlpha);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -6,8 +6,6 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using static MetaGroupAttribute;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class MetaGroupAttribute : EcsMetaAttribute
|
||||
{
|
||||
@ -22,6 +20,7 @@ namespace DCFApixels.DragonECS
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public class MetaGroup
|
||||
{
|
||||
public const char SEPARATOR = MetaGroupAttribute.SEPARATOR;
|
||||
public const string UNGROUPED = "<UNGROUPED>";
|
||||
private const string PATTERN = @"Module(?=/)";
|
||||
public static readonly MetaGroup Empty = new MetaGroup(UNGROUPED);
|
||||
@ -39,6 +38,10 @@ namespace DCFApixels.DragonECS
|
||||
return _path;
|
||||
}
|
||||
}
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return this == Empty; }
|
||||
}
|
||||
public MetaGroup(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
|
@ -153,7 +153,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
if (_initFlags.HasFlag(InitFlag.Color) == false)
|
||||
{
|
||||
(_color, _isCustomColor) = MetaGenerator.GetColor(_type);
|
||||
(_color, _isCustomColor) = MetaGenerator.GetColor(this);
|
||||
_initFlags |= InitFlag.Color;
|
||||
}
|
||||
}
|
||||
@ -406,15 +406,6 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
private const int GENERIC_NAME_DEPTH = 3;
|
||||
|
||||
//private static HashSet<Type> _;
|
||||
|
||||
//#region GetMemberType
|
||||
//public static EcsMemberType GetMemberType(Type type)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
#region GetMetaName/GetTypeName
|
||||
public static string GetTypeName(Type type)
|
||||
{
|
||||
@ -448,15 +439,25 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region GetColor
|
||||
private static MetaColor AutoColor(Type type)
|
||||
|
||||
private static MetaColor AutoColor(TypeMeta meta)
|
||||
{
|
||||
return new MetaColor(type.Name).UpContrast();//.Desaturate(0.48f) / 1.18f;
|
||||
int hash;
|
||||
if (meta.Group.IsEmpty)
|
||||
{
|
||||
hash = meta.Type.Name.GetHashCode();
|
||||
}
|
||||
public static (MetaColor, bool) GetColor(Type type)
|
||||
else
|
||||
{
|
||||
hash = meta.Group.Name.GetHashCode();
|
||||
}
|
||||
return MetaColor.FromHashCode(hash).UpContrast();
|
||||
}
|
||||
public static (MetaColor, bool) GetColor(TypeMeta meta)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
|
||||
bool isCustom = type.TryGetAttribute(out MetaColorAttribute atr);
|
||||
return (isCustom ? atr.color : AutoColor(type), isCustom);
|
||||
bool isCustom = meta.Type.TryGetAttribute(out MetaColorAttribute atr);
|
||||
return (isCustom ? atr.color : AutoColor(meta), isCustom);
|
||||
#else
|
||||
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetColor)} method does not work.");
|
||||
return (AutoColor(type), false);
|
||||
|
@ -225,13 +225,14 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
//Building
|
||||
TAspect newAspect = new TAspect();
|
||||
object newAspectObj = newAspect;
|
||||
EcsAspect builtinAspect = newAspect as EcsAspect;
|
||||
if (builtinAspect != null)
|
||||
{
|
||||
builtinAspect._source = world;
|
||||
builtinAspect.Init(builder);
|
||||
}
|
||||
OnInit(newAspect, builder);
|
||||
OnInit(newAspectObj, builder);
|
||||
|
||||
//Build Mask
|
||||
if (staticMask == null)
|
||||
@ -254,9 +255,9 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
_constructorBuildersStackIndex--;
|
||||
|
||||
OnAfterInit(newAspect, mask);
|
||||
OnAfterInit(newAspectObj, mask);
|
||||
|
||||
return (newAspect, mask);
|
||||
return ((TAspect)newAspectObj, mask);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -75,6 +75,8 @@ namespace DCFApixels.DragonECS
|
||||
EcsProcessRaw ProcessRaw { get; }
|
||||
bool IsEmpty { get; }
|
||||
}
|
||||
|
||||
//TODO инъекция в раннеры
|
||||
//TODO добавить функцию фильтрации систем по string, за счет создания отдельных ранеров для отдельных string
|
||||
[MetaColor(MetaColor.DragonRose)]
|
||||
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
|
||||
|
Loading…
Reference in New Issue
Block a user