diff --git a/Nuake/src/Scripting/NetModules/InputNetAPI.cpp b/Nuake/src/Scripting/NetModules/InputNetAPI.cpp index 32b41358..20a2a866 100644 --- a/Nuake/src/Scripting/NetModules/InputNetAPI.cpp +++ b/Nuake/src/Scripting/NetModules/InputNetAPI.cpp @@ -18,6 +18,11 @@ namespace Nuake { } } + bool IsMouseButtonDown(int keyCode) + { + return Input::IsMouseButtonDown(keyCode); + } + bool IsKeyDown(int keyCode) { return Input::IsKeyDown(keyCode); @@ -41,6 +46,7 @@ namespace Nuake { RegisterMethod("Input.IsKeyDownIcall", &IsKeyDown); RegisterMethod("Input.IsKeyPressedIcall", &IsKeyPressed); + RegisterMethod("Input.IsMouseButtonDownIcall", &IsMouseButtonDown); RegisterMethod("Input.GetMousePositionIcall", &GetMousePosition); } diff --git a/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp b/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp index cc19cf58..2fd35877 100644 --- a/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp +++ b/Nuake/src/Scripting/NetModules/SceneNetAPI.cpp @@ -137,6 +137,19 @@ namespace Nuake { } } + Coral::Array TransformGetPosition(int entityId) + { + Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() }; + + if (entity.IsValid() && entity.HasComponent()) + { + auto& component = entity.GetComponent(); + const auto& position = component.GetLocalPosition(); + Coral::Array result = Coral::Array::New({ position.x, position.y, position.z }); + return result; + } + } + Coral::Array TransformGetGlobalPosition(int entityId) { Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() }; @@ -239,6 +252,7 @@ namespace Nuake { // Components RegisterMethod("TransformComponent.SetPositionIcall", &TransformSetPosition); + RegisterMethod("TransformComponent.GetPositionIcall", &TransformGetPosition); RegisterMethod("TransformComponent.GetGlobalPositionIcall", &TransformGetGlobalPosition); RegisterMethod("TransformComponent.RotateIcall", &TransformRotate); diff --git a/NuakeNet/src/Components.cs b/NuakeNet/src/Components.cs index 5bb6be0b..36a7273d 100644 --- a/NuakeNet/src/Components.cs +++ b/NuakeNet/src/Components.cs @@ -52,6 +52,7 @@ namespace Nuake.Net public class TransformComponent : IComponent { internal static unsafe delegate*> GetGlobalPositionIcall; + internal static unsafe delegate*> GetPositionIcall; internal static unsafe delegate* SetPositionIcall; internal static unsafe delegate* RotateIcall; @@ -83,7 +84,14 @@ namespace Nuake.Net public Vector3 LocalPosition { - get { return new Vector3(); } + get + { + unsafe + { + NativeArray result = GetPositionIcall(EntityID); + return new Vector3(result[0], result[1], result[2]); + } + } set { unsafe { SetPositionIcall(EntityID, value.X, value.Y, value.Z); } diff --git a/NuakeNet/src/Input.cs b/NuakeNet/src/Input.cs index 23183e59..5f536c4a 100644 --- a/NuakeNet/src/Input.cs +++ b/NuakeNet/src/Input.cs @@ -132,13 +132,31 @@ namespace Nuake.Net MENU = 348, } + public enum MouseButton + { + BUTTON_LEFT = 0, + BUTTON_RIGHT = 1, + BUTTON_MIDDLE = 2, + BUTTON_4 = 3, + BUTTON_5 = 4, + BUTTON_6 = 5, + BUTTON_7 = 6, + BUTTON_8 = 7, + } + public class Input { internal static unsafe delegate* ShowMouseIcall; internal static unsafe delegate* IsKeyDownIcall; internal static unsafe delegate* IsKeyPressedIcall; + internal static unsafe delegate* IsMouseButtonDownIcall; internal static unsafe delegate*> GetMousePositionIcall; + public static bool IsMouseButtonDown(MouseButton button) + { + unsafe { return IsMouseButtonDownIcall((int)button); } + } + public static void ShowMouse(bool visible) { unsafe { ShowMouseIcall(visible); }