From f8b13ff533e6eae7d31ca71a78cc4da61348ead2 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sat, 7 Dec 2024 15:33:59 -0500 Subject: [PATCH] grab interaction system --- src/Mono.cs | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/Mono.cs b/src/Mono.cs index 22e7e8f..d3b9ca7 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -9,7 +9,12 @@ static class Mono public static int score; - public static Pose world_pose; + // to be wrapped in a dof base class + public static Pose dof_pose; + public static float dof_scl; + // custom inside data/class + public static Grab to_grab; + public static Grab from_grab; public static DeltaBool menu; public static Pose menu_pose; @@ -26,11 +31,15 @@ static class Mono public static void Init() { game_time = 0.0; - world_pose = new(0, -1, -2); menu = new(false); menu_pose = new(0, 0, 0); menu_scale = 1 * U.cm; mode = Mode.Mount; + + dof_pose = new(0, 0, 0); // new(0, -1, -2); + dof_scl = 1.0f; // 0.1f; + to_grab = new(); + from_grab = new(); } public static void Frame() @@ -90,5 +99,58 @@ static class Mono // break; // } } + + Grab[] grabs = new Grab[] + { + to_grab, + from_grab + }; + foreach (var grab in grabs) + { + if (!grab.Held) + { + if (Rig.l_held == null) + { + if (Rig.btn_l_grip.delta == +1) + { + grab.OnGrab(ref Rig.l_hnd, ref Rig.l_held); + } + } + } + else + { + if (Rig.l_held == grab) + { + if (Rig.btn_l_grip.delta == -1) + { + grab.OnRelease(); + Rig.l_held = null; + } + } + } + if (!grab.Held) + { + if (Rig.r_held == null) + { + if (Rig.btn_r_grip.delta == +1) + { + grab.OnGrab(ref Rig.r_hnd, ref Rig.r_held); + } + } + } + else + { + if (Rig.r_held == grab) + { + if (Rig.btn_r_grip.delta == -1) + { + grab.OnRelease(); + Rig.r_held = null; + } + } + } + + grab.Frame(); + } } }