mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-13 09:05:54 +08:00
refactoring
This commit is contained in:
parent
aa220f17e6
commit
65861cb798
@ -18,7 +18,6 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public void Destroy(EcsPipeline pipeline);
|
public void Destroy(EcsPipeline pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IEcsBaseSystem : IEcsInitSystem, IEcsRunSystem, IEcsDestroySystem { }
|
public interface IEcsBaseSystem : IEcsInitSystem, IEcsRunSystem, IEcsDestroySystem { }
|
||||||
|
|
||||||
namespace Internal
|
namespace Internal
|
||||||
@ -32,10 +31,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public void PreInit(EcsPipeline pipeline)
|
public void PreInit(EcsPipeline pipeline)
|
||||||
{
|
{
|
||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
for (int i = 0; i < Targets.Length && Targets.Length <= _markers.Length; i++)
|
||||||
{
|
{
|
||||||
using (_markers[i].Auto())
|
using (_markers[i].Auto())
|
||||||
targets[i].PreInit(pipeline);
|
Targets[i].PreInit(pipeline);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
foreach (var item in targets) item.PreInit(pipeline);
|
foreach (var item in targets) item.PreInit(pipeline);
|
||||||
@ -45,10 +44,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
protected override void OnSetup()
|
protected override void OnSetup()
|
||||||
{
|
{
|
||||||
_markers = new EcsProfilerMarker[targets.Length];
|
_markers = new EcsProfilerMarker[Targets.Length];
|
||||||
for (int i = 0; i < targets.Length; i++)
|
for (int i = 0; i < Targets.Length; i++)
|
||||||
{
|
{
|
||||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}"));
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{Targets[i].GetType().Name}.{nameof(PreInit)}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -62,10 +61,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public void Init(EcsPipeline pipeline)
|
public void Init(EcsPipeline pipeline)
|
||||||
{
|
{
|
||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
for (int i = 0; i < Targets.Length && Targets.Length <= _markers.Length; i++)
|
||||||
{
|
{
|
||||||
using (_markers[i].Auto())
|
using (_markers[i].Auto())
|
||||||
targets[i].Init(pipeline);
|
Targets[i].Init(pipeline);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
foreach (var item in targets) item.Init(pipeline);
|
foreach (var item in targets) item.Init(pipeline);
|
||||||
@ -75,10 +74,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
protected override void OnSetup()
|
protected override void OnSetup()
|
||||||
{
|
{
|
||||||
_markers = new EcsProfilerMarker[targets.Length];
|
_markers = new EcsProfilerMarker[Targets.Length];
|
||||||
for (int i = 0; i < targets.Length; i++)
|
for (int i = 0; i < Targets.Length; i++)
|
||||||
{
|
{
|
||||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}"));
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{Targets[i].GetType().Name}.{nameof(Init)}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -92,10 +91,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public void Run(EcsPipeline pipeline)
|
public void Run(EcsPipeline pipeline)
|
||||||
{
|
{
|
||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
for (int i = 0; i < Targets.Length && Targets.Length <= _markers.Length; i++)
|
||||||
{
|
{
|
||||||
using (_markers[i].Auto())
|
using (_markers[i].Auto())
|
||||||
targets[i].Run(pipeline);
|
Targets[i].Run(pipeline);
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -106,10 +105,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
protected override void OnSetup()
|
protected override void OnSetup()
|
||||||
{
|
{
|
||||||
_markers = new EcsProfilerMarker[targets.Length];
|
_markers = new EcsProfilerMarker[Targets.Length];
|
||||||
for (int i = 0; i < targets.Length; i++)
|
for (int i = 0; i < Targets.Length; i++)
|
||||||
{
|
{
|
||||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}"));
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{Targets[i].GetType().Name}.{nameof(Run)}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -123,10 +122,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public void Destroy(EcsPipeline pipeline)
|
public void Destroy(EcsPipeline pipeline)
|
||||||
{
|
{
|
||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
for (int i = 0; i < Targets.Length && Targets.Length <= _markers.Length; i++)
|
||||||
{
|
{
|
||||||
using (_markers[i].Auto())
|
using (_markers[i].Auto())
|
||||||
targets[i].Destroy(pipeline);
|
Targets[i].Destroy(pipeline);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
foreach (var item in targets) item.Destroy(pipeline);
|
foreach (var item in targets) item.Destroy(pipeline);
|
||||||
@ -136,10 +135,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#if DEBUG && !DISABLE_DEBUG
|
#if DEBUG && !DISABLE_DEBUG
|
||||||
protected override void OnSetup()
|
protected override void OnSetup()
|
||||||
{
|
{
|
||||||
_markers = new EcsProfilerMarker[targets.Length];
|
_markers = new EcsProfilerMarker[Targets.Length];
|
||||||
for (int i = 0; i < targets.Length; i++)
|
for (int i = 0; i < Targets.Length; i++)
|
||||||
{
|
{
|
||||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}"));
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{Targets[i].GetType().Name}.{nameof(Destroy)}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -11,22 +11,18 @@ namespace DCFApixels.DragonECS
|
|||||||
private EcsPipeline _source;
|
private EcsPipeline _source;
|
||||||
private InjectSystemBase[] _injectSystems;
|
private InjectSystemBase[] _injectSystems;
|
||||||
private int _injectCount;
|
private int _injectCount;
|
||||||
|
|
||||||
public PreInitInjectController(EcsPipeline source)
|
public PreInitInjectController(EcsPipeline source)
|
||||||
{
|
{
|
||||||
_injectCount = 0;
|
_injectCount = 0;
|
||||||
_source = source;
|
_source = source;
|
||||||
_injectSystems = _source.AllSystems.OfType<InjectSystemBase>().ToArray();
|
_injectSystems = _source.AllSystems.OfType<InjectSystemBase>().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnInject()
|
public bool OnInject()
|
||||||
{
|
{
|
||||||
_injectCount++;
|
_injectCount++;
|
||||||
return IsInjectionEnd;
|
return IsInjectionEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInjectionEnd => _injectCount >= _injectSystems.Length;
|
public bool IsInjectionEnd => _injectCount >= _injectSystems.Length;
|
||||||
|
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
_source = null;
|
_source = null;
|
||||||
@ -68,7 +64,6 @@ namespace DCFApixels.DragonECS
|
|||||||
_preInjectchache.PreInject(obj);
|
_preInjectchache.PreInject(obj);
|
||||||
foreach (var item in targets) item.Inject(obj);
|
foreach (var item in targets) item.Inject(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSetup()
|
protected override void OnSetup()
|
||||||
{
|
{
|
||||||
_preInjectchache = Source.GetRunner<IEcsPreInject>();
|
_preInjectchache = Source.GetRunner<IEcsPreInject>();
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Unity.Profiling;
|
using Unity.Profiling;
|
||||||
using UnityEngine;
|
|
||||||
using delayedOp = System.Int32;
|
using delayedOp = System.Int32;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
@ -11,6 +10,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public readonly ref struct EcsReadonlyGroup
|
public readonly ref struct EcsReadonlyGroup
|
||||||
{
|
{
|
||||||
private readonly EcsGroup _source;
|
private readonly EcsGroup _source;
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsReadonlyGroup(EcsGroup source) => _source = source;
|
public EcsReadonlyGroup(EcsGroup source) => _source = source;
|
||||||
|
|||||||
@ -41,6 +41,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
//буфер удаления откладывает освобождение андишников сущьностей.
|
//буфер удаления откладывает освобождение андишников сущьностей.
|
||||||
//Нужен для того чтобы запускать некоторые процесыы связанные с удалением сущьности не по одному при каждом удалении, а пачкой
|
//Нужен для того чтобы запускать некоторые процесыы связанные с удалением сущьности не по одному при каждом удалении, а пачкой
|
||||||
|
//В теории такой подход частично улучшает ситуацию с переполнением поколений
|
||||||
private int[] _delEntBuffer;
|
private int[] _delEntBuffer;
|
||||||
private int _delEntBufferCount;
|
private int _delEntBufferCount;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Unity.Profiling;
|
using Unity.Profiling;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Unity.Profiling;
|
using Unity.Profiling;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System;
|
||||||
using System;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
|
||||||
public interface ITabelRecord
|
|
||||||
{
|
|
||||||
//TODO rename to index; Так EcsEntity по определению станет идентификатором
|
|
||||||
public int Id { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user