From 6aa75305026dd1b7003a536693e39110589fa270 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 6 Aug 2025 21:25:28 +0200 Subject: [PATCH] Added speed hack for vesna --- addons/babushkahelpers/babushkahelpers.gd | 22 ++++ addons/babushkahelpers/babushkahelpers.gd.uid | 1 + addons/babushkahelpers/plugin.cfg | 7 ++ project.godot | 2 +- .../CharacterControls/PlayerMovement.cs | 100 ++++++++++-------- 5 files changed, 84 insertions(+), 48 deletions(-) create mode 100644 addons/babushkahelpers/babushkahelpers.gd create mode 100644 addons/babushkahelpers/babushkahelpers.gd.uid create mode 100644 addons/babushkahelpers/plugin.cfg diff --git a/addons/babushkahelpers/babushkahelpers.gd b/addons/babushkahelpers/babushkahelpers.gd new file mode 100644 index 0000000..d7ea5e6 --- /dev/null +++ b/addons/babushkahelpers/babushkahelpers.gd @@ -0,0 +1,22 @@ +@tool +extends EditorPlugin + + +func _enter_tree() -> void: + if !ProjectSettings.has_setting("babushka/hacks/speed_hack"): + ProjectSettings.set_setting("babushka/hacks/speed_hack",-1) + + var property_info = { + "name": "babushka/hacks/speed_hack", + "type": TYPE_FLOAT, + "hint": PROPERTY_HINT_RANGE, + "hint_string": "-1,20,0.5" + } + + ProjectSettings.add_property_info(property_info) + ProjectSettings.set_initial_value("babushka/hacks/speed_hack",-1) + + +func _exit_tree() -> void: + # Clean-up of the plugin goes here. + pass diff --git a/addons/babushkahelpers/babushkahelpers.gd.uid b/addons/babushkahelpers/babushkahelpers.gd.uid new file mode 100644 index 0000000..ef34d3e --- /dev/null +++ b/addons/babushkahelpers/babushkahelpers.gd.uid @@ -0,0 +1 @@ +uid://buwfplh0xji8q diff --git a/addons/babushkahelpers/plugin.cfg b/addons/babushkahelpers/plugin.cfg new file mode 100644 index 0000000..95accb0 --- /dev/null +++ b/addons/babushkahelpers/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="BabushkaHelpers" +description="" +author="Cozy Raven" +version="" +script="babushkahelpers.gd" diff --git a/project.godot b/project.godot index c29d51e..bea9e10 100644 --- a/project.godot +++ b/project.godot @@ -181,7 +181,7 @@ movie_writer/movie_file="/home/kaddi/Documents/Repos/Godot/Babushka/_clips/clip. [editor_plugins] -enabled=PackedStringArray("res://addons/SignalVisualizer/plugin.cfg", "res://addons/anthonyec.camera_preview/plugin.cfg", "res://addons/dialogic/plugin.cfg") +enabled=PackedStringArray("res://addons/SignalVisualizer/plugin.cfg", "res://addons/anthonyec.camera_preview/plugin.cfg", "res://addons/babushkahelpers/plugin.cfg", "res://addons/dialogic/plugin.cfg") [file_customization] diff --git a/scripts/CSharp/Common/CharacterControls/PlayerMovement.cs b/scripts/CSharp/Common/CharacterControls/PlayerMovement.cs index b021209..029a6b8 100644 --- a/scripts/CSharp/Common/CharacterControls/PlayerMovement.cs +++ b/scripts/CSharp/Common/CharacterControls/PlayerMovement.cs @@ -1,4 +1,3 @@ - using System.Threading.Tasks; using Babushka.scripts.CSharp.Common.Inventory; using Babushka.scripts.CSharp.Common.Services; @@ -8,58 +7,65 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls; public partial class PlayerMovement : CharacterBody2D { - [Export] private float _speed = 1000f; - - private InventoryManager _inventoryManager; - - public override void _Process(double delta) - { - bool anyActionPressed = false; - Vector2 currentVelocity = Vector2.Zero; - - if (!InputService.Instance.InputEnabled) - return; + [Export] private float _speed = 1000f; + + private InventoryManager _inventoryManager; + + public override void _Process(double delta) + { + bool anyActionPressed = false; + Vector2 currentVelocity = Vector2.Zero; + + if (!InputService.Instance.InputEnabled) + return; + + bool right = Input.IsActionPressed("move_right"); + bool left = Input.IsActionPressed("move_left"); + bool up = Input.IsActionPressed("move_up"); + bool down = Input.IsActionPressed("move_down"); - bool right = Input.IsActionPressed("move_right"); - bool left = Input.IsActionPressed("move_left"); - bool up = Input.IsActionPressed("move_up"); - bool down = Input.IsActionPressed("move_down"); + if (up) + { + currentVelocity += new Vector2(0, -_speed); + anyActionPressed = true; + } - if (up) - { - currentVelocity += new Vector2(0, -_speed); - anyActionPressed = true; - } + if (down) + { + currentVelocity += new Vector2(0, _speed); + anyActionPressed = true; + } - if (down) - { - currentVelocity += new Vector2(0, _speed); - anyActionPressed = true; - } + if (right) + { + currentVelocity += new Vector2(_speed, 0); - if (right) - { - currentVelocity += new Vector2(_speed, 0); + anyActionPressed = true; + } - anyActionPressed = true; - } + if (left) + { + currentVelocity += new Vector2(-_speed, 0); - if (left) - { - currentVelocity += new Vector2(-_speed, 0); + anyActionPressed = true; + } - anyActionPressed = true; - } + if (anyActionPressed) + { + if (currentVelocity.X != 0 && currentVelocity.Y != 0) + { + currentVelocity *= 0.7f; + } - if (anyActionPressed) - { - if (currentVelocity.X != 0 && currentVelocity.Y != 0) - { - currentVelocity *= 0.7f; - } - - Velocity = currentVelocity; - MoveAndSlide(); - } - } + // speed hack + var setting = ProjectSettings.GetSetting("babushka/hacks/speed_hack",-1).AsSingle(); + if (setting > 0) + { + currentVelocity *= setting; + } + + Velocity = currentVelocity; + MoveAndSlide(); + } + } }