From 7a3318e5f66987ec5e6f471c8a0bb93ba00bf47d Mon Sep 17 00:00:00 2001 From: Dustin Date: Wed, 7 May 2025 21:07:31 -0700 Subject: [PATCH] Prepping for new model. --- lib/classes/movement_state_receiver.gd | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/classes/movement_state_receiver.gd b/lib/classes/movement_state_receiver.gd index 6de7889..90b8479 100644 --- a/lib/classes/movement_state_receiver.gd +++ b/lib/classes/movement_state_receiver.gd @@ -380,6 +380,39 @@ func is_out_of_range(value: float, a: float, b: float) -> bool: var upper = max(a, b) return value <= lower or value >= upper +enum RANGE_PLACEMENT { + BEFORE_RANGE, + WITHIN_RANGE, + PAST_RANGE +} + +## Determine the trend of direction and where our current speed is +# in relation to it. This should help determine the direction of +# acceleration and whether we speed up or slow down. +## +func placement_to_speed_range(speed: float, speed_range: Vector2) -> int: + ## Actually we don't care about mix or min + #var range_start :float = min(speed_range.x, speed_range.y) + #var range_end :float = max(speed_range.x, speed_range.y) + + ## We can be at the base range to ensure impulse can happen + ## Direction <-- that way + if speed_range.x > speed_range.y: + if speed < speed_range.x and speed >= speed_range.y: + return RANGE_PLACEMENT.WITHIN_RANGE + elif speed < speed_range.y: + return RANGE_PLACEMENT.PAST_RANGE + else: + return RANGE_PLACEMENT.BEFORE_RANGE + else: ## Direction --> that way + if speed > speed_range.x and speed <= speed_range.y: + return RANGE_PLACEMENT.WITHIN_RANGE + elif speed > speed_range.y: + return RANGE_PLACEMENT.PAST_RANGE + else: + return RANGE_PLACEMENT.BEFORE_RANGE + return 0 + ## Passed in acceleration, vel, etc is applied to whatever ## the parent is. If Kinematic then move_and_slide, otherwise manually adjusted func apply_movement_to_parent( _velocity :Vector2) -> void: