feat(scripting): add mono csharp runtime foundation
This commit is contained in:
@@ -50,14 +50,30 @@ foreach(XCENGINE_REQUIRED_PATH
|
||||
endforeach()
|
||||
|
||||
set(XCENGINE_SCRIPT_CORE_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Camera.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Behaviour.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Component.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Debug.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/GameObject.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/InternalCalls.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Light.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/MonoBehaviour.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Quaternion.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Space.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Time.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Transform.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Vector2.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Vector3.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XCEngine.ScriptCore/Vector4.cs
|
||||
)
|
||||
|
||||
set(XCENGINE_GAME_SCRIPT_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameScripts/BuiltinComponentProbe.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameScripts/HierarchyProbe.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameScripts/LifecycleProbe.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameScripts/TransformConversionProbe.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameScripts/TransformMotionProbe.cs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GameScripts/TransformSpaceProbe.cs
|
||||
)
|
||||
|
||||
set(XCENGINE_MANAGED_FRAMEWORK_REFERENCES
|
||||
|
||||
60
managed/GameScripts/BuiltinComponentProbe.cs
Normal file
60
managed/GameScripts/BuiltinComponentProbe.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class BuiltinComponentProbe : MonoBehaviour
|
||||
{
|
||||
public bool HasCamera;
|
||||
public bool HasLight;
|
||||
public bool CameraLookupSucceeded;
|
||||
public bool LightLookupSucceeded;
|
||||
|
||||
public float ObservedFieldOfView;
|
||||
public float ObservedNearClipPlane;
|
||||
public float ObservedFarClipPlane;
|
||||
public float ObservedDepth;
|
||||
public bool ObservedPrimary;
|
||||
|
||||
public float ObservedIntensity;
|
||||
public float ObservedRange;
|
||||
public float ObservedSpotAngle;
|
||||
public bool ObservedCastsShadows;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
HasCamera = HasComponent<Camera>();
|
||||
HasLight = HasComponent<Light>();
|
||||
|
||||
CameraLookupSucceeded = TryGetComponent(out Camera camera);
|
||||
LightLookupSucceeded = TryGetComponent(out Light light);
|
||||
|
||||
if (camera != null)
|
||||
{
|
||||
ObservedFieldOfView = camera.fieldOfView;
|
||||
ObservedNearClipPlane = camera.nearClipPlane;
|
||||
ObservedFarClipPlane = camera.farClipPlane;
|
||||
ObservedDepth = camera.depth;
|
||||
ObservedPrimary = camera.primary;
|
||||
|
||||
camera.fieldOfView = 75.0f;
|
||||
camera.nearClipPlane = 0.3f;
|
||||
camera.farClipPlane = 500.0f;
|
||||
camera.depth = 3.0f;
|
||||
camera.primary = false;
|
||||
}
|
||||
|
||||
if (light != null)
|
||||
{
|
||||
ObservedIntensity = light.intensity;
|
||||
ObservedRange = light.range;
|
||||
ObservedSpotAngle = light.spotAngle;
|
||||
ObservedCastsShadows = light.castsShadows;
|
||||
|
||||
light.intensity = 2.5f;
|
||||
light.range = 42.0f;
|
||||
light.spotAngle = 55.0f;
|
||||
light.castsShadows = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
managed/GameScripts/HierarchyProbe.cs
Normal file
45
managed/GameScripts/HierarchyProbe.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class HierarchyProbe : MonoBehaviour
|
||||
{
|
||||
public GameObject ReparentTarget;
|
||||
public string ObservedParentName = string.Empty;
|
||||
public string ObservedFirstChildName = string.Empty;
|
||||
public string ReparentedChildParentName = string.Empty;
|
||||
public bool ParentLookupSucceeded;
|
||||
public bool ChildLookupSucceeded;
|
||||
public int ObservedChildCount;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Transform currentParent = transform.parent;
|
||||
ParentLookupSucceeded = currentParent != null;
|
||||
if (currentParent != null)
|
||||
{
|
||||
ObservedParentName = currentParent.gameObject.name;
|
||||
}
|
||||
|
||||
ObservedChildCount = transform.childCount;
|
||||
|
||||
Transform firstChild = transform.GetChild(0);
|
||||
ChildLookupSucceeded = firstChild != null;
|
||||
if (firstChild != null)
|
||||
{
|
||||
ObservedFirstChildName = firstChild.gameObject.name;
|
||||
|
||||
if (ReparentTarget != null)
|
||||
{
|
||||
firstChild.SetParent(ReparentTarget.transform, true);
|
||||
|
||||
Transform newParent = firstChild.parent;
|
||||
if (newParent != null)
|
||||
{
|
||||
ReparentedChildParentName = newParent.gameObject.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,14 @@ namespace Gameplay
|
||||
{
|
||||
}
|
||||
|
||||
public sealed class UnsupportedManagedComponent : Component
|
||||
{
|
||||
private UnsupportedManagedComponent(ulong gameObjectUUID)
|
||||
: base(gameObjectUUID)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class LifecycleProbe : MonoBehaviour
|
||||
{
|
||||
public int AwakeCount;
|
||||
@@ -18,14 +26,47 @@ namespace Gameplay
|
||||
public int DestroyCount;
|
||||
|
||||
public float Speed;
|
||||
public float ObservedFixedDeltaTime;
|
||||
public float ObservedUpdateDeltaTime;
|
||||
public float ObservedLateDeltaTime;
|
||||
public string Label = string.Empty;
|
||||
public string ObservedGameObjectName = string.Empty;
|
||||
public string ObservedTargetName = string.Empty;
|
||||
public bool WasAwakened;
|
||||
public bool WarningLogged;
|
||||
public bool ErrorLogged;
|
||||
public bool HasTransform;
|
||||
public bool TransformLookupSucceeded;
|
||||
public bool HasUnsupportedComponent;
|
||||
public bool UnsupportedComponentLookupReturnedNull;
|
||||
public bool TargetResolved;
|
||||
public bool RotationAccessed;
|
||||
public bool ScaleAccessed;
|
||||
public bool TransformAccessed;
|
||||
public bool ObservedEnabled;
|
||||
public bool ObservedActiveSelf;
|
||||
public bool ObservedActiveInHierarchy;
|
||||
public bool ObservedIsActiveAndEnabled;
|
||||
public bool DisableSelfOnFirstUpdate;
|
||||
public bool DeactivateGameObjectOnFirstUpdate;
|
||||
public GameObject Target;
|
||||
public GameObject SelfReference;
|
||||
public Vector4 ObservedLocalRotation;
|
||||
public Vector3 ObservedLocalPosition;
|
||||
public Vector3 ObservedLocalScale;
|
||||
public Vector3 SpawnPoint;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
AwakeCount += 1;
|
||||
WasAwakened = true;
|
||||
gameObject.name = gameObject.name + "_Managed";
|
||||
ObservedGameObjectName = gameObject.name;
|
||||
Debug.Log(ObservedGameObjectName);
|
||||
Debug.LogWarning(ObservedGameObjectName);
|
||||
WarningLogged = true;
|
||||
Debug.LogError(ObservedGameObjectName);
|
||||
ErrorLogged = true;
|
||||
Label = Label + "|Awake";
|
||||
}
|
||||
|
||||
@@ -37,23 +78,80 @@ namespace Gameplay
|
||||
public void Start()
|
||||
{
|
||||
StartCount += 1;
|
||||
HasTransform = HasComponent<Transform>();
|
||||
HasUnsupportedComponent = HasComponent<UnsupportedManagedComponent>();
|
||||
|
||||
SelfReference = gameObject;
|
||||
TargetResolved = Target != null;
|
||||
if (Target != null)
|
||||
{
|
||||
ObservedTargetName = Target.name;
|
||||
}
|
||||
|
||||
TransformLookupSucceeded = TryGetComponent(out Transform resolvedTransform);
|
||||
UnsupportedComponentLookupReturnedNull = !gameObject.TryGetComponent(out UnsupportedManagedComponent unsupportedComponent);
|
||||
|
||||
if (resolvedTransform != null)
|
||||
{
|
||||
resolvedTransform.localPosition = new Vector3(7.0f, 8.0f, 9.0f);
|
||||
resolvedTransform.localRotation = new Quaternion(0.0f, 0.5f, 0.0f, 0.8660254f);
|
||||
resolvedTransform.localScale = new Vector3(2.0f, 3.0f, 4.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
{
|
||||
FixedUpdateCount += 1;
|
||||
ObservedFixedDeltaTime = Time.deltaTime;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
UpdateCount += 1;
|
||||
Speed += 1.0f;
|
||||
ObservedUpdateDeltaTime = Time.deltaTime;
|
||||
ObservedLocalPosition = transform.localPosition;
|
||||
Quaternion rotation = transform.localRotation;
|
||||
ObservedLocalRotation = new Vector4(rotation.x, rotation.y, rotation.z, rotation.w);
|
||||
ObservedLocalScale = transform.localScale;
|
||||
ObservedEnabled = enabled;
|
||||
ObservedActiveSelf = gameObject.activeSelf;
|
||||
ObservedActiveInHierarchy = gameObject.activeInHierarchy;
|
||||
ObservedIsActiveAndEnabled = isActiveAndEnabled;
|
||||
RotationAccessed = true;
|
||||
ScaleAccessed = true;
|
||||
TransformAccessed = true;
|
||||
|
||||
if (UpdateCount == 1)
|
||||
{
|
||||
if (DisableSelfOnFirstUpdate)
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (DeactivateGameObjectOnFirstUpdate)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
LateUpdateCount += 1;
|
||||
SpawnPoint = new Vector3(SpawnPoint.X + 1.0f, SpawnPoint.Y, SpawnPoint.Z);
|
||||
ObservedLateDeltaTime = Time.deltaTime;
|
||||
|
||||
Vector3 position = transform.localPosition;
|
||||
position.x = position.x + 1.0f;
|
||||
transform.localPosition = position;
|
||||
ObservedLocalPosition = transform.localPosition;
|
||||
|
||||
Vector3 scale = transform.localScale;
|
||||
scale.x = scale.x + 1.0f;
|
||||
transform.localScale = scale;
|
||||
ObservedLocalScale = transform.localScale;
|
||||
|
||||
SpawnPoint.x = SpawnPoint.x + 1.0f;
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
|
||||
23
managed/GameScripts/TransformConversionProbe.cs
Normal file
23
managed/GameScripts/TransformConversionProbe.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class TransformConversionProbe : MonoBehaviour
|
||||
{
|
||||
public Vector3 ObservedWorldPoint;
|
||||
public Vector3 ObservedLocalPoint;
|
||||
public Vector3 ObservedWorldDirection;
|
||||
public Vector3 ObservedLocalDirection;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
transform.localPosition = new Vector3(5.0f, 0.0f, 1.0f);
|
||||
transform.localEulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
|
||||
|
||||
ObservedWorldPoint = transform.TransformPoint(new Vector3(0.0f, 0.0f, 2.0f));
|
||||
ObservedLocalPoint = transform.InverseTransformPoint(new Vector3(7.0f, 0.0f, 1.0f));
|
||||
ObservedWorldDirection = transform.TransformDirection(new Vector3(0.0f, 0.0f, 1.0f));
|
||||
ObservedLocalDirection = transform.InverseTransformDirection(new Vector3(1.0f, 0.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
41
managed/GameScripts/TransformMotionProbe.cs
Normal file
41
managed/GameScripts/TransformMotionProbe.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class TransformMotionProbe : MonoBehaviour
|
||||
{
|
||||
public Vector3 ObservedForward;
|
||||
public Vector3 ObservedRight;
|
||||
public Vector3 ObservedUp;
|
||||
public Vector3 ObservedPositionAfterSelfTranslate;
|
||||
public Vector3 ObservedPositionAfterWorldTranslate;
|
||||
public Vector3 ObservedForwardAfterWorldRotate;
|
||||
public Vector3 ObservedForwardAfterSelfRotate;
|
||||
public Vector3 ObservedForwardAfterLookAt;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
transform.localEulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
|
||||
|
||||
ObservedForward = transform.forward;
|
||||
ObservedRight = transform.right;
|
||||
ObservedUp = transform.up;
|
||||
|
||||
transform.Translate(new Vector3(0.0f, 0.0f, 2.0f));
|
||||
ObservedPositionAfterSelfTranslate = transform.position;
|
||||
|
||||
transform.Translate(new Vector3(0.0f, 0.0f, 3.0f), Space.World);
|
||||
ObservedPositionAfterWorldTranslate = transform.position;
|
||||
|
||||
transform.Rotate(new Vector3(0.0f, -90.0f, 0.0f), Space.World);
|
||||
ObservedForwardAfterWorldRotate = transform.forward;
|
||||
|
||||
transform.Rotate(new Vector3(0.0f, 90.0f, 0.0f));
|
||||
ObservedForwardAfterSelfRotate = transform.forward;
|
||||
|
||||
transform.LookAt(new Vector3(2.0f, 0.0f, 8.0f));
|
||||
ObservedForwardAfterLookAt = transform.forward;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
managed/GameScripts/TransformSpaceProbe.cs
Normal file
33
managed/GameScripts/TransformSpaceProbe.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class TransformSpaceProbe : MonoBehaviour
|
||||
{
|
||||
public Vector3 ObservedInitialWorldPosition;
|
||||
public Vector3 ObservedInitialWorldScale;
|
||||
public Vector3 ObservedInitialLocalEulerAngles;
|
||||
public Vector3 ObservedEulerAfterSet;
|
||||
public Vector3 ObservedWorldPositionAfterSet;
|
||||
public Vector3 ObservedWorldScaleAfterSet;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
ObservedInitialWorldPosition = transform.position;
|
||||
ObservedInitialWorldScale = transform.scale;
|
||||
ObservedInitialLocalEulerAngles = transform.localEulerAngles;
|
||||
|
||||
transform.localEulerAngles = new Vector3(0.0f, 45.0f, 0.0f);
|
||||
ObservedEulerAfterSet = transform.localEulerAngles;
|
||||
|
||||
transform.position = new Vector3(20.0f, 6.0f, 10.0f);
|
||||
ObservedWorldPositionAfterSet = transform.position;
|
||||
|
||||
Quaternion targetRotation = new Quaternion(0.0f, 0.5f, 0.0f, 0.8660254f);
|
||||
transform.rotation = targetRotation;
|
||||
|
||||
transform.scale = new Vector3(6.0f, 8.0f, 10.0f);
|
||||
ObservedWorldScaleAfterSet = transform.scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
managed/XCEngine.ScriptCore/Behaviour.cs
Normal file
21
managed/XCEngine.ScriptCore/Behaviour.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public class Behaviour : Component
|
||||
{
|
||||
internal ulong m_scriptComponentUUID = 0;
|
||||
|
||||
protected Behaviour()
|
||||
{
|
||||
}
|
||||
|
||||
public ulong ScriptComponentUUID => m_scriptComponentUUID;
|
||||
|
||||
public bool enabled
|
||||
{
|
||||
get => InternalCalls.Behaviour_GetEnabled(m_scriptComponentUUID);
|
||||
set => InternalCalls.Behaviour_SetEnabled(m_scriptComponentUUID, value);
|
||||
}
|
||||
|
||||
public bool isActiveAndEnabled => enabled && GameObject.activeInHierarchy;
|
||||
}
|
||||
}
|
||||
70
managed/XCEngine.ScriptCore/Camera.cs
Normal file
70
managed/XCEngine.ScriptCore/Camera.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public sealed class Camera : Component
|
||||
{
|
||||
internal Camera(ulong gameObjectUUID)
|
||||
: base(gameObjectUUID)
|
||||
{
|
||||
}
|
||||
|
||||
public float FieldOfView
|
||||
{
|
||||
get => InternalCalls.Camera_GetFieldOfView(GameObjectUUID);
|
||||
set => InternalCalls.Camera_SetFieldOfView(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float fieldOfView
|
||||
{
|
||||
get => FieldOfView;
|
||||
set => FieldOfView = value;
|
||||
}
|
||||
|
||||
public float NearClipPlane
|
||||
{
|
||||
get => InternalCalls.Camera_GetNearClipPlane(GameObjectUUID);
|
||||
set => InternalCalls.Camera_SetNearClipPlane(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float nearClipPlane
|
||||
{
|
||||
get => NearClipPlane;
|
||||
set => NearClipPlane = value;
|
||||
}
|
||||
|
||||
public float FarClipPlane
|
||||
{
|
||||
get => InternalCalls.Camera_GetFarClipPlane(GameObjectUUID);
|
||||
set => InternalCalls.Camera_SetFarClipPlane(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float farClipPlane
|
||||
{
|
||||
get => FarClipPlane;
|
||||
set => FarClipPlane = value;
|
||||
}
|
||||
|
||||
public float Depth
|
||||
{
|
||||
get => InternalCalls.Camera_GetDepth(GameObjectUUID);
|
||||
set => InternalCalls.Camera_SetDepth(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float depth
|
||||
{
|
||||
get => Depth;
|
||||
set => Depth = value;
|
||||
}
|
||||
|
||||
public bool Primary
|
||||
{
|
||||
get => InternalCalls.Camera_GetPrimary(GameObjectUUID);
|
||||
set => InternalCalls.Camera_SetPrimary(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public bool primary
|
||||
{
|
||||
get => Primary;
|
||||
set => Primary = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
managed/XCEngine.ScriptCore/Component.cs
Normal file
70
managed/XCEngine.ScriptCore/Component.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
public abstract class Component
|
||||
{
|
||||
internal ulong m_gameObjectUUID;
|
||||
|
||||
protected Component()
|
||||
{
|
||||
}
|
||||
|
||||
protected Component(ulong gameObjectUUID)
|
||||
{
|
||||
m_gameObjectUUID = gameObjectUUID;
|
||||
}
|
||||
|
||||
public ulong GameObjectUUID => m_gameObjectUUID;
|
||||
|
||||
public GameObject GameObject => new GameObject(m_gameObjectUUID);
|
||||
public GameObject gameObject => GameObject;
|
||||
|
||||
public Transform Transform => GameObject.Transform;
|
||||
public Transform transform => Transform;
|
||||
|
||||
public bool HasComponent<T>() where T : Component
|
||||
{
|
||||
return GameObject.HasComponent<T>();
|
||||
}
|
||||
|
||||
public T GetComponent<T>() where T : Component
|
||||
{
|
||||
return GameObject.GetComponent<T>();
|
||||
}
|
||||
|
||||
public bool TryGetComponent<T>(out T component) where T : Component
|
||||
{
|
||||
component = GetComponent<T>();
|
||||
return component != null;
|
||||
}
|
||||
|
||||
internal static T Create<T>(ulong gameObjectUUID) where T : Component
|
||||
{
|
||||
return Create(typeof(T), gameObjectUUID) as T;
|
||||
}
|
||||
|
||||
internal static Component Create(Type componentType, ulong gameObjectUUID)
|
||||
{
|
||||
if (componentType == null || gameObjectUUID == 0 || !typeof(Component).IsAssignableFrom(componentType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(
|
||||
componentType,
|
||||
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
|
||||
binder: null,
|
||||
args: new object[] { gameObjectUUID },
|
||||
culture: null) as Component;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
managed/XCEngine.ScriptCore/Debug.cs
Normal file
20
managed/XCEngine.ScriptCore/Debug.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public static class Debug
|
||||
{
|
||||
public static void Log(string message)
|
||||
{
|
||||
InternalCalls.Debug_Log(message ?? string.Empty);
|
||||
}
|
||||
|
||||
public static void LogWarning(string message)
|
||||
{
|
||||
InternalCalls.Debug_LogWarning(message ?? string.Empty);
|
||||
}
|
||||
|
||||
public static void LogError(string message)
|
||||
{
|
||||
InternalCalls.Debug_LogError(message ?? string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
managed/XCEngine.ScriptCore/GameObject.cs
Normal file
55
managed/XCEngine.ScriptCore/GameObject.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public sealed class GameObject
|
||||
{
|
||||
private readonly ulong m_uuid;
|
||||
|
||||
internal GameObject(ulong uuid)
|
||||
{
|
||||
m_uuid = uuid;
|
||||
}
|
||||
|
||||
public ulong UUID => m_uuid;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => InternalCalls.GameObject_GetName(UUID) ?? string.Empty;
|
||||
set => InternalCalls.GameObject_SetName(UUID, value ?? string.Empty);
|
||||
}
|
||||
|
||||
public string name
|
||||
{
|
||||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
|
||||
public bool activeSelf => InternalCalls.GameObject_GetActiveSelf(UUID);
|
||||
|
||||
public bool activeInHierarchy => InternalCalls.GameObject_GetActiveInHierarchy(UUID);
|
||||
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
InternalCalls.GameObject_SetActive(UUID, value);
|
||||
}
|
||||
|
||||
public Transform Transform => GetComponent<Transform>();
|
||||
public Transform transform => Transform;
|
||||
|
||||
public bool HasComponent<T>() where T : Component
|
||||
{
|
||||
return InternalCalls.GameObject_HasComponent(UUID, typeof(T));
|
||||
}
|
||||
|
||||
public T GetComponent<T>() where T : Component
|
||||
{
|
||||
ulong componentOwnerUUID = InternalCalls.GameObject_GetComponent(UUID, typeof(T));
|
||||
return Component.Create<T>(componentOwnerUUID);
|
||||
}
|
||||
|
||||
public bool TryGetComponent<T>(out T component) where T : Component
|
||||
{
|
||||
component = GetComponent<T>();
|
||||
return component != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
185
managed/XCEngine.ScriptCore/InternalCalls.cs
Normal file
185
managed/XCEngine.ScriptCore/InternalCalls.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
internal static class InternalCalls
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Debug_Log(string message);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Debug_LogWarning(string message);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Debug_LogError(string message);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Time_GetDeltaTime();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern string GameObject_GetName(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void GameObject_SetName(ulong gameObjectUUID, string name);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool GameObject_GetActiveSelf(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool GameObject_GetActiveInHierarchy(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void GameObject_SetActive(ulong gameObjectUUID, bool active);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool GameObject_HasComponent(ulong gameObjectUUID, Type componentType);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern ulong GameObject_GetComponent(ulong gameObjectUUID, Type componentType);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool Behaviour_GetEnabled(ulong scriptComponentUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Behaviour_SetEnabled(ulong scriptComponentUUID, bool enabled);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetLocalPosition(ulong gameObjectUUID, out Vector3 position);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetLocalPosition(ulong gameObjectUUID, ref Vector3 position);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetLocalRotation(ulong gameObjectUUID, out Quaternion rotation);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetLocalRotation(ulong gameObjectUUID, ref Quaternion rotation);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetLocalScale(ulong gameObjectUUID, out Vector3 scale);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetLocalScale(ulong gameObjectUUID, ref Vector3 scale);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetLocalEulerAngles(ulong gameObjectUUID, out Vector3 eulerAngles);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetLocalEulerAngles(ulong gameObjectUUID, ref Vector3 eulerAngles);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetPosition(ulong gameObjectUUID, out Vector3 position);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetPosition(ulong gameObjectUUID, ref Vector3 position);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetRotation(ulong gameObjectUUID, out Quaternion rotation);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetRotation(ulong gameObjectUUID, ref Quaternion rotation);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetScale(ulong gameObjectUUID, out Vector3 scale);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetScale(ulong gameObjectUUID, ref Vector3 scale);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetForward(ulong gameObjectUUID, out Vector3 forward);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetRight(ulong gameObjectUUID, out Vector3 right);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_GetUp(ulong gameObjectUUID, out Vector3 up);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_Translate(ulong gameObjectUUID, ref Vector3 translation, int relativeTo);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_Rotate(ulong gameObjectUUID, ref Vector3 eulers, int relativeTo);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_LookAt(ulong gameObjectUUID, ref Vector3 target);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_TransformPoint(ulong gameObjectUUID, ref Vector3 point, out Vector3 transformedPoint);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_InverseTransformPoint(ulong gameObjectUUID, ref Vector3 point, out Vector3 transformedPoint);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_TransformDirection(ulong gameObjectUUID, ref Vector3 direction, out Vector3 transformedDirection);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_InverseTransformDirection(ulong gameObjectUUID, ref Vector3 direction, out Vector3 transformedDirection);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern ulong Transform_GetParent(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Transform_SetParent(ulong gameObjectUUID, ulong parentGameObjectUUID, bool worldPositionStays);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern int Transform_GetChildCount(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern ulong Transform_GetChild(ulong gameObjectUUID, int index);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Camera_GetFieldOfView(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Camera_SetFieldOfView(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Camera_GetNearClipPlane(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Camera_SetNearClipPlane(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Camera_GetFarClipPlane(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Camera_SetFarClipPlane(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Camera_GetDepth(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Camera_SetDepth(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool Camera_GetPrimary(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Camera_SetPrimary(ulong gameObjectUUID, bool value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Light_GetIntensity(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Light_SetIntensity(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Light_GetRange(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Light_SetRange(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern float Light_GetSpotAngle(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Light_SetSpotAngle(ulong gameObjectUUID, float value);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool Light_GetCastsShadows(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Light_SetCastsShadows(ulong gameObjectUUID, bool value);
|
||||
}
|
||||
}
|
||||
58
managed/XCEngine.ScriptCore/Light.cs
Normal file
58
managed/XCEngine.ScriptCore/Light.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public sealed class Light : Component
|
||||
{
|
||||
internal Light(ulong gameObjectUUID)
|
||||
: base(gameObjectUUID)
|
||||
{
|
||||
}
|
||||
|
||||
public float Intensity
|
||||
{
|
||||
get => InternalCalls.Light_GetIntensity(GameObjectUUID);
|
||||
set => InternalCalls.Light_SetIntensity(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float intensity
|
||||
{
|
||||
get => Intensity;
|
||||
set => Intensity = value;
|
||||
}
|
||||
|
||||
public float Range
|
||||
{
|
||||
get => InternalCalls.Light_GetRange(GameObjectUUID);
|
||||
set => InternalCalls.Light_SetRange(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float range
|
||||
{
|
||||
get => Range;
|
||||
set => Range = value;
|
||||
}
|
||||
|
||||
public float SpotAngle
|
||||
{
|
||||
get => InternalCalls.Light_GetSpotAngle(GameObjectUUID);
|
||||
set => InternalCalls.Light_SetSpotAngle(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public float spotAngle
|
||||
{
|
||||
get => SpotAngle;
|
||||
set => SpotAngle = value;
|
||||
}
|
||||
|
||||
public bool CastsShadows
|
||||
{
|
||||
get => InternalCalls.Light_GetCastsShadows(GameObjectUUID);
|
||||
set => InternalCalls.Light_SetCastsShadows(GameObjectUUID, value);
|
||||
}
|
||||
|
||||
public bool castsShadows
|
||||
{
|
||||
get => CastsShadows;
|
||||
set => CastsShadows = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public class MonoBehaviour
|
||||
public class MonoBehaviour : Behaviour
|
||||
{
|
||||
public ulong GameObjectUUID;
|
||||
public ulong ScriptComponentUUID;
|
||||
}
|
||||
}
|
||||
|
||||
45
managed/XCEngine.ScriptCore/Quaternion.cs
Normal file
45
managed/XCEngine.ScriptCore/Quaternion.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Quaternion
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public float W;
|
||||
|
||||
public float x
|
||||
{
|
||||
get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
public float y
|
||||
{
|
||||
get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
public float z
|
||||
{
|
||||
get => Z;
|
||||
set => Z = value;
|
||||
}
|
||||
|
||||
public float w
|
||||
{
|
||||
get => W;
|
||||
set => W = value;
|
||||
}
|
||||
|
||||
public Quaternion(float x, float y, float z, float w)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
W = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
8
managed/XCEngine.ScriptCore/Space.cs
Normal file
8
managed/XCEngine.ScriptCore/Space.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public enum Space
|
||||
{
|
||||
Self = 0,
|
||||
World = 1,
|
||||
}
|
||||
}
|
||||
7
managed/XCEngine.ScriptCore/Time.cs
Normal file
7
managed/XCEngine.ScriptCore/Time.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public static class Time
|
||||
{
|
||||
public static float deltaTime => InternalCalls.Time_GetDeltaTime();
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
managed/XCEngine.ScriptCore/Vector2.cs
Normal file
29
managed/XCEngine.ScriptCore/Vector2.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector2
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
|
||||
public float x
|
||||
{
|
||||
get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
public float y
|
||||
{
|
||||
get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
public Vector2(float x, float y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
managed/XCEngine.ScriptCore/Vector3.cs
Normal file
37
managed/XCEngine.ScriptCore/Vector3.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector3
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
|
||||
public float x
|
||||
{
|
||||
get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
public float y
|
||||
{
|
||||
get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
public float z
|
||||
{
|
||||
get => Z;
|
||||
set => Z = value;
|
||||
}
|
||||
|
||||
public Vector3(float x, float y, float z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
managed/XCEngine.ScriptCore/Vector4.cs
Normal file
45
managed/XCEngine.ScriptCore/Vector4.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector4
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public float W;
|
||||
|
||||
public float x
|
||||
{
|
||||
get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
public float y
|
||||
{
|
||||
get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
public float z
|
||||
{
|
||||
get => Z;
|
||||
set => Z = value;
|
||||
}
|
||||
|
||||
public float w
|
||||
{
|
||||
get => W;
|
||||
set => W = value;
|
||||
}
|
||||
|
||||
public Vector4(float x, float y, float z, float w)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
W = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user