mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
rename MetaGroup
This commit is contained in:
parent
394820549f
commit
e0a3d54979
@ -193,32 +193,32 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GetGroup
|
#region GetGroup
|
||||||
public static ReadonlyMetaGroup GetGroup(object obj)
|
public static MetaGroup GetGroup(object obj)
|
||||||
{
|
{
|
||||||
return GetTypeMeta(obj).Group;
|
return GetTypeMeta(obj).Group;
|
||||||
}
|
}
|
||||||
public static ReadonlyMetaGroup GetGroup<T>()
|
public static MetaGroup GetGroup<T>()
|
||||||
{
|
{
|
||||||
return GetTypeMeta<T>().Group;
|
return GetTypeMeta<T>().Group;
|
||||||
}
|
}
|
||||||
public static ReadonlyMetaGroup GetGroup(Type type)
|
public static MetaGroup GetGroup(Type type)
|
||||||
{
|
{
|
||||||
return GetTypeMeta(type).Group;
|
return GetTypeMeta(type).Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetGroup(object obj, out ReadonlyMetaGroup group)
|
public static bool TryGetGroup(object obj, out MetaGroup group)
|
||||||
{
|
{
|
||||||
TypeMeta meta = GetTypeMeta(obj);
|
TypeMeta meta = GetTypeMeta(obj);
|
||||||
group = meta.Group;
|
group = meta.Group;
|
||||||
return group.IsNull;
|
return group.IsNull;
|
||||||
}
|
}
|
||||||
public static bool TryGetGroup<T>(out ReadonlyMetaGroup group)
|
public static bool TryGetGroup<T>(out MetaGroup group)
|
||||||
{
|
{
|
||||||
TypeMeta meta = GetTypeMeta<T>();
|
TypeMeta meta = GetTypeMeta<T>();
|
||||||
group = meta.Group;
|
group = meta.Group;
|
||||||
return group.IsNull;
|
return group.IsNull;
|
||||||
}
|
}
|
||||||
public static bool TryGetGroup(Type type, out ReadonlyMetaGroup group)
|
public static bool TryGetGroup(Type type, out MetaGroup group)
|
||||||
{
|
{
|
||||||
TypeMeta meta = GetTypeMeta(type);
|
TypeMeta meta = GetTypeMeta(type);
|
||||||
group = meta.Group;
|
group = meta.Group;
|
||||||
@ -313,7 +313,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public MetaColor Color { get; }
|
public MetaColor Color { get; }
|
||||||
public string Description { get; }
|
public string Description { get; }
|
||||||
public ReadonlyMetaGroup Group { get; }
|
public MetaGroup Group { get; }
|
||||||
public IReadOnlyCollection<string> Tags { get; }
|
public IReadOnlyCollection<string> Tags { get; }
|
||||||
}
|
}
|
||||||
public sealed class TypeMeta : ITypeMeta
|
public sealed class TypeMeta : ITypeMeta
|
||||||
@ -327,7 +327,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private string _name;
|
private string _name;
|
||||||
private MetaColor _color;
|
private MetaColor _color;
|
||||||
private string _description;
|
private string _description;
|
||||||
private ReadonlyMetaGroup _group;
|
private MetaGroup _group;
|
||||||
private IReadOnlyCollection<string> _tags;
|
private IReadOnlyCollection<string> _tags;
|
||||||
private int _typeCode;
|
private int _typeCode;
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Group
|
#region Group
|
||||||
public ReadonlyMetaGroup Group
|
public MetaGroup Group
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -547,9 +547,9 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GetGroup
|
#region GetGroup
|
||||||
public static ReadonlyMetaGroup GetGroup(Type type)
|
public static MetaGroup GetGroup(Type type)
|
||||||
{
|
{
|
||||||
return type.TryGetCustomAttribute(out MetaGroupAttribute atr) ? atr.Data : ReadonlyMetaGroup.Empty;
|
return type.TryGetCustomAttribute(out MetaGroupAttribute atr) ? atr.Data : MetaGroup.Empty;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -6,15 +6,15 @@ namespace DCFApixels.DragonECS
|
|||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
||||||
public sealed class MetaGroupAttribute : EcsMetaAttribute
|
public sealed class MetaGroupAttribute : EcsMetaAttribute
|
||||||
{
|
{
|
||||||
public readonly MetaGroup Data;
|
public readonly MetaGroupRef Data;
|
||||||
public MetaGroupAttribute(string name)
|
public MetaGroupAttribute(string name)
|
||||||
{
|
{
|
||||||
Data = new MetaGroup(name);
|
Data = new MetaGroupRef(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class MetaGroup
|
public class MetaGroupRef
|
||||||
{
|
{
|
||||||
public static readonly MetaGroup Empty = new MetaGroup("");
|
public static readonly MetaGroupRef Empty = new MetaGroupRef("");
|
||||||
|
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
private string[] path = null;
|
private string[] path = null;
|
||||||
@ -29,7 +29,7 @@ namespace DCFApixels.DragonECS
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public MetaGroup(string name)
|
public MetaGroupRef(string name)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(name))
|
if (string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
@ -45,10 +45,10 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly struct ReadonlyMetaGroup
|
public readonly struct MetaGroup
|
||||||
{
|
{
|
||||||
public static readonly ReadonlyMetaGroup Empty = new ReadonlyMetaGroup(MetaGroup.Empty);
|
public static readonly MetaGroup Empty = new MetaGroup(MetaGroupRef.Empty);
|
||||||
private readonly MetaGroup _source;
|
private readonly MetaGroupRef _source;
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return _source.Name; }
|
get { return _source.Name; }
|
||||||
@ -61,14 +61,14 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
get { return _source == null; }
|
get { return _source == null; }
|
||||||
}
|
}
|
||||||
public ReadonlyMetaGroup(MetaGroup source)
|
public MetaGroup(MetaGroupRef source)
|
||||||
{
|
{
|
||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator ReadonlyMetaGroup(MetaGroup group)
|
public static implicit operator MetaGroup(MetaGroupRef group)
|
||||||
{
|
{
|
||||||
return new ReadonlyMetaGroup(group);
|
return new MetaGroup(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user