Partial implementation of new entity accesors from scene tree path

This commit is contained in:
Antoine Pilote
2024-04-19 00:03:59 -04:00
parent 5cb99f7ef6
commit 512cb3336c
5 changed files with 426 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
using Coral.Managed.Interop;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
@@ -20,7 +21,7 @@ namespace Nuake.Net
{
internal static unsafe delegate*<int, int, bool> EntityHasComponentIcall;
internal static unsafe delegate*<int, bool> EntityHasManagedInstanceIcall;
internal static unsafe delegate*<int, NativeString, int> EntityGetEntityIcall;
public enum ComponentTypes
{
Unknown = -1,
@@ -122,5 +123,26 @@ namespace Nuake.Net
return null;
}
public Entity? GetEntity<T>(string path) where T : Entity
{
Entity entityInstance;
unsafe
{
int entityHandle = EntityGetEntityIcall(ECSHandle, path );
bool hasInstance = EntityHasManagedInstanceIcall(entityHandle);
if (hasInstance)
{
entityInstance = Scene.GetEntity<Entity>(entityHandle);
}
else
{
entityInstance = new Entity { ECSHandle = entityHandle };
}
}
return null;
}
}
}