rename EcsSystems to EcsPipeline

This commit is contained in:
Mikhail 2023-03-30 05:33:35 +08:00
parent 9b3379d060
commit d355a409b0
8 changed files with 44 additions and 44 deletions

View File

@ -5,29 +5,29 @@ using UnityEngine;
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
[DebugHide, DebugColor(DebugColor.Gray)] [DebugHide, DebugColor(DebugColor.Gray)]
public class SystemsDebugSystem : IEcsPreInitSystem public class PipelineDebugSystem : IEcsPreInitSystem
{ {
private string _name; private string _name;
public SystemsDebugSystem(string name = "Systems") public PipelineDebugSystem(string name = "Systems")
{ {
_name = name; _name = name;
} }
void IEcsPreInitSystem.PreInit(EcsSystems systems) void IEcsPreInitSystem.PreInit(EcsPipeline pipeline)
{ {
SystemsDebugMonitor monitor = new GameObject(EcsConsts.DEBUG_PREFIX + _name).AddComponent<SystemsDebugMonitor>(); SystemsDebugMonitor monitor = new GameObject(EcsConsts.DEBUG_PREFIX + _name).AddComponent<SystemsDebugMonitor>();
monitor.source = this; monitor.source = this;
monitor.systems = systems; monitor.pipeline = pipeline;
monitor.systemsName = _name; monitor.pipelineName = _name;
Object.DontDestroyOnLoad(monitor.gameObject); Object.DontDestroyOnLoad(monitor.gameObject);
} }
} }
public class SystemsDebugMonitor : MonoBehaviour public class SystemsDebugMonitor : MonoBehaviour
{ {
internal SystemsDebugSystem source; internal PipelineDebugSystem source;
internal EcsSystems systems; internal EcsPipeline pipeline;
internal string systemsName; internal string pipelineName;
} }
#if UNITY_EDITOR #if UNITY_EDITOR
@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS
using UnityEditor; using UnityEditor;
[CustomEditor(typeof(SystemsDebugMonitor))] [CustomEditor(typeof(SystemsDebugMonitor))]
public class SystemsDebugMonitorEditor : Editor public class PipelineDebugMonitorEditor : Editor
{ {
private DebugColorAttribute _fakeDebugColorAttribute = new DebugColorAttribute(DebugColor.White); private DebugColorAttribute _fakeDebugColorAttribute = new DebugColorAttribute(DebugColor.White);
private Type _debugColorAttributeType = typeof(DebugColorAttribute); private Type _debugColorAttributeType = typeof(DebugColorAttribute);
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS
DebugMonitorPrefs.instance.IsShowHidden = EditorGUILayout.Toggle("Show Hidden", DebugMonitorPrefs.instance.IsShowHidden); DebugMonitorPrefs.instance.IsShowHidden = EditorGUILayout.Toggle("Show Hidden", DebugMonitorPrefs.instance.IsShowHidden);
GUILayout.BeginVertical(); GUILayout.BeginVertical();
foreach (var item in Target.systems.AllSystems) foreach (var item in Target.pipeline.AllSystems)
{ {
DrawSystem(item); DrawSystem(item);
} }
@ -77,7 +77,7 @@ namespace DCFApixels.DragonECS
GUILayout.Label("[Runners]", _headerStyle); GUILayout.Label("[Runners]", _headerStyle);
GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black)); GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black));
foreach (var item in Target.systems.AllRunners) foreach (var item in Target.pipeline.AllRunners)
{ {
DrawRunner(item.Value); DrawRunner(item.Value);
} }

View File

@ -13,7 +13,7 @@ namespace DCFApixels.DragonECS
_ecsWorld = ecsWorld; _ecsWorld = ecsWorld;
} }
public void Run(EcsSystems systems) public void Run(EcsPipeline pipeline)
{ {
} }
} }

View File

@ -2,22 +2,22 @@
{ {
public interface IEcsFixedRunSystem : IEcsSystem public interface IEcsFixedRunSystem : IEcsSystem
{ {
public void FixedRun(EcsSystems systems); public void FixedRun(EcsPipeline pipeline);
} }
public class EcsFixedRunSystemRunner : EcsRunner<IEcsFixedRunSystem>, IEcsFixedRunSystem public class EcsFixedRunSystemRunner : EcsRunner<IEcsFixedRunSystem>, IEcsFixedRunSystem
{ {
void IEcsFixedRunSystem.FixedRun(EcsSystems systems) void IEcsFixedRunSystem.FixedRun(EcsPipeline pipeline)
{ {
foreach (var item in targets) item.FixedRun(systems); foreach (var item in targets) item.FixedRun(pipeline);
} }
} }
public static class IEcsFixedRunSystemExtensions public static class IEcsFixedRunSystemExtensions
{ {
public static void FixedRun(this EcsSystems systems) public static void FixedRun(this EcsPipeline pipeline)
{ {
systems.GetRunner<IEcsFixedRunSystem>().FixedRun(systems); pipeline.GetRunner<IEcsFixedRunSystem>().FixedRun(pipeline);
} }
} }
} }

View File

