mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
add Bake methods to EcsSpan
This commit is contained in:
parent
1ecad4de1d
commit
43d8489157
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@ -62,6 +63,34 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methdos
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int[] Bake()
|
||||
{
|
||||
int[] result = new int[_values.Length];
|
||||
_values.CopyTo(result);
|
||||
return result;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Bake(ref int[] entities)
|
||||
{
|
||||
if (entities.Length < _values.Length)
|
||||
Array.Resize(ref entities, _values.Length);
|
||||
int[] result = new int[_values.Length];
|
||||
_values.CopyTo(result);
|
||||
return _values.Length;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Bake(List<int> entities)
|
||||
{
|
||||
entities.Clear();
|
||||
foreach (var e in _values)
|
||||
{
|
||||
entities.Add(e);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Object
|
||||
#pragma warning disable CS0809 // Устаревший член переопределяет неустаревший член
|
||||
[Obsolete($"Equals() on {nameof(EcsSpan)} will always throw an exception. Use the equality operator instead.")]
|
||||
|
Loading…
Reference in New Issue
Block a user