mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-19 10:34:35 +08:00
66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
![]() |
using System;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace DCFApixels.DragonECS
|
|||
|
{
|
|||
|
public class MonoEntityTemplate : MonoBehaviour, ITemplateInternal
|
|||
|
{
|
|||
|
[SerializeReference]
|
|||
|
private IComponentTemplate[] _components;
|
|||
|
//[SerializeField]
|
|||
|
//private EntityTemplateInheritanceMatrix _inheritanceMatrix;
|
|||
|
|
|||
|
#region Properties
|
|||
|
string ITemplateInternal.ComponentsPropertyName
|
|||
|
{
|
|||
|
get { return nameof(_components); }
|
|||
|
}
|
|||
|
//EntityTemplateInheritanceMatrix ITemplateInternal.InheritanceMatrix
|
|||
|
//{
|
|||
|
// get { return _inheritanceMatrix; }
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Methods
|
|||
|
public void Apply(int worldID, int entityID)
|
|||
|
{
|
|||
|
foreach (var item in _components)
|
|||
|
{
|
|||
|
item.Apply(worldID, entityID);
|
|||
|
}
|
|||
|
}
|
|||
|
public void Clear()
|
|||
|
{
|
|||
|
_components = Array.Empty<IComponentTemplate>();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region UnityEvents
|
|||
|
private void OnValidate()
|
|||
|
{
|
|||
|
if (_components == null) { return; }
|
|||
|
foreach (var item in _components)
|
|||
|
{
|
|||
|
item.OnValidate(gameObject);
|
|||
|
}
|
|||
|
}
|
|||
|
private void OnDrawGizmos()
|
|||
|
{
|
|||
|
if (_components == null) { return; }
|
|||
|
foreach (var item in _components)
|
|||
|
{
|
|||
|
item.OnGizmos(transform, IComponentTemplate.GizmosMode.Always);
|
|||
|
}
|
|||
|
}
|
|||
|
private void OnDrawGizmosSelected()
|
|||
|
{
|
|||
|
if (_components == null) { return; }
|
|||
|
foreach (var item in _components)
|
|||
|
{
|
|||
|
item.OnGizmos(transform, IComponentTemplate.GizmosMode.Selected);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|