Added ability to get other instances of .net scripts using GetEntity<T>

This commit is contained in:
Antoine Pilote
2024-04-02 00:12:04 -04:00
parent 3d60ab1608
commit 33b4f75461
4 changed files with 63 additions and 52 deletions

View File

@@ -6,6 +6,21 @@ namespace Nuake.Net
public class Scene
{
internal static unsafe delegate*<NativeString, int> GetEntityIcall;
internal static unsafe delegate*<NativeString, NativeInstance<Entity>> GetEntityScriptIcall;
public static T? GetEntity<T>(string entityName) where T : class
{
NativeInstance<Entity> handle;
unsafe { handle = GetEntityScriptIcall(entityName); }
Entity? entity = handle.Get();
if (entity != null && entity is T)
{
return entity as T;
}
return null;
}
public static Entity GetEntity(string entityName)
{