fixes for support Unity 2020.1.x

This commit is contained in:
Mikhail 2024-01-04 22:52:54 +08:00
parent e3839609a5
commit 8b5cdd84f4
4 changed files with 37 additions and 10 deletions

View File

@ -25,7 +25,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _values.Length;
}
public readonly int this[int index]
public int this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _values[index];

View File

@ -142,16 +142,28 @@ namespace DCFApixels.DragonECS
foreach (var id in maskInc)
{
var bit = EcsMaskBit.FromID(id);
if (!r.TryAdd(bit.chankIndex, bit.mask))
if (r.ContainsKey(bit.chankIndex))
{
r[bit.chankIndex] = r[bit.chankIndex] | bit.mask;
}
else
{
r[bit.chankIndex] = bit.mask;
}
}
EcsMaskBit[] incMasks = r.Select(o => new EcsMaskBit(o.Key, o.Value)).ToArray();
r.Clear();
foreach (var id in maskExc)
{
var bit = EcsMaskBit.FromID(id);
if (!r.TryAdd(bit.chankIndex, bit.mask))
if (r.ContainsKey(bit.chankIndex))
{
r[bit.chankIndex] = r[bit.chankIndex] | bit.mask;
}
else
{
r[bit.chankIndex] = bit.mask;
}
}
EcsMaskBit[] excMasks = r.Select(o => new EcsMaskBit(o.Key, o.Value)).ToArray();
@ -230,7 +242,6 @@ namespace DCFApixels.DragonECS
}
public static EcsMaskBit FromID(int id)
{
short x = 10;
return new EcsMaskBit(id >> DIV_SHIFT, 1 << (id & MOD_MASK)); //аналогично new EcsMaskBit(id / BITS, 1 << (id % BITS)) но быстрее
}
public override string ToString()

View File

@ -138,12 +138,12 @@ namespace DCFApixels.DragonECS
throw new Exception();
}
Type GetRunnerBaseType(Type type)
Type GetRunnerBaseType(Type typeX)
{
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(EcsRunner<>))
return type;
if (type.BaseType != null)
return GetRunnerBaseType(type.BaseType);
if (typeX.IsGenericType && typeX.GetGenericTypeDefinition() == typeof(EcsRunner<>))
return typeX;
if (typeX.BaseType != null)
return GetRunnerBaseType(typeX.BaseType);
return null;
}
Type baseType = GetRunnerBaseType(type);
@ -291,7 +291,7 @@ namespace DCFApixels.DragonECS
name = Regex.Replace(name, @"\bEcs|Process\b", "");
if (Regex.IsMatch(name, "`\\w{1,}$"))
{
var s = name.Split("`");
var s = name.Split("`".ToCharArray());
name = s[0] + $"<{s[1]}>";
}
_processes.Add(type, new ProcessInterface(type, name));

View File

@ -1,5 +1,6 @@
#if ENABLE_DUMMY_SPAN
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute;
@ -68,12 +69,14 @@ namespace DCFApixels.DragonECS
#endregion
#region Object
#pragma warning disable CS0809 // Óñòàðåâøèé ÷ëåí ïåðåîïðåäåëÿåò íåóñòàðåâøèé ÷ëåí
[Obsolete("Equals() on ReadOnlySpan 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 ReadOnlySpan will always throw an exception.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => throw new NotSupportedException();
#pragma warning restore CS0809 // Óñòàðåâøèé ÷ëåí ïåðåîïðåäåëÿåò íåóñòàðåâøèé ÷ëåí
public override string ToString()
{
//if (typeof(T) == typeof(char))
@ -155,6 +158,19 @@ namespace DCFApixels.DragonECS
// return retVal;
//}
public void CopyTo(T[] array)
{
if (_length > array.Length)
{
throw new ArgumentOutOfRangeException();
}
for (int i = 0; i < _length; i++)
{
array[i] = _array[i];
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan<T> Slice(int start)
{