mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ScriptCore: Added Parent property to Transform
This commit is contained in:
@@ -459,6 +459,26 @@ static class ScriptGlue
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TransformComponent
|
#region TransformComponent
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Transform_GetParent")]
|
||||||
|
static void Transform_GetParent(UUID entityId, out UUID parentId)
|
||||||
|
{
|
||||||
|
Scene scene = ScriptEngine.Context;
|
||||||
|
Entity entity = scene.GetEntityByID(entityId);
|
||||||
|
|
||||||
|
parentId = entity.Parent?.UUID ?? .Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RegisterCall("ScriptGlue::Transform_SetParent")]
|
||||||
|
static void Transform_SetParent(UUID entityId, in UUID parentId)
|
||||||
|
{
|
||||||
|
Scene scene = ScriptEngine.Context;
|
||||||
|
Entity entity = scene.GetEntityByID(entityId);
|
||||||
|
|
||||||
|
Entity? parent = GetEntitySafe(parentId);
|
||||||
|
|
||||||
|
entity.Parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
[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)
|
||||||
|
|||||||
@@ -9,6 +9,20 @@ namespace GlitchyEngine.Core;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Transform : Component
|
public class Transform : Component
|
||||||
{
|
{
|
||||||
|
public Entity? Parent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ScriptGlue.Transform_GetParent(Entity.UUID, out UUID parentId);
|
||||||
|
|
||||||
|
if (parentId == UUID.Zero)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new Entity(parentId);
|
||||||
|
}
|
||||||
|
set => ScriptGlue.Transform_SetParent(Entity.UUID, value?._uuid ?? UUID.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the translation (position) of the entity.
|
/// Gets or sets the translation (position) of the entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ internal static class ScriptGlue
|
|||||||
|
|
||||||
#region TransformComponent
|
#region TransformComponent
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
|
internal static extern void Transform_GetParent(UUID entityId, out UUID parentId);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
|
internal static extern void Transform_SetParent(UUID entityId, in UUID parentId);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
internal static extern void Transform_GetTranslation(UUID entityId, out float3 translation);
|
internal static extern void Transform_GetTranslation(UUID entityId, out float3 translation);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user