feat(scripting): add mono csharp runtime foundation
This commit is contained in:
263
managed/XCEngine.ScriptCore/Transform.cs
Normal file
263
managed/XCEngine.ScriptCore/Transform.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public sealed class Transform : Component
|
||||
{
|
||||
internal Transform(ulong gameObjectUUID)
|
||||
: base(gameObjectUUID)
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 LocalPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetLocalPosition(GameObjectUUID, out Vector3 position);
|
||||
return position;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetLocalPosition(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 localPosition
|
||||
{
|
||||
get => LocalPosition;
|
||||
set => LocalPosition = value;
|
||||
}
|
||||
|
||||
public Quaternion LocalRotation
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetLocalRotation(GameObjectUUID, out Quaternion rotation);
|
||||
return rotation;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetLocalRotation(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Quaternion localRotation
|
||||
{
|
||||
get => LocalRotation;
|
||||
set => LocalRotation = value;
|
||||
}
|
||||
|
||||
public Vector3 LocalScale
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetLocalScale(GameObjectUUID, out Vector3 scale);
|
||||
return scale;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetLocalScale(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 localScale
|
||||
{
|
||||
get => LocalScale;
|
||||
set => LocalScale = value;
|
||||
}
|
||||
|
||||
public Vector3 LocalEulerAngles
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetLocalEulerAngles(GameObjectUUID, out Vector3 eulerAngles);
|
||||
return eulerAngles;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetLocalEulerAngles(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 localEulerAngles
|
||||
{
|
||||
get => LocalEulerAngles;
|
||||
set => LocalEulerAngles = value;
|
||||
}
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetPosition(GameObjectUUID, out Vector3 position);
|
||||
return position;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetPosition(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 position
|
||||
{
|
||||
get => Position;
|
||||
set => Position = value;
|
||||
}
|
||||
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetRotation(GameObjectUUID, out Quaternion rotation);
|
||||
return rotation;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetRotation(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Quaternion rotation
|
||||
{
|
||||
get => Rotation;
|
||||
set => Rotation = value;
|
||||
}
|
||||
|
||||
public Vector3 Scale
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetScale(GameObjectUUID, out Vector3 scale);
|
||||
return scale;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetScale(GameObjectUUID, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 scale
|
||||
{
|
||||
get => Scale;
|
||||
set => Scale = value;
|
||||
}
|
||||
|
||||
public Vector3 Forward
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetForward(GameObjectUUID, out Vector3 forward);
|
||||
return forward;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 forward => Forward;
|
||||
|
||||
public Vector3 Right
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetRight(GameObjectUUID, out Vector3 right);
|
||||
return right;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 right => Right;
|
||||
|
||||
public Vector3 Up
|
||||
{
|
||||
get
|
||||
{
|
||||
InternalCalls.Transform_GetUp(GameObjectUUID, out Vector3 up);
|
||||
return up;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 up => Up;
|
||||
|
||||
public Transform Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
ulong parentUUID = InternalCalls.Transform_GetParent(GameObjectUUID);
|
||||
return Create<Transform>(parentUUID);
|
||||
}
|
||||
set
|
||||
{
|
||||
InternalCalls.Transform_SetParent(GameObjectUUID, value?.GameObjectUUID ?? 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
public Transform parent
|
||||
{
|
||||
get => Parent;
|
||||
set => Parent = value;
|
||||
}
|
||||
|
||||
public int ChildCount => InternalCalls.Transform_GetChildCount(GameObjectUUID);
|
||||
public int childCount => ChildCount;
|
||||
|
||||
public Transform GetChild(int index)
|
||||
{
|
||||
ulong childUUID = InternalCalls.Transform_GetChild(GameObjectUUID, index);
|
||||
return Create<Transform>(childUUID);
|
||||
}
|
||||
|
||||
public void SetParent(Transform parent)
|
||||
{
|
||||
SetParent(parent, true);
|
||||
}
|
||||
|
||||
public void SetParent(Transform parent, bool worldPositionStays)
|
||||
{
|
||||
InternalCalls.Transform_SetParent(GameObjectUUID, parent?.GameObjectUUID ?? 0, worldPositionStays);
|
||||
}
|
||||
|
||||
public void Translate(Vector3 translation)
|
||||
{
|
||||
Translate(translation, Space.Self);
|
||||
}
|
||||
|
||||
public void Translate(Vector3 translation, Space relativeTo)
|
||||
{
|
||||
InternalCalls.Transform_Translate(GameObjectUUID, ref translation, (int)relativeTo);
|
||||
}
|
||||
|
||||
public void Rotate(Vector3 eulers)
|
||||
{
|
||||
Rotate(eulers, Space.Self);
|
||||
}
|
||||
|
||||
public void Rotate(Vector3 eulers, Space relativeTo)
|
||||
{
|
||||
InternalCalls.Transform_Rotate(GameObjectUUID, ref eulers, (int)relativeTo);
|
||||
}
|
||||
|
||||
public void LookAt(Vector3 worldPosition)
|
||||
{
|
||||
InternalCalls.Transform_LookAt(GameObjectUUID, ref worldPosition);
|
||||
}
|
||||
|
||||
public Vector3 TransformPoint(Vector3 point)
|
||||
{
|
||||
InternalCalls.Transform_TransformPoint(GameObjectUUID, ref point, out Vector3 transformedPoint);
|
||||
return transformedPoint;
|
||||
}
|
||||
|
||||
public Vector3 InverseTransformPoint(Vector3 point)
|
||||
{
|
||||
InternalCalls.Transform_InverseTransformPoint(GameObjectUUID, ref point, out Vector3 transformedPoint);
|
||||
return transformedPoint;
|
||||
}
|
||||
|
||||
public Vector3 TransformDirection(Vector3 direction)
|
||||
{
|
||||
InternalCalls.Transform_TransformDirection(GameObjectUUID, ref direction, out Vector3 transformedDirection);
|
||||
return transformedDirection;
|
||||
}
|
||||
|
||||
public Vector3 InverseTransformDirection(Vector3 direction)
|
||||
{
|
||||
InternalCalls.Transform_InverseTransformDirection(GameObjectUUID, ref direction, out Vector3 transformedDirection);
|
||||
return transformedDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user