mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Aadded GetLocalPosition and IsMouseButtonDown to .Net API
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,19 @@ namespace Nuake {
|
||||
}
|
||||
}
|
||||
|
||||
Coral::Array<float> TransformGetPosition(int entityId)
|
||||
{
|
||||
Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() };
|
||||
|
||||
if (entity.IsValid() && entity.HasComponent<TransformComponent>())
|
||||
{
|
||||
auto& component = entity.GetComponent<TransformComponent>();
|
||||
const auto& position = component.GetLocalPosition();
|
||||
Coral::Array<float> result = Coral::Array<float>::New({ position.x, position.y, position.z });
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Coral::Array<float> 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);
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Nuake.Net
|
||||
public class TransformComponent : IComponent
|
||||
{
|
||||
internal static unsafe delegate*<int, NativeArray<float>> GetGlobalPositionIcall;
|
||||
internal static unsafe delegate*<int, NativeArray<float>> GetPositionIcall;
|
||||
internal static unsafe delegate*<int, float, float, float, void> SetPositionIcall;
|
||||
internal static unsafe delegate*<int, float, float, float, void> RotateIcall;
|
||||
|
||||
@@ -83,7 +84,14 @@ namespace Nuake.Net
|
||||
|
||||
public Vector3 LocalPosition
|
||||
{
|
||||
get { return new Vector3(); }
|
||||
get
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
NativeArray<float> result = GetPositionIcall(EntityID);
|
||||
return new Vector3(result[0], result[1], result[2]);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
unsafe { SetPositionIcall(EntityID, value.X, value.Y, value.Z); }
|
||||
|
||||
@@ -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*<bool, void> ShowMouseIcall;
|
||||
internal static unsafe delegate*<int, bool> IsKeyDownIcall;
|
||||
internal static unsafe delegate*<int, bool> IsKeyPressedIcall;
|
||||
internal static unsafe delegate*<int, bool> IsMouseButtonDownIcall;
|
||||
internal static unsafe delegate*<NativeArray<float>> GetMousePositionIcall;
|
||||
|
||||
public static bool IsMouseButtonDown(MouseButton button)
|
||||
{
|
||||
unsafe { return IsMouseButtonDownIcall((int)button); }
|
||||
}
|
||||
|
||||
public static void ShowMouse(bool visible)
|
||||
{
|
||||
unsafe { ShowMouseIcall(visible); }
|
||||
|
||||
Reference in New Issue
Block a user