mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
refactoring/add DebuggerProxy to entlong
This commit is contained in:
parent
77286fc00c
commit
5c805ba555
@ -2,6 +2,7 @@
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
#region Interfaces
|
||||
public interface IEcsPreInitProcess : IEcsSystem
|
||||
{
|
||||
void PreInit(EcsPipeline pipeline);
|
||||
@ -18,7 +19,8 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
void Destroy(EcsPipeline pipeline);
|
||||
}
|
||||
public interface IEcsBaseSystem : IEcsInitProcess, IEcsRunProcess, IEcsDestroyProcess { }
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
@ -40,7 +42,6 @@ namespace DCFApixels.DragonECS
|
||||
foreach (var item in targets) item.PreInit(pipeline);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
@ -70,7 +71,6 @@ namespace DCFApixels.DragonECS
|
||||
foreach (var item in targets) item.Init(pipeline);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
@ -101,7 +101,6 @@ namespace DCFApixels.DragonECS
|
||||
foreach (var item in targets) item.Run(pipeline);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
@ -131,7 +130,6 @@ namespace DCFApixels.DragonECS
|
||||
foreach (var item in targets) item.Destroy(pipeline);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using DCFApixels.DragonECS.RunnersCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
@ -9,9 +11,6 @@ using static DCFApixels.DragonECS.EcsDebugUtility;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using RunnersCore;
|
||||
using System.ComponentModel;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
||||
sealed class EcsRunnerFilterAttribute : Attribute
|
||||
{
|
||||
|
@ -148,7 +148,10 @@ namespace DCFApixels.DragonECS
|
||||
_inc = inc;
|
||||
_exc = exc;
|
||||
}
|
||||
|
||||
public override string ToString() => CreateLogString(_worldType, _inc, _exc);
|
||||
|
||||
#region Debug utils
|
||||
private static string CreateLogString(Type worldType, int[] inc, int[] exc)
|
||||
{
|
||||
#if DEBUG
|
||||
@ -159,7 +162,6 @@ namespace DCFApixels.DragonECS
|
||||
return $"Inc({string.Join(", ", inc)}) Exc({string.Join(", ", exc)})"; // Release optimization
|
||||
#endif
|
||||
}
|
||||
|
||||
internal class DebuggerProxy
|
||||
{
|
||||
public readonly Type worldType;
|
||||
@ -179,6 +181,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public override string ToString() => CreateLogString(worldType, inc, exc);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -186,25 +189,25 @@ namespace DCFApixels.DragonECS
|
||||
public ref struct EcsSubjectIterator<TSubject> where TSubject : EcsSubject
|
||||
{
|
||||
public readonly TSubject s;
|
||||
private EcsReadonlyGroup sourceGroup;
|
||||
private Enumerator enumerator;
|
||||
private EcsReadonlyGroup _sourceGroup;
|
||||
private Enumerator _enumerator;
|
||||
|
||||
public EcsSubjectIterator(TSubject s, EcsReadonlyGroup sourceGroup)
|
||||
{
|
||||
this.s = s;
|
||||
this.sourceGroup = sourceGroup;
|
||||
enumerator = default;
|
||||
this._sourceGroup = sourceGroup;
|
||||
_enumerator = default;
|
||||
}
|
||||
|
||||
public int Entity
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => enumerator.Current;
|
||||
get => _enumerator.Current;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Begin() => enumerator = GetEnumerator();
|
||||
public void Begin() => _enumerator = GetEnumerator();
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Next() => enumerator.MoveNext();
|
||||
public bool Next() => _enumerator.MoveNext();
|
||||
public void CopyTo(EcsGroup group)
|
||||
{
|
||||
group.Clear();
|
||||
@ -213,7 +216,7 @@ namespace DCFApixels.DragonECS
|
||||
group.AddInternal(enumerator.Current);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator() => new Enumerator(sourceGroup, s);
|
||||
public Enumerator GetEnumerator() => new Enumerator(_sourceGroup, s);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
@ -1,15 +1,18 @@
|
||||
#pragma warning disable IDE1006
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using static DCFApixels.DragonECS.entlong.ThrowHalper;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
using static entlong.ThrowHalper;
|
||||
// [ id 32 | gen 16 | world 16 ]
|
||||
/// <summary>Strong identifier/Permanent entity identifier</summary>
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 2, Size = 8)]
|
||||
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||
public readonly struct entlong : IEquatable<long>, IEquatable<entlong>
|
||||
{
|
||||
public static readonly entlong NULL = default;
|
||||
@ -34,7 +37,6 @@ namespace DCFApixels.DragonECS
|
||||
get => this == NULL;
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public int ID
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -46,7 +48,6 @@ namespace DCFApixels.DragonECS
|
||||
return id;
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public short Gen
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -69,7 +70,6 @@ namespace DCFApixels.DragonECS
|
||||
return EcsWorld.Worlds[world];
|
||||
}
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public short WorldID
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -158,5 +158,33 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DebuggerProxy
|
||||
internal class DebuggerProxy
|
||||
{
|
||||
private List<object> _componentsList;
|
||||
private entlong _value;
|
||||
public long full => _value.full;
|
||||
public int id => _value.id;
|
||||
public int gen => _value.gen;
|
||||
public int world => _value.world;
|
||||
public EntState State => _value.IsNull ? EntState.Null : _value.IsAlive ? EntState.Alive : EntState.Dead;
|
||||
public EcsWorld EcsWorld => _value.World;
|
||||
public IEnumerable<object> components
|
||||
{
|
||||
get
|
||||
{
|
||||
_value.World.GetComponents(_value.ID, _componentsList);
|
||||
return _componentsList;
|
||||
}
|
||||
}
|
||||
public DebuggerProxy(entlong value)
|
||||
{
|
||||
_value = value;
|
||||
_componentsList = new List<object>();
|
||||
}
|
||||
public enum EntState { Null, Dead, Alive, }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user