mirror of
https://github.com/DCFApixels/DragonECS-AutoInjections.git
synced 2025-09-17 20:34:34 +08:00
45 lines
1.8 KiB
C#
45 lines
1.8 KiB
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace DCFApixels.DragonECS
|
|
{
|
|
public abstract class InjectAttribute : Attribute { }
|
|
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
|
|
public sealed class IncAttribute : InjectAttribute { }
|
|
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
|
|
public sealed class ExcAttribute : InjectAttribute { }
|
|
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
|
|
public sealed class OptAttribute : InjectAttribute { }
|
|
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
|
|
public sealed class CombineAttribute : InjectAttribute
|
|
{
|
|
public readonly int order = 0;
|
|
public CombineAttribute(int order = 0) => this.order = order;
|
|
}
|
|
|
|
public abstract class ImplicitInjectAttribute : Attribute { }
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
|
public sealed class IncImplicitAttribute : ImplicitInjectAttribute
|
|
{
|
|
public readonly Type type;
|
|
public readonly bool isPool;
|
|
public IncImplicitAttribute(Type type)
|
|
{
|
|
this.type = type;
|
|
isPool = type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation));
|
|
}
|
|
}
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
|
public sealed class ExcImplicitAttribute : ImplicitInjectAttribute
|
|
{
|
|
public readonly Type type;
|
|
public readonly bool isPool;
|
|
public ExcImplicitAttribute(Type type)
|
|
{
|
|
this.type = type;
|
|
isPool = type.GetInterfaces().Any(o => o == typeof(IEcsPoolImplementation));
|
|
}
|
|
}
|
|
}
|
|
|