Skip to content

Commit

Permalink
FLUDD, First Steps
Browse files Browse the repository at this point in the history
- Added the FluddManager class that handles the nozzle types, the available nozzles, and the active nozzle.
- Added a way to switch between FLUDD nozzles. (Code only, no implementation)
- Gave every PlayerState a reference to the FluddManager through a descendant line. (See PlayerStateManager)
  • Loading branch information
Charpurrr committed Sep 1, 2024
1 parent fea8aea commit d63ab55
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 46 deletions.
2 changes: 1 addition & 1 deletion addons/rmsmartshape/materials/shape_material.gd
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ func set_fill_texture_angle_offset(value: float) -> void:

func set_fill_texture_absolute_position(value: bool) -> void:
fill_texture_absolute_position = value
emit_changed()
emit_changed()
28 changes: 12 additions & 16 deletions entities/player/mario/mario.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=363 format=3 uid="uid://dgqp3sqvmcvpu"]
[gd_scene load_steps=364 format=3 uid="uid://dgqp3sqvmcvpu"]

[ext_resource type="Script" path="res://entities/player/shared/player.gd" id="1_87j6i"]
[ext_resource type="Texture2D" uid="uid://bbgppbst4akvn" path="res://entities/player/mario/anime/backflip.png" id="2_i2o54"]
Expand Down Expand Up @@ -129,7 +129,7 @@
[ext_resource type="Script" path="res://entities/player/shared/states/dry/airborne/fall_states/fall.gd" id="113_j3k6p"]
[ext_resource type="Script" path="res://entities/player/shared/states/dry/airborne/fall_states/freefall.gd" id="114_mgnux"]
[ext_resource type="AudioStream" uid="uid://1fibybjdw7pc" path="res://entities/player/shared/motion_nsmbw/groundpound.wav" id="116_078t4"]
[ext_resource type="Script" path="res://entities/player/shared/states/dry/airborne/fall_states/water_exit.gd" id="116_wolak"]
[ext_resource type="Script" path="res://entities/player/shared/states/dry/airborne/lazy_jump.gd" id="116_wolak"]
[ext_resource type="AudioStream" uid="uid://23at2s4l6qjv" path="res://entities/player/mario/voice/watch_it.wav" id="120_qvxml"]
[ext_resource type="AudioStream" uid="uid://lktt3ecwf5nm" path="res://entities/player/mario/voice/oh_surprised.wav" id="121_se657"]
[ext_resource type="AudioStream" uid="uid://udnnj6t7h54x" path="res://entities/player/mario/voice/mhpm.wav" id="122_r00kr"]
Expand All @@ -150,6 +150,7 @@
[ext_resource type="AudioStream" uid="uid://bbw3474fd3uxc" path="res://entities/player/shared/motion/spinattack_shine.wav" id="136_a6kal"]
[ext_resource type="AudioStream" uid="uid://bowyc14wpkcra" path="res://entities/player/shared/motion/dive.wav" id="138_88upi"]
[ext_resource type="Script" path="res://entities/player/shared/states/dry/butt_slide.gd" id="140_lfmwr"]
[ext_resource type="Script" path="res://entities/player/shared/fludd_manager.gd" id="151_4womg"]

[sub_resource type="AtlasTexture" id="AtlasTexture_8n85e"]
atlas = ExtResource("2_i2o54")
Expand Down Expand Up @@ -2030,6 +2031,9 @@ target_position = Vector2(-9, 0)
script = ExtResource("21_onm15")
buffer_duration = 6

[node name="FluddManager" type="Node" parent="."]
script = ExtResource("151_4womg")

[node name="Movement" type="Node" parent="." node_paths=PackedStringArray("actor")]
script = ExtResource("37_quca3")
actor = NodePath("..")
Expand All @@ -2040,12 +2044,8 @@ snap_length = 8.0
swim_speed = 3.0
min_slide_incline = 0.4

[node name="StateManager" type="Node" parent="." node_paths=PackedStringArray("input", "movement", "target_actor", "initial_state")]
[node name="StateManager" type="Node" parent="."]
script = ExtResource("38_vxs65")
input = NodePath("../InputManager")
movement = NodePath("../Movement")
target_actor = NodePath("..")
initial_state = NodePath("Dry/Airborne")

[node name="Submerged" type="Node" parent="StateManager"]
script = ExtResource("135_2utkk")
Expand Down Expand Up @@ -2191,6 +2191,11 @@ animation = &"triple_jump"
anim_offset = Vector2i(0, 5)
sfx_layers = Array[ExtResource("49_apkmk")]([SubResource("Resource_c6n5s"), SubResource("Resource_0beus"), SubResource("Resource_32052")])

[node name="LazyJump" type="Node" parent="StateManager/Dry/Airborne/JumpStates"]
script = ExtResource("116_wolak")
animation = &"jump"
anim_offset = Vector2i(0, 5)

[node name="Spinjump" type="Node" parent="StateManager/Dry/Airborne/JumpStates"]
script = ExtResource("92_pwmyp")
jump_power = 6.7
Expand Down Expand Up @@ -2275,13 +2280,6 @@ script = ExtResource("114_mgnux")
animation = &"freefall"
sfx_layers = Array[ExtResource("49_apkmk")]([SubResource("Resource_5kqsg")])