@ -2,12 +2,12 @@
{ {
public interface IEcsLateRunSystem : IEcsSystem public interface IEcsLateRunSystem : IEcsSystem
{ {
public void LateRun(EcsSystems systems); public void LateRun(EcsPipeline systems);
} }
public class EcsLateRunSystemRunner : EcsRunner<IEcsLateRunSystem>, IEcsLateRunSystem public class EcsLateRunSystemRunner : EcsRunner<IEcsLateRunSystem>, IEcsLateRunSystem
{ {
void IEcsLateRunSystem.LateRun(EcsSystems systems) void IEcsLateRunSystem.LateRun(EcsPipeline systems)
{ {
foreach (var item in targets) item.LateRun(systems); foreach (var item in targets) item.LateRun(systems);
} }
@ -15,7 +15,7 @@
public static class IEcsLateRunSystemExtensions public static class IEcsLateRunSystemExtensions
{ {
public static void LateRun(this EcsSystems systems) public static void LateRun(this EcsPipeline systems)
{ {
systems.GetRunner<IEcsLateRunSystem>().LateRun(systems); systems.GetRunner<IEcsLateRunSystem>().LateRun(systems);
} }

View File

@ -6,7 +6,7 @@ namespace #NAMESPACE#
sealed class #SCRIPTNAME# : MonoBehaviour sealed class #SCRIPTNAME# : MonoBehaviour
{ {
private EcsWorld<DefaultWorld> _world; private EcsWorld<DefaultWorld> _world;
private EcsSystems _systems; private EcsPipeline _pipeline;
private void Start() private void Start()
{ {
@ -14,7 +14,7 @@ namespace #NAMESPACE#
UnityDebugService.Init(); UnityDebugService.Init();
_world = new EcsWorld<DefaultWorld>(); _world = new EcsWorld<DefaultWorld>();
_systems = EcsSystems.New() _pipeline = EcsPipeline.New()
// register your systems here, for example: // register your systems here, for example:
// .Add (new TestSystem1 ()) // .Add (new TestSystem1 ())
// .Add (new TestSystem2 ()) // .Add (new TestSystem2 ())
@ -26,34 +26,34 @@ namespace #NAMESPACE#
// with Inject you can also inject other data, for example: // with Inject you can also inject other data, for example:
//.Inject(new SharedData()) //.Inject(new SharedData())
#if UNITY_EDITOR #if UNITY_EDITOR
// add debug systems for this EcsSystems here // add debug system for this EcsPipeline here
.Add(new SystemsDebugSystem()) .Add(new PipelineDebugSystem())
#endif #endif
.BuildAndInit(); .BuildAndInit();
} }
private void Update() private void Update()
{ {
_systems?.Run(); _pipeline?.Run();
} }
private void LateUpdate() private void LateUpdate()
{ {
_systems?.LateRun(); _pipeline?.LateRun();
} }
private void FixedUpdate() private void FixedUpdate()
{ {
_systems?.FixedRun(); _pipeline?.FixedRun();
} }
private void OnDestroy() private void OnDestroy()
{ {
// don't forget to clear data // don't forget to clear data
if (_systems != null) if (_pipeline != null)
{ {
_systems.Destroy(); _pipeline.Destroy();
_systems = null; _pipeline = null;
} }
if (_world != null) if (_world != null)

View File

@ -10,9 +10,9 @@ namespace #NAMESPACE#
private EcsWorld<DefaultWorld> _world; private EcsWorld<DefaultWorld> _world;
public void Inject(EcsWorld<DefaultWorld> obj) => _world = obj; public void Inject(EcsWorld<DefaultWorld> obj) => _world = obj;
public void Run(EcsSystems systems) public void Run(EcsPipeline pipeline)
{ {
// will be called on each EcsSystems.Run() call // will be called on each EcsPipeline.Run() call
} }
} }
} }

View File

@ -20,34 +20,34 @@ namespace #NAMESPACE#
private EcsWorld<DefaultWorld> _world; private EcsWorld<DefaultWorld> _world;
public void Inject(EcsWorld<DefaultWorld> obj) => _world = obj; public void Inject(EcsWorld<DefaultWorld> obj) => _world = obj;
public void PreInit(EcsSystems systems) public void PreInit(EcsPipeline pipeline)
{ {
// will be called once during EcsSystems.Init() call and before Init(EcsSystems systems). // will be called once during EcsPipeline.Init() call and before Init(EcsPipeline pipeline).
} }
public void Init(EcsSystems systems) public void Init(EcsPipeline pipeline)
{ {
// will be called once during EcsSystems.Init() call and after PreInit(EcsSystems systems). // will be called once during EcsPipeline.Init() call and after PreInit(EcsPipeline pipeline).
} }
public void Run(EcsSystems systems) public void Run(EcsPipeline pipeline)
{ {
// will be called on each EcsSystems.Run() call // will be called on each EcsPipeline.Run() call
} }
public void LateRun(EcsSystems systems) public void LateRun(EcsPipeline pipeline)
{ {
// will be called on each EcsSystems.LateRun() call // will be called on each EcsPipeline.LateRun() call
} }
public void FixedRun(EcsSystems systems) public void FixedRun(EcsPipeline pipeline)
{ {
// will be called on each EcsSystems.FixedRun() call // will be called on each EcsPipeline.FixedRun() call
} }
public void Destroy(EcsSystems systems) public void Destroy(EcsPipeline pipeline)
{ {
// will be called once during EcsSystems.Destroy() call // will be called once during EcsPipeline.Destroy() call
} }
//Use Runners to implement additional messages //Use Runners to implement additional messages