2024-05-16 19:03:03 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
|
|
|
|
[Serializable]
|
|
|
|
|
public struct ComponentTemplateProperty : IEquatable<ComponentTemplateProperty>
|
|
|
|
|
{
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[SerializeReference]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
private IComponentTemplate _template;
|
2024-05-16 19:59:57 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public ComponentTemplateProperty(IComponentTemplate template)
|
|
|
|
|
{
|
|
|
|
|
_template = template;
|
|
|
|
|
}
|
|
|
|
|
public IComponentTemplate Template
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _template; }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
set { _template = value; }
|
|
|
|
|
}
|
|
|
|
|
public Type Type
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _template.Type; }
|
|
|
|
|
}
|
|
|
|
|
public bool IsNull
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get { return _template == null; }
|
|
|
|
|
}
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public void Apply(short worldID, int entityID) { _template.Apply(worldID, entityID); }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public object GetRaw() { return _template.GetRaw(); }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public void OnGizmos(Transform transform, IComponentTemplate.GizmosMode mode) { _template.OnGizmos(transform, mode); }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public void OnValidate(UnityEngine.Object obj) { _template.OnValidate(obj); }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public void SetRaw(object raw) { _template.SetRaw(raw); }
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public bool Equals(ComponentTemplateProperty other) { return _template == other._template; }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public override int GetHashCode() { return _template.GetHashCode(); }
|
|
|
|
|
public override bool Equals(object obj) { return obj is ComponentTemplateProperty other && Equals(other); }
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public static bool operator ==(ComponentTemplateProperty a, ComponentTemplateProperty b) { return a._template == b._template; }
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public static bool operator !=(ComponentTemplateProperty a, ComponentTemplateProperty b) { return a._template != b._template; }
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public static bool operator ==(ComponentTemplateProperty a, Null? b) { return a.IsNull; }
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public static bool operator ==(Null? a, ComponentTemplateProperty b) { return b.IsNull; }
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public static bool operator !=(ComponentTemplateProperty a, Null? b) { return !a.IsNull; }
|
2024-05-16 20:31:06 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-05-16 19:03:03 +08:00
|
|
|
|
public static bool operator !=(Null? a, ComponentTemplateProperty b) { return !b.IsNull; }
|
|
|
|
|
public readonly struct Null { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed class ComponentTemplateReferenceAttribute : PropertyAttribute { }
|
|
|
|
|
}
|