Refactor systems to use EventBus for communication

- Removed direct dependencies on GameState in multiple systems, replacing them with EventBus for event-driven architecture.
- Updated CameraShakeSystem to handle focus changes and trauma through EventBus.
- Modified DeadliftSystem to manage lift efforts and hazards using EventBus.
- Refactored GameManager to handle lift results and day transitions via EventBus.
- Adjusted HazardController and HazardSystem to publish and respond to hazard events through EventBus.
- Enhanced PlayerInputSystem to publish lift efforts and focus releases using EventBus.
- Updated SoundManager to handle various audio events through EventBus, improving sound management.
- Refined TunnelSystem to manage focus changes and lift efforts using EventBus.
- Adjusted LiftProgressBar to update progress based on events from EventBus.
- Enhanced LiftSyncController to synchronize animations based on lift efforts and focus events via EventBus.
This commit is contained in:
2026-01-24 18:15:34 +01:00
parent 140e0f1cff
commit 266fa4ac1d
24 changed files with 738 additions and 540 deletions

View File

@@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://bqowx0vi3prqw"]
[node name="EventBus" type="EventBus"]

View File

@@ -12,3 +12,5 @@ macos.debug = "res://../rust/target/debug/libmax_effort_lib.dylib"
macos.release = "res://../rust/target/release/libmax_effort_lib.dylib"
macos.debug.arm64 = "res://../rust/target/debug/libmax_effort_lib.dylib"
macos.release.arm64 = "res://../rust/target/release/libmax_effort_lib.dylib"
web.debug.wasm32 = "res://../rust/target/wasm32-unknown-emscripten/debug/libmax_effort_lib.wasm"
web.release.wasm32 = "res://../rust/target/wasm32-unknown-emscripten/release/libmax_effort_lib.wasm"

View File

@@ -1,6 +1,5 @@
[gd_scene load_steps=5 format=3 uid="uid://dxq2510ywj1hy"]
[ext_resource type="GameState" uid="uid://2gma8vvisnqo" path="res://Resources/GameState.tres" id="1_tik8c"]
[ext_resource type="PackedScene" uid="uid://dn8y3bgovnh4a" path="res://Objects/bench_press_stickman.tscn" id="2_0c1tm"]
[ext_resource type="Texture2D" uid="uid://dsovna2tmb4o3" path="res://Sprites/bench.png" id="2_ky8t4"]
[ext_resource type="Texture2D" uid="uid://cbgn8aspf7oi0" path="res://Sprites/barbell.png" id="3_ky8t4"]
@@ -8,7 +7,6 @@
[node name="BenchPress" type="Node"]
[node name="System" type="BenchPressSystem" parent="."]
game_state = ExtResource("1_tik8c")
[node name="Bench" type="Sprite2D" parent="."]
position = Vector2(11, 1)
@@ -25,6 +23,5 @@ texture = ExtResource("3_ky8t4")
[node name="LiftSyncController" type="LiftSyncController" parent="." node_paths=PackedStringArray("player_anim", "barbell")]
player_anim = NodePath("../BenchPressStickman")
barbell = NodePath("../Barbell")
game_state = ExtResource("1_tik8c")
animation_name = "default"
bar_positions = Array[Vector2]([Vector2(19, -5), Vector2(19, -19), Vector2(21, -36), Vector2(21, -15), Vector2(23, 3), Vector2(22, 11), Vector2(22, -1), Vector2(22, -1)])

View File

@@ -1,6 +1,5 @@
[gd_scene load_steps=3 format=3 uid="uid://dx1k40qfioaas"]
[ext_resource type="GameState" uid="uid://2gma8vvisnqo" path="res://Resources/GameState.tres" id="1_n6ace"]
[ext_resource type="Texture2D" uid="uid://cbgn8aspf7oi0" path="res://Sprites/barbell.png" id="2_ltxro"]
[node name="Deadlift" type="Node"]
@@ -9,7 +8,6 @@
bar_height = 7.0
bar_visual = NodePath("../Barbell")
end_pos = Vector2(0, -30)
game_state = ExtResource("1_n6ace")
[node name="Barbell" type="Sprite2D" parent="."]
scale = Vector2(2, 2)

