Better engine exception for scripting

This commit is contained in:
Simon Lübeß
2025-07-30 18:58:26 +02:00
parent 72e87ee9ad
commit ed644b5b41
6 changed files with 74 additions and 36 deletions
+5 -3
View File
@@ -319,7 +319,7 @@ internal static unsafe partial class ScriptGlue
struct ComponentFunctionPointers
{
public delegate* unmanaged[Cdecl]<UUID, void> AddComponent;
public delegate* unmanaged[Cdecl]<UUID, bool> HasComponent;
public delegate* unmanaged[Cdecl]<UUID, EngineResult> HasComponent;
public delegate* unmanaged[Cdecl]<UUID, void> RemoveComponent;
}
@@ -328,7 +328,7 @@ internal static unsafe partial class ScriptGlue
[UnmanagedCallersOnly]
public static void RegisterComponentType(byte* fullComponentTypeName,
delegate* unmanaged[Cdecl]<UUID, void> addComponent,
delegate* unmanaged[Cdecl]<UUID, bool> hasComponent,
delegate* unmanaged[Cdecl]<UUID, EngineResult> hasComponent,
delegate* unmanaged[Cdecl]<UUID, void> removeComponent)
{
string? beefComponentTypeName = Marshal.PtrToStringUTF8((IntPtr)fullComponentTypeName);
@@ -421,7 +421,9 @@ internal static unsafe partial class ScriptGlue
public static bool Entity_HasComponent(UUID entityId, Type componentType)
{
return ComponentTypeFunctions[componentType].HasComponent(entityId);
EngineResult returnValue = ComponentTypeFunctions[componentType].HasComponent(entityId);
EngineErrors.ThrowIfError(returnValue);
return returnValue == EngineResult.Ok;
}
public static void Entity_RemoveComponent(UUID entityId, Type componentType)