mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
28 lines
819 B
C#
28 lines
819 B
C#
![]() |
using DCFApixels.DragonECS.Internal;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace DCFApixels.DragonECS
|
|||
|
{
|
|||
|
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
|||
|
public sealed class MetaIDAttribute : EcsMetaAttribute
|
|||
|
{
|
|||
|
private static HashSet<string> _ids;
|
|||
|
|
|||
|
public readonly string ID;
|
|||
|
public MetaIDAttribute(string id)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(id))
|
|||
|
{
|
|||
|
Throw.ArgumentNull(nameof(id));
|
|||
|
}
|
|||
|
if (_ids.Add(id))
|
|||
|
{
|
|||
|
//TODO перевести ексепшен
|
|||
|
Throw.ArgumentException($"Дублирование MetaID: {ID}");
|
|||
|
}
|
|||
|
ID = id;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|