mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
update collections
This commit is contained in:
parent
4ed102eaf2
commit
3119ea42db
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@ -111,10 +112,6 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsSupersetOf(EcsGroup group) => _source.IsSupersetOf(group);
|
public bool IsSupersetOf(EcsGroup group) => _source.IsSupersetOf(group);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Object
|
|
||||||
public override string ToString() => _source != null ? _source.ToString() : "NULL";
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Internal
|
#region Internal
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal EcsGroup GetGroupInternal() => _source;
|
internal EcsGroup GetGroupInternal() => _source;
|
||||||
@ -122,6 +119,19 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other
|
#region Other
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return _source != null ? _source.ToString() : "NULL";
|
||||||
|
}
|
||||||
|
#pragma warning disable CS0809 // Устаревший член переопределяет неустаревший член
|
||||||
|
[Obsolete("Equals() on EcsGroup will always throw an exception. Use the equality operator instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override bool Equals(object obj) => throw new NotSupportedException();
|
||||||
|
[Obsolete("GetHashCode() on EcsGroup will always throw an exception.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override int GetHashCode() => throw new NotSupportedException();
|
||||||
|
#pragma warning restore CS0809 // Устаревший член переопределяет неустаревший член
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static implicit operator EcsSpan(EcsReadonlyGroup a) => a.ToSpan();
|
public static implicit operator EcsSpan(EcsReadonlyGroup a) => a.ToSpan();
|
||||||
internal class DebuggerProxy : EcsGroup.DebuggerProxy
|
internal class DebuggerProxy : EcsGroup.DebuggerProxy
|
||||||
@ -710,7 +720,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Other
|
#region Other
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"group{{{string.Join(", ", _dense.Skip(1).Take(_count).OrderBy(o => o))}}}";
|
return $"group({_count}) {{{string.Join(", ", _dense.Skip(1).Take(_count).OrderBy(o => o))}}}";
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int First()
|
public int First()
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public readonly ref struct EcsSpan
|
public readonly ref struct EcsSpan
|
||||||
{
|
{
|
||||||
private readonly int _worldID;
|
private readonly int _worldID;
|
||||||
@ -91,18 +94,6 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Object
|
|
||||||
#pragma warning disable CS0809 // Устаревший член переопределяет неустаревший член
|
|
||||||
[Obsolete("Equals() on EcsSpan will always throw an exception. Use the equality operator instead.")]
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
||||||
public override bool Equals(object obj) => throw new NotSupportedException();
|
|
||||||
[Obsolete("GetHashCode() on EcsSpan will always throw an exception.")]
|
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
||||||
public override int GetHashCode() => throw new NotSupportedException();
|
|
||||||
#pragma warning restore CS0809 // Устаревший член переопределяет неустаревший член
|
|
||||||
public override string ToString() => _values.ToString();
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region operators
|
#region operators
|
||||||
public static bool operator ==(EcsSpan left, EcsSpan right) => left._values == right._values;
|
public static bool operator ==(EcsSpan left, EcsSpan right) => left._values == right._values;
|
||||||
public static bool operator !=(EcsSpan left, EcsSpan right) => left._values != right._values;
|
public static bool operator !=(EcsSpan left, EcsSpan right) => left._values != right._values;
|
||||||
@ -120,6 +111,45 @@ namespace DCFApixels.DragonECS
|
|||||||
public EcsSpan Slice(int start, int length) => new EcsSpan(_worldID, _values.Slice(start, length));
|
public EcsSpan Slice(int start, int length) => new EcsSpan(_worldID, _values.Slice(start, length));
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int[] ToArray() => _values.ToArray();
|
public int[] ToArray() => _values.ToArray();
|
||||||
|
|
||||||
|
#pragma warning disable CS0809 // Устаревший член переопределяет неустаревший член
|
||||||
|
[Obsolete("Equals() on EcsSpan will always throw an exception. Use the equality operator instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override bool Equals(object obj) => throw new NotSupportedException();
|
||||||
|
[Obsolete("GetHashCode() on EcsSpan will always throw an exception.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public override int GetHashCode() => throw new NotSupportedException();
|
||||||
|
#pragma warning restore CS0809 // Устаревший член переопределяет неустаревший член
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"span({_values.Length}) {{{string.Join(", ", _values.ToArray().OrderBy(o => o))}}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DebuggerProxy
|
||||||
|
{
|
||||||
|
private int[] _values;
|
||||||
|
private int _worldID;
|
||||||
|
public EcsWorld World => EcsWorld.GetWorld(_worldID);
|
||||||
|
public entlong[] Entities
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
entlong[] result = new entlong[_values.Length];
|
||||||
|
int i = 0;
|
||||||
|
foreach (var e in _values)
|
||||||
|
result[i++] = World.GetEntityLong(e);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Count => _values.Length;
|
||||||
|
//public override string ToString() => $"span({_values.Length}) {{{string.Join(", ", _values.OrderBy(o => o))}}}";
|
||||||
|
public DebuggerProxy(EcsSpan span)
|
||||||
|
{
|
||||||
|
_values = new int[span.Length];
|
||||||
|
span._values.CopyTo(_values);
|
||||||
|
_worldID = span._worldID;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user