feat: time dilation and indicator

This commit is contained in:
2025-07-11 10:34:20 +02:00
parent e3d10840c9
commit 98b6537fdd
4 changed files with 67 additions and 7 deletions

View File

@ -24,6 +24,7 @@ public partial class PlayerController : CharacterBody3D
public WeaponSystem WeaponSystem;
public WallHugSystem WallHugSystem;
public PlayerUi PlayerUi;
public TextureRect DashIndicator;
private bool _movementEnabled = true;
@ -53,6 +54,13 @@ public partial class PlayerController : CharacterBody3D
[Export(PropertyHint.Range, "0,5,1,or_greater")]
public int MaxNumberOfDashActions { get; set; } = 1;
[Export(PropertyHint.Range, "0,200,1,or_greater")]
public int DashIndicatorStartSize { get; set; } = 100;
[Export(PropertyHint.Range, "0,1,0.01")]
public float DashProgressAfterWhichToAct { get; set; } = 0.8f;
[Export]
public Curve DashTimeDilationCurve { get; set; }
private int _dashActionsLeft;
public int DashActionsLeft
@ -98,6 +106,8 @@ public partial class PlayerController : CharacterBody3D
// General use stuff
TweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
PlayerUi = GetNode<PlayerUi>("UI");
DashIndicator = GetNode<TextureRect>("%DashIndicator");
// Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
// Camera stuff
@ -209,6 +219,7 @@ public partial class PlayerController : CharacterBody3D
///////////////////////////
DashSystem.DashEnded += OnDashEnded;
DashSystem.DashProgress += OnDashProgress;
_weaponInHand.StateProcessing += HandleWeaponInHand;
_aiming.StateProcessing += HandleAiming;
@ -427,6 +438,15 @@ public partial class PlayerController : CharacterBody3D
_dashDirection = (DashSystem.PlannedPlayerLocation - GlobalPosition).Normalized();
DashSystem.Dash();
}
public void OnDashProgress(float progress)
{
Engine.SetTimeScale(DashTimeDilationCurve.Sample(progress));
DashIndicator.SetCustomMinimumSize(Vector2.One * DashIndicatorStartSize * (1 - progress));
var indicatorColor = progress < DashProgressAfterWhichToAct ? new Color(1, 1, 1) : new Color(0, 1, 0);
DashIndicator.SetModulate(indicatorColor);
}
public void OnDashEnded()
{
// _playerState.SendEvent("enable_double_jump"); // Allow for double jump after dash -- OP ?