From 508e9d593bd48f86943ab753d23a10df90dedf55 Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Mon, 9 Dec 2024 15:05:31 -0700 Subject: [PATCH] Shot projection is configurable in settings --- assets/text/text.csv | 3 ++ project.godot | 2 ++ src/game/game_settings.gd | 10 ++++++ src/ui/3d/projectile_arc/projectile_arc.gd | 4 +-- src/ui/menus/settings_menu/settings_menu.tscn | 32 +++++++++++++++++-- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/assets/text/text.csv b/assets/text/text.csv index 6f68621..01b38ae 100644 --- a/assets/text/text.csv +++ b/assets/text/text.csv @@ -19,6 +19,9 @@ SETTINGS_GAME_ACCESSIBILITY_HEADING,Accessibility SETTINGS_GAME_CAMERA_HEADING,Camera SETTINGS_SCREEN_SHAKE,"Enable Screen Shake" SETTINGS_HIT_LAG,"Enable Hit Lag Effect" +SETTINGS_GAME_GAMEPLAY_HEADING,Gameplay +SETTINGS_PROJECTION_COLLISIONS,"Enable Shot Projection Collisions" +SETTINGS_PROJECTION_GRAVITY,"Use Local Gravity for Shot Projection" SETTINGS_FREE_CAMERA_SPEED,"Free Camera Speed" SETTINGS_SENSITIVITY_X,"Sensitivity, Horizontal" SETTINGS_SENSITIVITY_Y,"Sensitivity, Vertical" diff --git a/project.godot b/project.godot index f80870e..e047c03 100644 --- a/project.godot +++ b/project.godot @@ -62,6 +62,8 @@ config/controls/camera/invert_pitch=false config/accessibility/enable_screen_shake=true config/accessibility/enable_hit_lag=true audio/buses/override_bus_layout="user://audio_bus_layout.tres" +config/gameplay/projection/detect_collision=true +config/gameplay/projection/use_local_gravity=true [global_group] diff --git a/src/game/game_settings.gd b/src/game/game_settings.gd index 8566f74..2116e94 100644 --- a/src/game/game_settings.gd +++ b/src/game/game_settings.gd @@ -13,6 +13,9 @@ var invert_pitch: bool var enable_screen_shake: bool var enable_hit_lag: bool +var projection_collisions: bool +var projection_gravity: bool + func _init() -> void: ProjectSettings.settings_changed.connect(_read_settings) @@ -36,6 +39,13 @@ func _read_settings() -> void: ) enable_hit_lag = ProjectSettings.get_setting("game/config/accessibility/enable_hit_lag") + projection_collisions = ProjectSettings.get_setting( + "game/config/gameplay/projection/detect_collision" + ) + projection_gravity = ProjectSettings.get_setting( + "game/config/gameplay/projection/use_local_gravity" + ) + func _load_audio_bus_override() -> void: # Load override audio bus file diff --git a/src/ui/3d/projectile_arc/projectile_arc.gd b/src/ui/3d/projectile_arc/projectile_arc.gd index 18618ab..2887baf 100644 --- a/src/ui/3d/projectile_arc/projectile_arc.gd +++ b/src/ui/3d/projectile_arc/projectile_arc.gd @@ -79,7 +79,7 @@ func _process(_delta: float) -> void: # Get local gravity if enabled var local_gravity := gravity * gravity_vec - if check_gravity: + if check_gravity and Game.settings.projection_gravity: local_gravity = _get_gravity(pos) # Integrate projectile path @@ -87,7 +87,7 @@ func _process(_delta: float) -> void: var next_pos := pos + vel * time_step # Collision - if check_collision: + if check_collision and Game.settings.projection_collisions: var ray_params := PhysicsRayQueryParameters3D.create( pos, next_pos, collision_mask, excluded_rid ) diff --git a/src/ui/menus/settings_menu/settings_menu.tscn b/src/ui/menus/settings_menu/settings_menu.tscn index 1b6e5d6..4f8a0ae 100644 --- a/src/ui/menus/settings_menu/settings_menu.tscn +++ b/src/ui/menus/settings_menu/settings_menu.tscn @@ -16,10 +16,9 @@ script = ExtResource("1_lbcn7") [node name="TabContainer" type="TabContainer" parent="."] layout_mode = 2 -current_tab = 1 +current_tab = 0 [node name="SETTINGS_GAME" type="MarginContainer" parent="TabContainer"] -visible = false layout_mode = 2 theme_type_variation = &"SettingsPageContainer" metadata/_tab_index = 0 @@ -81,6 +80,32 @@ key = &"game/config/accessibility/enable_hit_lag" [node name="SettingLabel" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/HitLag" index="1"] text = "SETTINGS_HIT_LAG" +[node name="GameplayHeading" type="HBoxContainer" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList"] +layout_mode = 2 + +[node name="Label" type="Label" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/GameplayHeading"] +layout_mode = 2 +theme_type_variation = &"HeaderMedium" +text = "SETTINGS_GAME_GAMEPLAY_HEADING" + +[node name="HSeparator" type="HSeparator" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/GameplayHeading"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ProjectionCollision" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")] +layout_mode = 2 +key = &"game/config/gameplay/projection/detect_collision" + +[node name="SettingLabel" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/ProjectionCollision" index="1"] +text = "SETTINGS_PROJECTION_COLLISIONS" + +[node name="ProjectionGravity" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")] +layout_mode = 2 +key = &"game/config/gameplay/projection/use_local_gravity" + +[node name="SettingLabel" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/ProjectionGravity" index="1"] +text = "SETTINGS_PROJECTION_GRAVITY" + [node name="CameraHeading" type="HBoxContainer" parent="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList"] layout_mode = 2 @@ -160,6 +185,7 @@ key = &"game/config/controls/camera/invert_pitch" text = "SETTINGS_INVERT_PITCH" [node name="SETTINGS_GRAPHICS" type="MarginContainer" parent="TabContainer"] +visible = false layout_mode = 2 theme_type_variation = &"SettingsPageContainer" metadata/_tab_index = 1 @@ -464,6 +490,8 @@ text = "UI_ACCEPT" [editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/ScreenShake"] [editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/HitLag"] +[editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/ProjectionCollision"] +[editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/ProjectionGravity"] [editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/FreeCameraSpeed"] [editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/FreeCameraSpeed/PanelContainer/MarginContainer/NumericSlider"] [editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/SensitivityX"]