mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
ScriptGlue error handling
This commit is contained in:
@@ -289,14 +289,14 @@ static class ScriptGlue
|
|||||||
[RegisterCall("ScriptGlue::Entity_Destroy")]
|
[RegisterCall("ScriptGlue::Entity_Destroy")]
|
||||||
static void Entity_Destroy(UUID entityId)
|
static void Entity_Destroy(UUID entityId)
|
||||||
{
|
{
|
||||||
Entity entity = ScriptEngine.Context.GetEntityByID(entityId);
|
Entity entity = GetEntitySafe(entityId);
|
||||||
ScriptEngine.Context.DestroyEntityDeferred(entity);
|
ScriptEngine.Context.DestroyEntityDeferred(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Entity_CreateInstance")]
|
[RegisterCall("ScriptGlue::Entity_CreateInstance")]
|
||||||
static void Entity_CreateInstance(UUID entityId, out UUID newEntityId)
|
static void Entity_CreateInstance(UUID entityId, out UUID newEntityId)
|
||||||
{
|
{
|
||||||
Entity entity = ScriptEngine.Context.GetEntityByID(entityId);
|
Entity entity = GetEntitySafe(entityId);
|
||||||
Entity newEntity = ScriptEngine.Context.CreateInstance(entity);
|
Entity newEntity = ScriptEngine.Context.CreateInstance(entity);
|
||||||
|
|
||||||
newEntityId = newEntity.UUID;
|
newEntityId = newEntity.UUID;
|
||||||
@@ -323,7 +323,7 @@ static class ScriptGlue
|
|||||||
{
|
{
|
||||||
MonoType* type = Mono.mono_reflection_type_get_type(componentType);
|
MonoType* type = Mono.mono_reflection_type_get_type(componentType);
|
||||||
|
|
||||||
Entity entity = ScriptEngine.Context.GetEntityByID(entityId);
|
Entity entity = GetEntitySafe(entityId);
|
||||||
if (s_AddComponentMethods.TryGetValue(type, let addMethod))
|
if (s_AddComponentMethods.TryGetValue(type, let addMethod))
|
||||||
addMethod(entity);
|
addMethod(entity);
|
||||||
else
|
else
|
||||||
@@ -359,7 +359,7 @@ static class ScriptGlue
|
|||||||
{
|
{
|
||||||
MonoType* type = Mono.mono_reflection_type_get_type(componentType);
|
MonoType* type = Mono.mono_reflection_type_get_type(componentType);
|
||||||
|
|
||||||
Entity entity = ScriptEngine.Context.GetEntityByID(entityId);
|
Entity entity = GetEntitySafe(entityId);
|
||||||
if (s_RemoveComponentMethods.TryGetValue(type, let removeMethod))
|
if (s_RemoveComponentMethods.TryGetValue(type, let removeMethod))
|
||||||
removeMethod(entity);
|
removeMethod(entity);
|
||||||
else
|
else
|
||||||
@@ -463,8 +463,7 @@ static class ScriptGlue
|
|||||||
[RegisterCall("ScriptGlue::Transform_GetParent")]
|
[RegisterCall("ScriptGlue::Transform_GetParent")]
|
||||||
static void Transform_GetParent(UUID entityId, out UUID parentId)
|
static void Transform_GetParent(UUID entityId, out UUID parentId)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Entity entity = GetEntitySafe(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
parentId = entity.Parent?.UUID ?? .Zero;
|
parentId = entity.Parent?.UUID ?? .Zero;
|
||||||
}
|
}
|
||||||
@@ -472,8 +471,7 @@ static class ScriptGlue
|
|||||||
[RegisterCall("ScriptGlue::Transform_SetParent")]
|
[RegisterCall("ScriptGlue::Transform_SetParent")]
|
||||||
static void Transform_SetParent(UUID entityId, in UUID parentId)
|
static void Transform_SetParent(UUID entityId, in UUID parentId)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Entity entity = GetEntitySafe(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
Entity? parent = GetEntitySafe(parentId);
|
Entity? parent = GetEntitySafe(parentId);
|
||||||
|
|
||||||
@@ -483,8 +481,7 @@ static class ScriptGlue
|
|||||||
[RegisterCall("ScriptGlue::Transform_GetTranslation")]
|
[RegisterCall("ScriptGlue::Transform_GetTranslation")]
|
||||||
static void Transform_GetTranslation(UUID entityId, out float3 translation)
|
static void Transform_GetTranslation(UUID entityId, out float3 translation)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Entity entity = GetEntitySafe(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
translation = entity.Transform.Position;
|
translation = entity.Transform.Position;
|
||||||
}
|
}
|
||||||
@@ -492,8 +489,7 @@ static class ScriptGlue
|
|||||||
[RegisterCall("ScriptGlue::Transform_SetTranslation")]
|
[RegisterCall("ScriptGlue::Transform_SetTranslation")]
|
||||||
static void Transform_SetTranslation(UUID entityId, in float3 translation)
|
static void Transform_SetTranslation(UUID entityId, in float3 translation)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Entity entity = GetEntitySafe(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
entity.Transform.Position = translation;
|
entity.Transform.Position = translation;
|
||||||
|
|
||||||
@@ -511,100 +507,70 @@ static class ScriptGlue
|
|||||||
[RegisterCall("ScriptGlue::Rigidbody2D_ApplyForce")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_ApplyForce")]
|
||||||
static void Rigidbody2D_ApplyForce(UUID entityId, in float2 force, in float2 point, bool wakeUp)
|
static void Rigidbody2D_ApplyForce(UUID entityId, in float2 force, in float2 point, bool wakeUp)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
Box2D.Body.ApplyForce(rigidBody.[Friend]RuntimeBody, force, point, wakeUp);
|
Box2D.Body.ApplyForce(rigidBody.[Friend]RuntimeBody, force, point, wakeUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_ApplyForceToCenter")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_ApplyForceToCenter")]
|
||||||
static void Rigidbody2D_ApplyForceToCenter(UUID entityId, in float2 force, bool wakeUp)
|
static void Rigidbody2D_ApplyForceToCenter(UUID entityId, in float2 force, bool wakeUp)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
Box2D.Body.ApplyForceToCenter(rigidBody.[Friend]RuntimeBody, force, wakeUp);
|
Box2D.Body.ApplyForceToCenter(rigidBody.[Friend]RuntimeBody, force, wakeUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_SetPosition")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_SetPosition")]
|
||||||
static void Rigidbody2D_SetPosition(UUID entityId, in float2 position)
|
static void Rigidbody2D_SetPosition(UUID entityId, in float2 position)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
rigidBody.SetPosition(position);
|
rigidBody.SetPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_GetPosition")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_GetPosition")]
|
||||||
static void Rigidbody2D_GetPosition(UUID entityId, out float2 position)
|
static void Rigidbody2D_GetPosition(UUID entityId, out float2 position)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
position = rigidBody.GetPosition();
|
position = rigidBody.GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_SetRotation")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_SetRotation")]
|
||||||
static void Rigidbody2D_SetRotation(UUID entityId, in float rotation)
|
static void Rigidbody2D_SetRotation(UUID entityId, in float rotation)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
rigidBody.SetAngle(rotation);
|
rigidBody.SetAngle(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_GetRotation")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_GetRotation")]
|
||||||
static void Rigidbody2D_GetRotation(UUID entityId, out float rotation)
|
static void Rigidbody2D_GetRotation(UUID entityId, out float rotation)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
rotation = rigidBody.GetAngle();
|
rotation = rigidBody.GetAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_GetLinearVelocity")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_GetLinearVelocity")]
|
||||||
static void Rigidbody2D_GetLinearVelocity(UUID entityId, out float2 velocity)
|
static void Rigidbody2D_GetLinearVelocity(UUID entityId, out float2 velocity)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
velocity = rigidBody.GetLinearVelocity();
|
velocity = rigidBody.GetLinearVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_SetLinearVelocity")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_SetLinearVelocity")]
|
||||||
static void Rigidbody2D_SetLinearVelocity(UUID entityId, in float2 velocity)
|
static void Rigidbody2D_SetLinearVelocity(UUID entityId, in float2 velocity)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
rigidBody.SetLinearVelocity(velocity);
|
rigidBody.SetLinearVelocity(velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_GetAngularVelocity")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_GetAngularVelocity")]
|
||||||
static void Rigidbody2D_GetAngularVelocity(UUID entityId, out float velocity)
|
static void Rigidbody2D_GetAngularVelocity(UUID entityId, out float velocity)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
velocity = rigidBody.GetAngularVelocity();
|
velocity = rigidBody.GetAngularVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Rigidbody2D_SetAngularVelocity")]
|
[RegisterCall("ScriptGlue::Rigidbody2D_SetAngularVelocity")]
|
||||||
static void Rigidbody2D_SetAngularVelocity(UUID entityId, in float velocity)
|
static void Rigidbody2D_SetAngularVelocity(UUID entityId, in float velocity)
|
||||||
{
|
{
|
||||||
Scene scene = ScriptEngine.Context;
|
Rigidbody2DComponent* rigidBody = GetComponentSafe<Rigidbody2DComponent>(entityId);
|
||||||
Entity entity = scene.GetEntityByID(entityId);
|
|
||||||
|
|
||||||
var rigidBody = entity.GetComponent<Rigidbody2DComponent>();
|
|
||||||
rigidBody.SetAngularVelocity(velocity);
|
rigidBody.SetAngularVelocity(velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,8 +592,6 @@ static class ScriptGlue
|
|||||||
camera.Camera.ProjectionType = projectionType;
|
camera.Camera.ProjectionType = projectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Native Implementierungen in Beef für die Kamera-Properties
|
|
||||||
|
|
||||||
[RegisterCall("ScriptGlue::Camera_GetPerspectiveFovY")]
|
[RegisterCall("ScriptGlue::Camera_GetPerspectiveFovY")]
|
||||||
static void Camera_GetPerspectiveFovY(UUID entityId, out float fovY)
|
static void Camera_GetPerspectiveFovY(UUID entityId, out float fovY)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user