Added speed hack for vesna

This commit is contained in:
Jonathan
2025-08-06 21:25:28 +02:00
parent d7ac1c6c22
commit 6aa7530502
5 changed files with 84 additions and 48 deletions
+22
View File
@@ -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
@@ -0,0 +1 @@
uid://buwfplh0xji8q
+7
View File
@@ -0,0 +1,7 @@
[plugin]
name="BabushkaHelpers"
description=""
author="Cozy Raven"
version=""
script="babushkahelpers.gd"
+1 -1
View File
@@ -181,7 +181,7 @@ movie_writer/movie_file="/home/kaddi/Documents/Repos/Godot/Babushka/_clips/clip.
[editor_plugins] [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] [file_customization]
@@ -1,4 +1,3 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Babushka.scripts.CSharp.Common.Inventory; using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Common.Services; using Babushka.scripts.CSharp.Common.Services;
@@ -8,58 +7,65 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
public partial class PlayerMovement : CharacterBody2D public partial class PlayerMovement : CharacterBody2D
{ {
[Export] private float _speed = 1000f; [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"); private InventoryManager _inventoryManager;
bool left = Input.IsActionPressed("move_left");
bool up = Input.IsActionPressed("move_up");
bool down = Input.IsActionPressed("move_down");
if (up) public override void _Process(double delta)
{ {
currentVelocity += new Vector2(0, -_speed); bool anyActionPressed = false;
anyActionPressed = true; Vector2 currentVelocity = Vector2.Zero;
}
if (down) if (!InputService.Instance.InputEnabled)
{ return;
currentVelocity += new Vector2(0, _speed);
anyActionPressed = true;
}
if (right) bool right = Input.IsActionPressed("move_right");
{ bool left = Input.IsActionPressed("move_left");
currentVelocity += new Vector2(_speed, 0); bool up = Input.IsActionPressed("move_up");
bool down = Input.IsActionPressed("move_down");
anyActionPressed = true; if (up)
} {
currentVelocity += new Vector2(0, -_speed);
anyActionPressed = true;
}
if (left) if (down)
{ {
currentVelocity += new Vector2(-_speed, 0); currentVelocity += new Vector2(0, _speed);
anyActionPressed = true;
}
anyActionPressed = true; if (right)
} {
currentVelocity += new Vector2(_speed, 0);
if (anyActionPressed) anyActionPressed = true;
{ }
if (currentVelocity.X != 0 && currentVelocity.Y != 0)
{ if (left)
currentVelocity *= 0.7f; {
} currentVelocity += new Vector2(-_speed, 0);
Velocity = currentVelocity; anyActionPressed = true;
MoveAndSlide(); }
}
} if (anyActionPressed)
{
if (currentVelocity.X != 0 && currentVelocity.Y != 0)
{
currentVelocity *= 0.7f;
}
// speed hack
var setting = ProjectSettings.GetSetting("babushka/hacks/speed_hack",-1).AsSingle();
if (setting > 0)
{
currentVelocity *= setting;
}
Velocity = currentVelocity;
MoveAndSlide();
}
}
} }