mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
tmp update
This commit is contained in:
parent
43d8489157
commit
b5300f7b43
@ -83,17 +83,17 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
public abstract void Inject(object obj);
|
||||
}
|
||||
internal class EcsBaseTypeInjectRunner<T> : EcsBaseTypeInjectRunner
|
||||
internal sealed class EcsBaseTypeInjectRunner<T> : EcsBaseTypeInjectRunner
|
||||
{
|
||||
private IEcsInject<T> _runner;
|
||||
public EcsBaseTypeInjectRunner(EcsPipeline pipeline) => _runner = pipeline.GetRunner<IEcsInject<T>>();
|
||||
public override void Inject(object obj) => _runner.Inject((T)obj);
|
||||
public sealed override void Inject(object obj) => _runner.Inject((T)obj);
|
||||
}
|
||||
internal class EcsObjectTypePreInjectRunner : EcsBaseTypeInjectRunner
|
||||
internal sealed class EcsObjectTypePreInjectRunner : EcsBaseTypeInjectRunner
|
||||
{
|
||||
private IEcsPreInject _runner;
|
||||
public EcsObjectTypePreInjectRunner(EcsPipeline pipeline) => _runner = pipeline.GetRunner<IEcsPreInject>();
|
||||
public override void Inject(object obj) => _runner.PreInject(obj);
|
||||
public sealed override void Inject(object obj) => _runner.PreInject(obj);
|
||||
}
|
||||
|
||||
[MetaTags(MetaTags.HIDDEN)]
|
||||
|
@ -20,13 +20,13 @@ namespace DCFApixels.DragonECS.Utils
|
||||
internal static unsafe class UnmanagedArrayUtility
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void* New<T>(int capacity) where T : struct
|
||||
public static T* New<T>(int capacity) where T : unmanaged
|
||||
{
|
||||
return Marshal.AllocHGlobal(Marshal.SizeOf(typeof(T)) * capacity).ToPointer();
|
||||
return (T*)Marshal.AllocHGlobal(Marshal.SizeOf<T>() * capacity).ToPointer();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void* NewAndInit<T>(int capacity) where T : struct
|
||||
public static T* NewAndInit<T>(int capacity) where T : unmanaged
|
||||
{
|
||||
int newSize = Marshal.SizeOf(typeof(T)) * capacity;
|
||||
byte* newPointer = (byte*)Marshal.AllocHGlobal(newSize).ToPointer();
|
||||
@ -34,7 +34,7 @@ namespace DCFApixels.DragonECS.Utils
|
||||
for (int i = 0; i < newSize; i++)
|
||||
*(newPointer + i) = 0;
|
||||
|
||||
return newPointer;
|
||||
return (T*)newPointer;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -44,9 +44,9 @@ namespace DCFApixels.DragonECS.Utils
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void* Resize<T>(void* oldPointer, int newCount) where T : struct
|
||||
public static T* Resize<T>(void* oldPointer, int newCount) where T : unmanaged
|
||||
{
|
||||
return (Marshal.ReAllocHGlobal(
|
||||
return (T*)(Marshal.ReAllocHGlobal(
|
||||
new IntPtr(oldPointer),
|
||||
new IntPtr(Marshal.SizeOf(typeof(T)) * newCount))).ToPointer();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user