View File

@@ -1,12 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://bqxc62tofqger"]
[ext_resource type="GameState" uid="uid://2gma8vvisnqo" path="res://Resources/GameState.tres" id="1_strkh"]
[gd_scene format=3 uid="uid://bqxc62tofqger"]
[node name="HazardAnimated" type="HazardController" node_paths=PackedStringArray("anim_sprite", "click_area", "click_shape")]
anim_sprite = NodePath("AnimatedSprite2D")
click_area = NodePath("Area2D")
click_shape = NodePath("Area2D/CollisionShape2D")
game_state = ExtResource("1_strkh")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]

View File

@@ -1,3 +0,0 @@
[gd_resource type="GameState" format=3 uid="uid://2gma8vvisnqo"]
[resource]

View File

@@ -1,6 +1,5 @@
[gd_scene load_steps=12 format=3 uid="uid://xtm08af0e82g"]
[ext_resource type="GameState" uid="uid://2gma8vvisnqo" path="res://Resources/GameState.tres" id="1_bo1nx"]
[ext_resource type="Shader" uid="uid://dndm4jfifooyk" path="res://Shaders/TunnelVision.gdshader" id="1_jjgbg"]
[ext_resource type="DayConfig" uid="uid://d30pwvrr7m72j" path="res://Resources/Day_Day1.tres" id="2_8gbba"]
[ext_resource type="SoundBank" uid="uid://b8ouri8tqw8vp" path="res://Resources/SoundBank.tres" id="2_21xkr"]
@@ -27,20 +26,16 @@ shader_parameter/vignette_color = Color(0, 0, 0, 1)
[node name="Systems" type="Node" parent="."]
[node name="PlayerInputSystem" type="PlayerInputSystem" parent="Systems"]
game_state = ExtResource("1_bo1nx")
[node name="TunnelSystem" type="TunnelSystem" parent="Systems" node_paths=PackedStringArray("vignette_overlay")]
game_state = ExtResource("1_bo1nx")
config = SubResource("TunnelConfig_8gbba")
vignette_overlay = NodePath("../../Ui/Vignette")
[node name="SoundManager" type="SoundManager" parent="Systems"]
bank = ExtResource("2_21xkr")
game_state = ExtResource("1_bo1nx")
[node name="GameManager" type="GameManager" parent="Systems" node_paths=PackedStringArray("hazard_system", "minigame_container", "win_screen", "lose_screen")]
days = Array[DayConfig]([ExtResource("2_8gbba"), ExtResource("4_344ge")])
game_state = ExtResource("1_bo1nx")
hazard_system = NodePath("../HazardSystem")
minigame_container = NodePath("../../GameContainer")
win_screen = NodePath("../../Ui/Win")
@@ -49,14 +44,12 @@ main_menu_scene = ExtResource("4_6bp64")
[node name="CameraShakeSystem" type="CameraShakeSystem" parent="Systems" node_paths=PackedStringArray("camera")]
camera = NodePath("../../Camera2D")
game_state = ExtResource("1_bo1nx")
min_focus_for_shake = 0.7
[node name="HazardSystem" type="HazardSystem" parent="Systems" node_paths=PackedStringArray("spawn_locations")]
possible_hazards = Array[HazardDef]([ExtResource("3_kry3j")])
spawn_locations = [NodePath("../../HazardSpots/Right"), NodePath("../../HazardSpots/Left")]
hazard_prefab = ExtResource("4_21xkr")
game_state = ExtResource("1_bo1nx")
[node name="GameContainer" type="Node" parent="."]
@@ -80,7 +73,6 @@ grow_vertical = 2
mouse_filter = 2
[node name="LiftProgressBar" type="LiftProgressBar" parent="Ui"]
game_state = ExtResource("1_bo1nx")
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0

View File

@@ -15,6 +15,10 @@ run/main_scene="uid://bg4uaukekjbx"
config/features=PackedStringArray("4.5", "GL Compatibility")
config/icon="res://icon.svg"
[autoload]
GlobalEventBus="*res://Autoloads/event_bus.tscn"
[input]
lift_action={