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
@@ -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;
bool right = Input.IsActionPressed("move_right");
bool left = Input.IsActionPressed("move_left");
bool up = Input.IsActionPressed("move_up");
bool down = Input.IsActionPressed("move_down");
private InventoryManager _inventoryManager;
if (up)
{
currentVelocity += new Vector2(0, -_speed);
anyActionPressed = true;
}
public override void _Process(double delta)
{
bool anyActionPressed = false;
Vector2 currentVelocity = Vector2.Zero;
if (down)
{
currentVelocity += new Vector2(0, _speed);
anyActionPressed = true;
}
if (!InputService.Instance.InputEnabled)
return;
if (right)
{
currentVelocity += new Vector2(_speed, 0);
bool right = Input.IsActionPressed("move_right");
bool left = Input.IsActionPressed("move_left");
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)
{
currentVelocity += new Vector2(-_speed, 0);
if (down)
{
currentVelocity += new Vector2(0, _speed);
anyActionPressed = true;
}
anyActionPressed = true;
}
if (right)
{
currentVelocity += new Vector2(_speed, 0);
if (anyActionPressed)
{
if (currentVelocity.X != 0 && currentVelocity.Y != 0)
{
currentVelocity *= 0.7f;
}
Velocity = currentVelocity;
MoveAndSlide();
}
}
anyActionPressed = true;
}
if (left)
{
currentVelocity += new Vector2(-_speed, 0);
anyActionPressed = true;
}
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();
}
}
}