[node name="WaterExit" type="Node" parent="StateManager/Dry/Airborne/FallStates"]
script = ExtResource("116_wolak")
animation_jump = &"jump"
anim_offset_j = Vector2(0, 5)
animation = &"jump_fall"
anim_offset = Vector2i(0, 5)

[node name="DoubleFall" type="Node" parent="StateManager/Dry/Airborne/FallStates"]
script = ExtResource("113_j3k6p")
animation = &"double_fall"
Expand Down Expand Up @@ -2358,6 +2356,4 @@ animation_airborne = &"butt_slide_jump"
hitbox_type = "Small"
animation = &"butt_slide"

[node name="FluddManager" type="Node" parent="."]

[connection signal="body_entered" from="Areas/SpinHitbox" to="StateManager/Dry/Spin" method="_on_spin_hitbox_body_entered"]
33 changes: 33 additions & 0 deletions entities/player/shared/fludd_manager.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class_name FluddManager
extends Node
## Handles communication between PlayerStates in regards to FLUDD.

enum Nozzle{
NONE,
HOVER,
ROCKET,
TURBO,
}

var available_nozzles: Array[Nozzle] = [
Nozzle.NONE,
Nozzle.HOVER,
#Nozzle.ROCKET,
#Nozzle.TURBO,
]

var active_nozzle: Nozzle = Nozzle.NONE


# Done within physics process to guarantee being properly synced with the player.
func _physics_process(_delta: float) -> void:
if Input.is_action_just_pressed(&"switch_nozzle"):
switch_nozzle()


func switch_nozzle() -> void:
var current_id: int = available_nozzles.find(active_nozzle)

active_nozzle = available_nozzles[wrapi(current_id + 1, 0, available_nozzles.size())]

print(Nozzle.find_key(active_nozzle))
2 changes: 2 additions & 0 deletions entities/player/shared/player_state_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ extends StateManager
## Adds player specialised variables and functions.

@export var input: InputManager
@export var fludd: FluddManager
@export var movement: PMovement


func _custom_passdowns() -> Dictionary:
return {
&"input": input,
&"fludd": fludd,
&"movement": movement,
}

This file was deleted.

26 changes: 26 additions & 0 deletions entities/player/shared/states/dry/airborne/lazy_jump.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class_name LazyJump
extends Fall
## A jump that doesn't give you any height.
## Used for actions that look like jumps but don't act like them.


func _trans_rules() -> Variant:
if not movement.dived and movement.can_air_action() and input.buffered_input(&"dive"):
return &"Dive"

if movement.can_spin() and input.buffered_input(&"spin"):
return &"Spin"

if Input.is_action_just_pressed(&"groundpound") and movement.can_air_action():
return &"GroundPound"

if actor.push_rays.is_colliding() and input.buffered_input(&"jump"):
return [&"Walljump", -movement.facing_direction]

if movement.can_init_wallslide():
return &"Wallslide"

if actor.vel.y > 0:
return &"Fall"

return &""
2 changes: 1 addition & 1 deletion entities/player/shared/states/dry/dry.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ func _trans_rules():


func _defer_rules():
return &"WaterExit"
return &"LazyJump"
5 changes: 3 additions & 2 deletions entities/player/shared/states/player_state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ extends State
## sound effects it can cycle through.
@export var sfx_layers: Array[SFXLayer]

@onready var input: InputManager = null
@onready var movement: PMovement = null
var input: InputManager = null
var fludd: FluddManager = null
var movement: PMovement = null


func trigger_enter(handover):
Expand Down
10 changes: 10 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ e_pin_hotbar_item={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
switch_nozzle={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null)
]
}
use_fludd={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
]
}

[layer_names]

Expand Down
11 changes: 5 additions & 6 deletions ui/ui.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,6 @@ layout_mode = 2
texture = ExtResource("5_cgoe6")

[node name="PauseScreen" type="Control" parent="." node_paths=PackedStringArray("choices", "pause_menu", "settings_menu")]
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
Expand Down Expand Up @@ -2340,22 +2339,22 @@ texture = ExtResource("19_wa1aj")
expand_mode = 1
stretch_mode = 5

[node name="Turbo" type="TextureRect" parent="PauseScreen/PauseMenu/Info/Contents/Bottom/ActiveNozzles/Icons"]
[node name="Rocket" type="TextureRect" parent="PauseScreen/PauseMenu/Info/Contents/Bottom/ActiveNozzles/Icons"]
modulate = Color(0, 0, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
texture = ExtResource("20_yd3bl")
texture = ExtResource("21_xk5tc")
expand_mode = 1
stretch_mode = 5

[node name="Rocket" type="TextureRect" parent="PauseScreen/PauseMenu/Info/Contents/Bottom/ActiveNozzles/Icons"]
[node name="Turbo" type="TextureRect" parent="PauseScreen/PauseMenu/Info/Contents/Bottom/ActiveNozzles/Icons"]
modulate = Color(0, 0, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 0.5
texture = ExtResource("21_xk5tc")
size_flags_stretch_ratio = 0.7
texture = ExtResource("20_yd3bl")
expand_mode = 1
stretch_mode = 5

Expand Down

0 comments on commit d63ab55

Please sign in to comment.