2024-03-11 05:59:57 +08:00
|
|
|
|
using DCFApixels.DragonECS.Unity.Internal;
|
|
|
|
|
using System;
|
2024-03-03 03:51:49 +08:00
|
|
|
|
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
|
2024-04-22 17:20:10 +08:00
|
|
|
|
public void Apply(short worldID, int entityID)
|
2024-03-03 03:51:49 +08:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|