DragonECS-AutoInjections/src/Attributes/AspectAttributes.cs

46 lines
1.9 KiB
C#
Raw Normal View History

2024-04-30 16:12:34 +08:00
using DCFApixels.DragonECS.PoolsCore;
using System;
2023-05-07 00:50:23 +08:00
using System.Linq;
2023-04-21 17:39:06 +08:00
namespace DCFApixels.DragonECS
{
public abstract class InjectAspectMemberAttribute : Attribute { }
2023-04-21 17:39:06 +08:00
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class IncAttribute : InjectAspectMemberAttribute { }
2023-04-21 17:39:06 +08:00
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class ExcAttribute : InjectAspectMemberAttribute { }
2023-04-24 16:48:46 +08:00
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class OptAttribute : InjectAspectMemberAttribute { }
2023-06-05 23:45:25 +08:00
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class CombineAttribute : InjectAspectMemberAttribute
2023-06-05 23:45:25 +08:00
{
2025-03-13 13:38:58 +08:00
public readonly int Order = 0;
public CombineAttribute(int order = 0) { Order = order; }
2023-06-05 23:45:25 +08:00
}
2025-03-13 13:38:58 +08:00
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public sealed class MaskAttribute : InjectAspectMemberAttribute { }
2023-05-07 00:50:23 +08:00
2025-03-13 13:38:58 +08:00
public abstract class ImplicitInjectAttribute : Attribute
2023-05-07 00:50:23 +08:00
{
2025-03-13 13:38:58 +08:00
public readonly Type Type;
public readonly bool IsPool;
public ImplicitInjectAttribute(Type type)
2023-05-07 00:50:23 +08:00
{
2025-03-13 13:38:58 +08:00
Type = type;
IsPool = type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation));
2023-05-07 00:50:23 +08:00
}
}
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
2025-03-13 13:38:58 +08:00
public sealed class IncImplicitAttribute : ImplicitInjectAttribute
{
public IncImplicitAttribute(Type type) : base(type) { }
}
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
2023-05-07 00:50:23 +08:00
public sealed class ExcImplicitAttribute : ImplicitInjectAttribute
{
2025-03-13 13:38:58 +08:00
public ExcImplicitAttribute(Type type) : base(type) { }
2023-05-07 00:50:23 +08:00
}
2023-04-21 17:39:06 +08:00
}