ScriptCore: Added Parent property to Transform

This commit is contained in:
Simon Lübeß
2024-01-25 22:29:11 +01:00
parent 3815b70f06
commit d8e4e8d028
3 changed files with 40 additions and 0 deletions
+14
View File
@@ -9,6 +9,20 @@ namespace GlitchyEngine.Core;
/// </summary>
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>
/// Gets or sets the translation (position) of the entity.
/// </summary>
+6
View File
@@ -67,6 +67,12 @@ internal static class ScriptGlue
#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)]
internal static extern void Transform_GetTranslation(UUID entityId, out float3 translation);