mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-13 00:55:55 +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 interface IEcsBaseSystem : IEcsInitSystem, IEcsRunSystem, IEcsDestroySystem { }
|
||||
|
||||
namespace Internal
|
||||
@ -32,10 +31,10 @@ namespace DCFApixels.DragonECS
|
||||
public void PreInit(EcsPipeline pipeline)
|
||||
{
|
||||
#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())
|
||||
targets[i].PreInit(pipeline);
|
||||
Targets[i].PreInit(pipeline);
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.PreInit(pipeline);
|
||||
@ -45,10 +44,10 @@ namespace DCFApixels.DragonECS
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
_markers = new EcsProfilerMarker[Targets.Length];
|
||||
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
|
||||
@ -62,10 +61,10 @@ namespace DCFApixels.DragonECS
|
||||
public void Init(EcsPipeline pipeline)
|
||||
{
|
||||
#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())
|
||||
targets[i].Init(pipeline);
|
||||
Targets[i].Init(pipeline);
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.Init(pipeline);
|
||||
@ -75,10 +74,10 @@ namespace DCFApixels.DragonECS
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
_markers = new EcsProfilerMarker[Targets.Length];
|
||||
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
|
||||
@ -92,10 +91,10 @@ namespace DCFApixels.DragonECS
|
||||
public void Run(EcsPipeline pipeline)
|
||||
{
|
||||
#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())
|
||||
targets[i].Run(pipeline);
|
||||
Targets[i].Run(pipeline);
|
||||
|
||||
}
|
||||
#else
|
||||
@ -106,10 +105,10 @@ namespace DCFApixels.DragonECS
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
_markers = new EcsProfilerMarker[Targets.Length];
|
||||
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
|
||||
@ -123,10 +122,10 @@ namespace DCFApixels.DragonECS
|
||||
public void Destroy(EcsPipeline pipeline)
|
||||
{
|
||||
#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())
|
||||
targets[i].Destroy(pipeline);
|
||||
Targets[i].Destroy(pipeline);
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.Destroy(pipeline);
|
||||
@ -136,10 +135,10 @@ namespace DCFApixels.DragonECS
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
_markers = new EcsProfilerMarker[Targets.Length];
|
||||
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
|
||||
|
||||
@ -11,22 +11,18 @@ namespace DCFApixels.DragonECS
|
||||
private EcsPipeline _source;
|
||||
private InjectSystemBase[] _injectSystems;
|
||||
private int _injectCount;
|
||||
|
||||
public PreInitInjectController(EcsPipeline source)
|
||||
{
|
||||
_injectCount = 0;
|
||||
_source = source;
|
||||
_injectSystems = _source.AllSystems.OfType<InjectSystemBase>().ToArray();
|
||||
}
|
||||
|
||||
public bool OnInject()
|
||||
{
|
||||
_injectCount++;
|
||||
return IsInjectionEnd;
|
||||
}
|
||||
|
||||
public bool IsInjectionEnd => _injectCount >= _injectSystems.Length;
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
_source = null;
|
||||
@ -68,7 +64,6 @@ namespace DCFApixels.DragonECS
|
||||
_preInjectchache.PreInject(obj);
|
||||
foreach (var item in targets) item.Inject(obj);
|
||||
}
|
||||
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_preInjectchache = Source.GetRunner<IEcsPreInject>();
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.Profiling;
|
||||
using UnityEngine;
|
||||
using delayedOp = System.Int32;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
@ -11,6 +10,7 @@ namespace DCFApixels.DragonECS
|
||||
public readonly ref struct EcsReadonlyGroup
|
||||
{
|
||||
private readonly EcsGroup _source;
|
||||
|
||||
#region Constructors
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup(EcsGroup source) => _source = source;
|
||||
|
||||
@ -41,6 +41,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
//буфер удаления откладывает освобождение андишников сущьностей.
|
||||
//Нужен для того чтобы запускать некоторые процесыы связанные с удалением сущьности не по одному при каждом удалении, а пачкой
|
||||
//В теории такой подход частично улучшает ситуацию с переполнением поколений
|
||||
private int[] _delEntBuffer;
|
||||
private int _delEntBufferCount;
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Unity.Profiling;
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Unity.Profiling;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
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