You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.1 KiB
53 lines
2.1 KiB
using System; |
|
using static gaemstone.Flecs.Core; |
|
|
|
namespace gaemstone.ECS; |
|
|
|
/// <summary> |
|
/// Entities marked with this attribute are automatically registered with a |
|
/// <see cref="EntityRef.Symbol"/> specified in the attribute constructor, |
|
/// defaulting to their <see cref="EntityRef.Name"/> if not given. |
|
/// |
|
/// Symbols are unique string identifiers used to look up their entities. |
|
/// </summary> |
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
|
| AttributeTargets.Enum | AttributeTargets.Method)] |
|
public class SymbolAttribute : Attribute |
|
{ |
|
public string? Value { get; } |
|
public SymbolAttribute() { } |
|
public SymbolAttribute(string value) => Value = value; |
|
} |
|
|
|
|
|
// TODO: Should this be renamed from [Add<...>] to something else? |
|
/// <summary> |
|
/// Marked entity automatically has the specified entity added to it when |
|
/// automatically registered. Equivalent to <see cref="EntityBuilder.Add{T}"/>. |
|
/// </summary> |
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
|
| AttributeTargets.Enum | AttributeTargets.Method, |
|
AllowMultiple = true)] |
|
public class AddAttribute<TEntity> : Attribute { } |
|
|
|
/// <summary> |
|
/// Marked entity automatically has the specified relationship pair added to it when |
|
/// automatically registered. Equivalent to <see cref="EntityBuilder.Add{TRelation, TTarget}"/>. |
|
/// </summary> |
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
|
| AttributeTargets.Enum | AttributeTargets.Method, |
|
AllowMultiple = true)] |
|
public class AddAttribute<TRelation, TTarget> : Attribute { } |
|
|
|
|
|
/// <seealso cref="IsA"/> |
|
public class IsAAttribute<TTarget> : AddAttribute<IsA, TTarget> { } |
|
/// <seealso cref="ChildOf"/> |
|
public class ChildOfAttribute<TTarget> : AddAttribute<ChildOf, TTarget> { } |
|
/// <seealso cref="DependsOn"/> |
|
public class DependsOnAttribute<TTarget> : AddAttribute<DependsOn, TTarget> { } |
|
|
|
/// <seealso cref="Exclusive"/> |
|
public class ExclusiveAttribute : AddAttribute<Exclusive> { } |
|
/// <seealso cref="With"/> |
|
public class WithAttribute<TTarget> : AddAttribute<With, TTarget> { }
|
|
|