mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-27 16:17:12 +03:00
Added prefab instancing through C# and support for mid-game rigidbody and skeletal animation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Coral.Managed.Interop;
|
||||
using System;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace Nuake.Net
|
||||
{
|
||||
@@ -8,6 +9,7 @@ namespace Nuake.Net
|
||||
internal static unsafe delegate*<NativeString, int> GetEntityIcall;
|
||||
internal static unsafe delegate*<NativeString, NativeInstance<Entity>> GetEntityScriptFromNameIcall;
|
||||
internal static unsafe delegate*<int, NativeInstance<Entity>> GetEntityScriptFromHandleIcall;
|
||||
internal static unsafe delegate*<NativeString, int> InstancePrefabIcall;
|
||||
|
||||
public static T? GetEntity<T>(string entityName) where T : class
|
||||
{
|
||||
@@ -22,6 +24,7 @@ namespace Nuake.Net
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static T? GetEntity<T>(int entityHandle) where T : class
|
||||
{
|
||||
NativeInstance<Entity> handle;
|
||||
@@ -53,5 +56,32 @@ namespace Nuake.Net
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static Entity? InstancePrefab(string path, Entity? parent = null)
|
||||
{
|
||||
int handle;
|
||||
unsafe { handle = InstancePrefabIcall(path); }
|
||||
|
||||
if (handle == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
//NativeInstance<Entity> nativeInstance;
|
||||
//unsafe { nativeInstance = GetEntityScriptFromHandleIcall(handle); }
|
||||
//
|
||||
//Entity? entity = nativeInstance.Get();
|
||||
//if (entity != null && entity is T)
|
||||
//{
|
||||
// return entity as T;
|
||||
//}
|
||||
|
||||
Entity entity = new Entity
|
||||
{
|
||||
ECSHandle = handle
|
||||
};
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user