Set up framework for more advance pickup behaviours.

This commit is contained in:
Henry Faber 2026-07-02 15:44:23 +01:00
parent a0df0be862
commit 935b61bd3b
16 changed files with 485 additions and 20 deletions

View file

@ -0,0 +1,47 @@
class_name PickupDriftBehavior extends Resource
## Base resource that defines the global travel pattern of a pickup across
## the screen. Assign to [member drift_behavior] on a PickupBehaviorController.
enum DriftType {
STATIONARY, ## Does not move (aside from bob/shake).
SINE_WAVE, ## Travels in a sine curve.
LEAF_FALL, ## Drifts downward with gentle horizontal sway.
DIAGONAL, ## Moves diagonally in one direction.
}
@export_group("Drift")
## The drift pattern to apply.
@export var drift_type: DriftType = DriftType.STATIONARY
## Horizontal speed in pixels per second (applies to SINE_WAVE, LEAF_FALL).
@export var drift_speed: float = 30.0
## Vertical fall speed in pixels per second (applies to LEAF_FALL).
@export var fall_speed: float = 15.0
## Horizontal wave amplitude in pixels (applies to SINE_WAVE, LEAF_FALL).
@export var wave_amplitude: float = 40.0
## Wave frequency in cycles per second (applies to SINE_WAVE, LEAF_FALL).
@export var wave_frequency: float = 1.0
## Diagonal direction: +X forward, -X backward (applies to DIAGONAL).
@export var diagonal_forward: bool = true
## Main drift axis for SINE_WAVE and LEAF_FALL.
## true = horizontal travel (x), false = vertical travel (y).
@export var drift_along_x: bool = true
## Reverse the primary direction (left/right or up/down).
@export var reverse_direction: bool = false
## Randomize the perpendicular axis origin (y if horizontal, x if vertical).
@export var randomize_origin: bool = false
## Phase offset in radians — randomize per-instance for variety.
@export var phase_offset: float = 0.0
var _initial_x: float = 0.0
func reset(initial_position: Vector2) -> void:
_initial_x = initial_position.x