mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
rename EcsSystems to EcsPipeline
This commit is contained in:
parent
9b3379d060
commit
d355a409b0
@ -5,29 +5,29 @@ using UnityEngine;
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public class SystemsDebugSystem : IEcsPreInitSystem
|
||||
public class PipelineDebugSystem : IEcsPreInitSystem
|
||||
{
|
||||
private string _name;
|
||||
public SystemsDebugSystem(string name = "Systems")
|
||||
public PipelineDebugSystem(string name = "Systems")
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
void IEcsPreInitSystem.PreInit(EcsSystems systems)
|
||||
void IEcsPreInitSystem.PreInit(EcsPipeline pipeline)
|
||||
{
|
||||
SystemsDebugMonitor monitor = new GameObject(EcsConsts.DEBUG_PREFIX + _name).AddComponent<SystemsDebugMonitor>();
|
||||
monitor.source = this;
|
||||
monitor.systems = systems;
|
||||
monitor.systemsName = _name;
|
||||
monitor.pipeline = pipeline;
|
||||
monitor.pipelineName = _name;
|
||||
Object.DontDestroyOnLoad(monitor.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public class SystemsDebugMonitor : MonoBehaviour
|
||||
{
|
||||
internal SystemsDebugSystem source;
|
||||
internal EcsSystems systems;
|
||||
internal string systemsName;
|
||||
internal PipelineDebugSystem source;
|
||||
internal EcsPipeline pipeline;
|
||||
internal string pipelineName;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(SystemsDebugMonitor))]
|
||||
public class SystemsDebugMonitorEditor : Editor
|
||||
public class PipelineDebugMonitorEditor : Editor
|
||||
{
|
||||
private DebugColorAttribute _fakeDebugColorAttribute = new DebugColorAttribute(DebugColor.White);
|
||||
private Type _debugColorAttributeType = typeof(DebugColorAttribute);
|
||||
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS
|
||||
DebugMonitorPrefs.instance.IsShowHidden = EditorGUILayout.Toggle("Show Hidden", DebugMonitorPrefs.instance.IsShowHidden);
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
foreach (var item in Target.systems.AllSystems)
|
||||
foreach (var item in Target.pipeline.AllSystems)
|
||||
{
|
||||
DrawSystem(item);
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace DCFApixels.DragonECS
|
||||
GUILayout.Label("[Runners]", _headerStyle);
|
||||
|
||||
GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black));
|
||||
foreach (var item in Target.systems.AllRunners)
|
||||
foreach (var item in Target.pipeline.AllRunners)
|
||||
{
|
||||
DrawRunner(item.Value);
|
||||
}
|
@ -13,7 +13,7 @@ namespace DCFApixels.DragonECS
|
||||
_ecsWorld = ecsWorld;
|
||||
}
|
||||
|
||||
public void Run(EcsSystems systems)
|
||||
public void Run(EcsPipeline pipeline)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,22 @@
|
||||
{
|
||||
public interface IEcsFixedRunSystem : IEcsSystem
|
||||
{
|
||||
public void FixedRun(EcsSystems systems);
|
||||
public void FixedRun(EcsPipeline pipeline);
|
||||
}
|
||||
|
||||
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 void FixedRun(this EcsSystems systems)
|
||||
public static void FixedRun(this EcsPipeline pipeline)
|
||||
{
|
||||
systems.GetRunner<IEcsFixedRunSystem>().FixedRun(systems);
|
||||
pipeline.GetRunner<IEcsFixedRunSystem>().FixedRun(pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@
|
||||
{
|
||||
public interface IEcsLateRunSystem : IEcsSystem
|
||||
{
|
||||
public void LateRun(EcsSystems systems);
|
||||
public void LateRun(EcsPipeline systems);
|
||||
}
|
||||
|
||||
public class EcsLateRunSystemRunner : EcsRunner<IEcsLateRunSystem>, IEcsLateRunSystem
|
||||
{
|
||||
void IEcsLateRunSystem.LateRun(EcsSystems systems)
|
||||
void IEcsLateRunSystem.LateRun(EcsPipeline systems)
|
||||
{
|
||||
foreach (var item in targets) item.LateRun(systems);
|
||||
}
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
public static class IEcsLateRunSystemExtensions
|
||||
{
|
||||
public static void LateRun(this EcsSystems systems)
|
||||
public static void LateRun(this EcsPipeline systems)
|
||||
{
|
||||
systems.GetRunner<IEcsLateRunSystem>().LateRun(systems);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace #NAMESPACE#
|
||||
sealed class #SCRIPTNAME# : MonoBehaviour
|
||||
{
|
||||
private EcsWorld<DefaultWorld> _world;
|
||||
private EcsSystems _systems;
|
||||
private EcsPipeline _pipeline;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@ -14,7 +14,7 @@ namespace #NAMESPACE#
|
||||
UnityDebugService.Init();
|
||||
|
||||
_world = new EcsWorld<DefaultWorld>();
|
||||
_systems = EcsSystems.New()
|
||||
_pipeline = EcsPipeline.New()
|
||||
// register your systems here, for example:
|
||||
// .Add (new TestSystem1 ())
|
||||
// .Add (new TestSystem2 ())
|
||||
@ -26,34 +26,34 @@ namespace #NAMESPACE#
|
||||
// with Inject you can also inject other data, for example:
|
||||
//.Inject(new SharedData())
|
||||
#if UNITY_EDITOR
|
||||
// add debug systems for this EcsSystems here
|
||||
.Add(new SystemsDebugSystem())
|
||||
// add debug system for this EcsPipeline here
|
||||
.Add(new PipelineDebugSystem())
|
||||
#endif
|
||||
.BuildAndInit();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_systems?.Run();
|
||||
_pipeline?.Run();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
_systems?.LateRun();
|
||||
_pipeline?.LateRun();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
_systems?.FixedRun();
|
||||
_pipeline?.FixedRun();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// don't forget to clear data
|
||||
if (_systems != null)
|
||||
if (_pipeline != null)
|
||||
{
|
||||
_systems.Destroy();
|
||||
_systems = null;
|
||||
_pipeline.Destroy();
|
||||
_pipeline = null;
|
||||
}
|
||||
|
||||
if (_world != null)
|
||||
|
@ -10,9 +10,9 @@ namespace #NAMESPACE#
|
||||
private EcsWorld<DefaultWorld> _world;
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,34 +20,34 @@ namespace #NAMESPACE#
|
||||
private EcsWorld<DefaultWorld> _world;
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user