mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 18:14:35 +08:00
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
![]() |
using System;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace DCFApixels.DragonECS
|
|||
|
{
|
|||
|
[CreateAssetMenu(fileName = nameof(ScriptableEntityTemplate), menuName = EcsConsts.FRAMEWORK_NAME + "/" + nameof(ScriptableEntityTemplate), order = 1)]
|
|||
|
public class ScriptableEntityTemplate : ScriptableObject, 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(this);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|