Added ShowMouse and get global position to .net api, deferred onInit after all entities have been initialized

This commit is contained in:
Antoine Pilote
2024-03-16 16:37:38 -04:00
parent a5ca094c5f
commit 69205ec4fa
6 changed files with 61 additions and 7 deletions

View File

@@ -6,6 +6,18 @@
namespace Nuake {
void ShowMouse(bool visible)
{
if (visible)
{
Input::ShowMouse();
}
else
{
Input::HideMouse();
}
}
bool IsKeyDown(int keyCode)
{
return Input::IsKeyDown(keyCode);
@@ -25,6 +37,7 @@ namespace Nuake {
void InputNetAPI::RegisterMethods()
{
RegisterMethod("Input.ShowMouseIcall", &ShowMouse);
RegisterMethod("Input.IsKeyDownIcall", &IsKeyDown);
RegisterMethod("Input.IsKeyPressedIcall", &IsKeyPressed);

View File

@@ -115,6 +115,19 @@ namespace Nuake {
}
}
Coral::NativeArray<float> TransformGetGlobalPosition(int entityId)
{
Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() };
if (entity.IsValid() && entity.HasComponent<TransformComponent>())
{
auto& component = entity.GetComponent<TransformComponent>();
const auto& globalPosition = component.GetGlobalPosition();
Coral::NativeArray<float> result = { globalPosition.x, globalPosition.y, globalPosition.z };
return result;
}
}
void TransformRotate(int entityId, float x, float y, float z)
{
Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() };
@@ -203,6 +216,7 @@ namespace Nuake {
// Components
RegisterMethod("TransformComponent.SetPositionIcall", &TransformSetPosition);
RegisterMethod("TransformComponent.GetGlobalPositionIcall", &TransformGetGlobalPosition);
RegisterMethod("TransformComponent.RotateIcall", &TransformRotate);
RegisterMethod("CameraComponent.GetDirectionIcall", &CameraGetDirection);