trying other setup
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=44 format=3 uid="uid://bei4nhkf8lwdo"]
|
[gd_scene load_steps=45 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
||||||
[ext_resource type="Curve" uid="uid://c2a8soliruf35" path="res://systems/dash/dash_time_dilation.tres" id="2_2q0ik"]
|
[ext_resource type="Curve" uid="uid://c2a8soliruf35" path="res://systems/dash/dash_time_dilation.tres" id="2_2q0ik"]
|
||||||
@ -14,6 +14,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="8_qu4wy"]
|
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="8_qu4wy"]
|
||||||
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="9_5p2qc"]
|
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="9_5p2qc"]
|
||||||
[ext_resource type="Script" uid="uid://bt0xv2q8iv1vn" path="res://player_controller/Scripts/Gravity.cs" id="9_lsueh"]
|
[ext_resource type="Script" uid="uid://bt0xv2q8iv1vn" path="res://player_controller/Scripts/Gravity.cs" id="9_lsueh"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bebstkm608wxx" path="res://systems/inputs/base_mode/aim_pressed.tres" id="9_nob5r"]
|
||||||
[ext_resource type="Resource" uid="uid://bdit2jy5gbpts" path="res://systems/inputs/base_mode/jump.tres" id="10_4u7i3"]
|
[ext_resource type="Resource" uid="uid://bdit2jy5gbpts" path="res://systems/inputs/base_mode/jump.tres" id="10_4u7i3"]
|
||||||
[ext_resource type="Script" uid="uid://g8idirw62qe0" path="res://player_controller/Scripts/Bobbing.cs" id="10_7wk1w"]
|
[ext_resource type="Script" uid="uid://g8idirw62qe0" path="res://player_controller/Scripts/Bobbing.cs" id="10_7wk1w"]
|
||||||
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/empower_down.tres" id="10_nodcl"]
|
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/empower_down.tres" id="10_nodcl"]
|
||||||
@ -53,6 +54,7 @@ script = ExtResource("1_poq2x")
|
|||||||
TimeScaleAimInAir = 0.15
|
TimeScaleAimInAir = 0.15
|
||||||
MaxJumpBoostAfterDashing = 0.7
|
MaxJumpBoostAfterDashing = 0.7
|
||||||
MaxNumberOfDashActions = 2
|
MaxNumberOfDashActions = 2
|
||||||
|
PerfectlyTimedActionTimer = 0.3
|
||||||
BasicDashStrength = 15.0
|
BasicDashStrength = 15.0
|
||||||
DashTimeDilationCurve = ExtResource("2_2q0ik")
|
DashTimeDilationCurve = ExtResource("2_2q0ik")
|
||||||
|
|
||||||
@ -63,6 +65,7 @@ move = ExtResource("17_h6vvl")
|
|||||||
rotate_y = ExtResource("4_rxwoh")
|
rotate_y = ExtResource("4_rxwoh")
|
||||||
rotate_floorplane = ExtResource("5_4u7i3")
|
rotate_floorplane = ExtResource("5_4u7i3")
|
||||||
aim_down = ExtResource("8_obsfv")
|
aim_down = ExtResource("8_obsfv")
|
||||||
|
aim_pressed = ExtResource("9_nob5r")
|
||||||
aim_released = ExtResource("8_lhb11")
|
aim_released = ExtResource("8_lhb11")
|
||||||
empower_down = ExtResource("10_nodcl")
|
empower_down = ExtResource("10_nodcl")
|
||||||
empower_released = ExtResource("11_ruloh")
|
empower_released = ExtResource("11_ruloh")
|
||||||
@ -195,6 +198,10 @@ ignore_time_scale = true
|
|||||||
wait_time = 0.3
|
wait_time = 0.3
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="EmpowerTimeDownscale" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
ignore_time_scale = true
|
||||||
|
|
||||||
[node name="StateChartDebugger" parent="." instance=ExtResource("24_q5h8a")]
|
[node name="StateChartDebugger" parent="." instance=ExtResource("24_q5h8a")]
|
||||||
offset_left = 1524.0
|
offset_left = 1524.0
|
||||||
offset_top = 1.0
|
offset_top = 1.0
|
||||||
@ -262,6 +269,12 @@ script = ExtResource("27_infe6")
|
|||||||
script = ExtResource("26_infe6")
|
script = ExtResource("26_infe6")
|
||||||
initial_state = NodePath("Off")
|
initial_state = NodePath("Off")
|
||||||
|
|
||||||
|
[node name="ToOff" type="Node" parent="StateChart/Root/Aim"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../Off")
|
||||||
|
event = &"aim_released"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Off" type="Node" parent="StateChart/Root/Aim"]
|
[node name="Off" type="Node" parent="StateChart/Root/Aim"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
@ -274,12 +287,15 @@ delay_in_seconds = "0.0"
|
|||||||
[node name="On" type="Node" parent="StateChart/Root/Aim"]
|
[node name="On" type="Node" parent="StateChart/Root/Aim"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="ToOff" type="Node" parent="StateChart/Root/Aim/On"]
|
[node name="ToCancel" type="Node" parent="StateChart/Root/Aim/On"]
|
||||||
script = ExtResource("28_n7qhm")
|
script = ExtResource("28_n7qhm")
|
||||||
to = NodePath("../../Off")
|
to = NodePath("../../Canceled")
|
||||||
event = &"aim_released"
|
event = &"cancel_aim"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="Canceled" type="Node" parent="StateChart/Root/Aim"]
|
||||||
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
[node name="Empower" type="Node" parent="StateChart/Root"]
|
[node name="Empower" type="Node" parent="StateChart/Root"]
|
||||||
script = ExtResource("26_infe6")
|
script = ExtResource("26_infe6")
|
||||||
initial_state = NodePath("Off")
|
initial_state = NodePath("Off")
|
||||||
@ -326,12 +342,36 @@ script = ExtResource("26_infe6")
|
|||||||
initial_state = NodePath("InHand")
|
initial_state = NodePath("InHand")
|
||||||
metadata/_custom_type_script = "uid://c1vp0ojjvaby1"
|
metadata/_custom_type_script = "uid://c1vp0ojjvaby1"
|
||||||
|
|
||||||
|
[node name="ToPlanted" type="Node" parent="StateChart/Root/WeaponState"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../Planted")
|
||||||
|
event = &"plant_weapon"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="ToHand" type="Node" parent="StateChart/Root/WeaponState"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../InHand")
|
||||||
|
event = &"recover_weapond"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="InHand" type="Node" parent="StateChart/Root/WeaponState"]
|
[node name="InHand" type="Node" parent="StateChart/Root/WeaponState"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToThrown" type="Node" parent="StateChart/Root/WeaponState/InHand"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../Flying")
|
||||||
|
event = &"throw"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Flying" type="Node" parent="StateChart/Root/WeaponState"]
|
[node name="Flying" type="Node" parent="StateChart/Root/WeaponState"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToPlanted" type="Node" parent="StateChart/Root/WeaponState/Flying"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../Planted")
|
||||||
|
event = &"plant_weapon"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Planted" type="Node" parent="StateChart/Root/WeaponState"]
|
[node name="Planted" type="Node" parent="StateChart/Root/WeaponState"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
@ -517,6 +557,7 @@ delay_in_seconds = "0.0"
|
|||||||
|
|
||||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||||
[connection signal="input_aim_down" from="InputController" to="." method="OnInputAimDown"]
|
[connection signal="input_aim_down" from="InputController" to="." method="OnInputAimDown"]
|
||||||
|
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||||
[connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"]
|
[connection signal="input_aim_released" from="InputController" to="." method="OnInputAimReleased"]
|
||||||
[connection signal="input_dash" from="InputController" to="." method="OnInputDashPressed"]
|
[connection signal="input_dash" from="InputController" to="." method="OnInputDashPressed"]
|
||||||
[connection signal="input_empower_down" from="InputController" to="." method="OnInputEmpowerDown"]
|
[connection signal="input_empower_down" from="InputController" to="." method="OnInputEmpowerDown"]
|
||||||
|
@ -46,6 +46,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private Timer _timeScaleAimInAirTimer;
|
private Timer _timeScaleAimInAirTimer;
|
||||||
private Timer _timeAfterDashingTimer;
|
private Timer _timeAfterDashingTimer;
|
||||||
private Timer _dashCooldownTimer;
|
private Timer _dashCooldownTimer;
|
||||||
|
private Timer _empowerTimeDownscale;
|
||||||
|
|
||||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
public float TimeScaleAimInAir { get; set; } = 0.2f;
|
public float TimeScaleAimInAir { get; set; } = 0.2f;
|
||||||
@ -57,25 +58,27 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
[Export(PropertyHint.Range, "0,200,1,or_greater")]
|
[Export(PropertyHint.Range, "0,200,1,or_greater")]
|
||||||
public int DashIndicatorStartSize { get; set; } = 100;
|
public int DashIndicatorStartSize { get; set; } = 100;
|
||||||
[Export(PropertyHint.Range, "0,1,0.01")]
|
[Export(PropertyHint.Range, "0,1,0.01")]
|
||||||
public float DashProgressAfterWhichToAct { get; set; } = 0.8f;
|
public float PerfectlyTimedActionTimer { get; set; } = 0.8f;
|
||||||
[Export(PropertyHint.Range, "0,50,0.1")]
|
[Export(PropertyHint.Range, "0,50,0.1")]
|
||||||
public float BasicDashStrength { get; set; } = 10f;
|
public float BasicDashStrength { get; set; } = 10f;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Curve DashTimeDilationCurve { get; set; }
|
public Curve DashTimeDilationCurve { get; set; }
|
||||||
|
private bool _canDash = true;
|
||||||
|
|
||||||
private int _dashActionsLeft;
|
private int _empoweredActionsLeft;
|
||||||
public int DashActionsLeft
|
public int EmpoweredActionsLeft
|
||||||
{
|
{
|
||||||
get => _dashActionsLeft;
|
get => _empoweredActionsLeft;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_dashActionsLeft = value;
|
_empoweredActionsLeft = value;
|
||||||
PlayerUi.SetNumberOfDashesLeft(value);
|
PlayerUi.SetNumberOfDashesLeft(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isWallJumpAvailable = true;
|
private bool _isWallJumpAvailable = true;
|
||||||
|
private bool _isActionPerfectlyTimed = false;
|
||||||
|
|
||||||
private StateChart _playerState;
|
private StateChart _playerState;
|
||||||
|
|
||||||
@ -176,6 +179,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_dashCooldownTimer = GetNode<Timer>("DashCooldown");
|
_dashCooldownTimer = GetNode<Timer>("DashCooldown");
|
||||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||||
_timeAfterDashingTimer = GetNode<Timer>("TimeAfterDashing");
|
_timeAfterDashingTimer = GetNode<Timer>("TimeAfterDashing");
|
||||||
|
_empowerTimeDownscale = GetNode<Timer>("EmpowerTimeDownscale");
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Initialize components //
|
// Initialize components //
|
||||||
@ -216,7 +220,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
HealthSystem.Init(healthSystemParams);
|
HealthSystem.Init(healthSystemParams);
|
||||||
Stamina.SetSpeeds(MoveSystem.WalkSpeed, MoveSystem.SprintSpeed);
|
Stamina.SetSpeeds(MoveSystem.WalkSpeed, MoveSystem.SprintSpeed);
|
||||||
|
|
||||||
DashActionsLeft = MaxNumberOfDashActions;
|
EmpoweredActionsLeft = MaxNumberOfDashActions;
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Signal setup ///////////
|
// Signal setup ///////////
|
||||||
@ -229,9 +233,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_aiming.StateProcessing += HandleAiming;
|
_aiming.StateProcessing += HandleAiming;
|
||||||
_aiming.StateEntered += OnAimingEntered;
|
_aiming.StateEntered += OnAimingEntered;
|
||||||
_aiming.StateExited += ResetTimeScale;
|
_aiming.StateExited += ResetTimeScale;
|
||||||
|
_aiming.StateExited += OnAimingExited;
|
||||||
|
|
||||||
/*_crouched.StatePhysicsProcessing += HandleGroundedCrouched;
|
|
||||||
_standing.StatePhysicsProcessing += HandleGroundedStanding;*/
|
|
||||||
_grounded.StateEntered += OnGrounded;
|
_grounded.StateEntered += OnGrounded;
|
||||||
_grounded.StatePhysicsProcessing += HandleGrounded;
|
_grounded.StatePhysicsProcessing += HandleGrounded;
|
||||||
_airborne.StatePhysicsProcessing += HandleAirborne;
|
_airborne.StatePhysicsProcessing += HandleAirborne;
|
||||||
@ -242,7 +245,36 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_timeScaleAimInAirTimer.Timeout += ResetTimeScale;
|
_timeScaleAimInAirTimer.Timeout += ResetTimeScale;
|
||||||
|
|
||||||
_dashing.StatePhysicsProcessing += Dashing;
|
_dashing.StatePhysicsProcessing += Dashing;
|
||||||
_weaponThrown.StateEntered += OnWeaponThrown;
|
// _weaponThrown.StateEntered += OnWeaponThrown;
|
||||||
|
|
||||||
|
_empowerOn.StateEntered += OnEmpowerStarted;
|
||||||
|
_empowerOn.StateProcessing += HandleEmpower;
|
||||||
|
_empowerTimeDownscale.Timeout += EmpowerStopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnEmpowerStarted()
|
||||||
|
{
|
||||||
|
_empowerTimeDownscale.Start();
|
||||||
|
_isActionPerfectlyTimed = true;
|
||||||
|
Engine.SetTimeScale(0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleEmpower(float delta)
|
||||||
|
{
|
||||||
|
var progress = (float) (_empowerTimeDownscale.TimeLeft / _empowerTimeDownscale.WaitTime);
|
||||||
|
_isActionPerfectlyTimed = progress < PerfectlyTimedActionTimer;
|
||||||
|
var indicatorColor = _isActionPerfectlyTimed ? Colors.Green : Colors.White;
|
||||||
|
|
||||||
|
DashIndicator.SetCustomMinimumSize(Vector2.One * DashIndicatorStartSize * progress);
|
||||||
|
DashIndicator.SetModulate(indicatorColor);
|
||||||
|
DashIndicator.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EmpowerStopped()
|
||||||
|
{
|
||||||
|
DashIndicator.Visible = false;
|
||||||
|
ResetTimeScale();
|
||||||
|
_isActionPerfectlyTimed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@ -264,6 +296,10 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
public void OnInputAimPressed()
|
public void OnInputAimPressed()
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("aim_pressed");
|
_playerState.SendEvent("aim_pressed");
|
||||||
|
if (!WeaponSystem.InHandState.Active)
|
||||||
|
{
|
||||||
|
OnDashStarted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void OnInputAimDown()
|
public void OnInputAimDown()
|
||||||
{
|
{
|
||||||
@ -280,7 +316,10 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
public void OnInputHitPressed()
|
public void OnInputHitPressed()
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("hit_pressed");
|
if (_aiming.Active)
|
||||||
|
{
|
||||||
|
OnWeaponThrown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void OnInputJumpPressed()
|
public void OnInputJumpPressed()
|
||||||
{
|
{
|
||||||
@ -290,15 +329,21 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_grounded.Active || _coyoteEnabled.Active)
|
if (_grounded.Active || _coyoteEnabled.Active)
|
||||||
if (_empowerOn.Active)
|
if (_empowerOn.Active && CanPerformEmpoweredAction())
|
||||||
|
{
|
||||||
|
PerformEmpoweredAction();
|
||||||
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
|
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Jump();
|
PerformJump(MoveSystem.JumpTypes.SimpleJump);
|
||||||
else if (_doubleJumpEnabled.Active)
|
else if (_doubleJumpEnabled.Active)
|
||||||
if (_empowerOn.Active)
|
if (_empowerOn.Active && CanPerformEmpoweredAction())
|
||||||
|
{
|
||||||
|
PerformEmpoweredAction();
|
||||||
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
|
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
DoubleJump();
|
PerformJump(MoveSystem.JumpTypes.DoubleJump);
|
||||||
else if (_onWall.Active)
|
else if (_onWall.Active)
|
||||||
JumpFromWall(_empowerOn.Active);
|
JumpFromWall(_empowerOn.Active);
|
||||||
|
|
||||||
@ -312,7 +357,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
public void OnInputThrowPressed()
|
public void OnInputThrowPressed()
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("throw");
|
|
||||||
}
|
}
|
||||||
public void OnInputEmpowerDown()
|
public void OnInputEmpowerDown()
|
||||||
{
|
{
|
||||||
@ -325,9 +370,25 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public void PerformDash(bool isEmpowered)
|
public void PerformDash(bool isEmpowered)
|
||||||
{
|
{
|
||||||
|
if (_aiming.Active)
|
||||||
|
{
|
||||||
|
OnDashStarted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_canDash)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_canDash = false;
|
||||||
|
var dashStrength = BasicDashStrength;
|
||||||
|
if (isEmpowered && CanPerformEmpoweredAction())
|
||||||
|
{
|
||||||
|
PerformEmpoweredAction();
|
||||||
|
dashStrength *= 2.5f;
|
||||||
|
}
|
||||||
|
|
||||||
var direction = HeadSystem.Transform.Basis * _inputMove;
|
var direction = HeadSystem.Transform.Basis * _inputMove;
|
||||||
var planarDirection = new Vector3(direction.X, 0, direction.Z).Normalized();
|
var planarDirection = new Vector3(direction.X, 0, direction.Z).Normalized();
|
||||||
var dashStrength = isEmpowered ? BasicDashStrength * 2.5f : BasicDashStrength;
|
|
||||||
SetVelocity(planarDirection * dashStrength);
|
SetVelocity(planarDirection * dashStrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,20 +405,31 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
// Simple states
|
// Simple states
|
||||||
public void OnGrounded()
|
public void OnGrounded()
|
||||||
{
|
{
|
||||||
DashActionsLeft = MaxNumberOfDashActions;
|
RestoreEmpoweredActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreEmpoweredActions()
|
||||||
|
{
|
||||||
|
EmpoweredActionsLeft = MaxNumberOfDashActions;
|
||||||
_isWallJumpAvailable = true;
|
_isWallJumpAvailable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPerformEmpoweredAction()
|
public bool CanPerformEmpoweredAction()
|
||||||
{
|
{
|
||||||
return DashActionsLeft > 0 && _dashCooldownTimer.IsStopped();
|
return EmpoweredActionsLeft > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PerformEmpoweredAction()
|
public void PerformEmpoweredAction()
|
||||||
{
|
{
|
||||||
_isWallJumpAvailable = true;
|
_isWallJumpAvailable = true;
|
||||||
_dashCooldownTimer.Start();
|
_dashCooldownTimer.Start();
|
||||||
DashActionsLeft--;
|
|
||||||
|
if (!_isActionPerfectlyTimed)
|
||||||
|
{
|
||||||
|
EmpoweredActionsLeft--;
|
||||||
|
}
|
||||||
|
_empowerTimeDownscale.Stop();
|
||||||
|
EmpowerStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jumping
|
// Jumping
|
||||||
@ -369,17 +441,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
{
|
{
|
||||||
_playerState.SendEvent("coyote_expired");
|
_playerState.SendEvent("coyote_expired");
|
||||||
}
|
}
|
||||||
public void Jump()
|
|
||||||
{
|
|
||||||
if (_aiming.Active && CanPerformEmpoweredAction())
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("jump_from_dash");
|
|
||||||
PerformEmpoweredAction();
|
|
||||||
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PerformJump(MoveSystem.JumpTypes.SimpleJump);
|
|
||||||
}
|
|
||||||
public void JumpFromWall(bool isEmpowered)
|
public void JumpFromWall(bool isEmpowered)
|
||||||
{
|
{
|
||||||
if (!_isWallJumpAvailable)
|
if (!_isWallJumpAvailable)
|
||||||
@ -397,16 +458,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
PerformJump(MoveSystem.JumpTypes.JumpFromWall, jumpDirection);
|
PerformJump(MoveSystem.JumpTypes.JumpFromWall, jumpDirection);
|
||||||
}
|
}
|
||||||
public void DoubleJump()
|
|
||||||
{
|
|
||||||
if (_aiming.Active && CanPerformEmpoweredAction())
|
|
||||||
{
|
|
||||||
PerformEmpoweredAction();
|
|
||||||
PerformJump(MoveSystem.JumpTypes.JumpFromDash);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PerformJump(MoveSystem.JumpTypes.DoubleJump);
|
|
||||||
}
|
|
||||||
private void PerformJump(MoveSystem.JumpTypes jumpType, Vector3? jumpDirection = null)
|
private void PerformJump(MoveSystem.JumpTypes jumpType, Vector3? jumpDirection = null)
|
||||||
{
|
{
|
||||||
var effectiveJumpDirection = jumpDirection ?? Vector3.Up;
|
var effectiveJumpDirection = jumpDirection ?? Vector3.Up;
|
||||||
@ -478,10 +529,12 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public void OnDashProgress(float progress)
|
public void OnDashProgress(float progress)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
Engine.SetTimeScale(DashTimeDilationCurve.Sample(progress));
|
Engine.SetTimeScale(DashTimeDilationCurve.Sample(progress));
|
||||||
|
|
||||||
DashIndicator.SetCustomMinimumSize(Vector2.One * DashIndicatorStartSize * (1 - progress));
|
DashIndicator.SetCustomMinimumSize(Vector2.One * DashIndicatorStartSize * (1 - progress));
|
||||||
var indicatorColor = progress < DashProgressAfterWhichToAct ? new Color(1, 1, 1) : new Color(0, 1, 0);
|
var indicatorColor = progress < PerfectlyTimedActionTimer ? new Color(1, 1, 1) : new Color(0, 1, 0);
|
||||||
DashIndicator.SetModulate(indicatorColor);
|
DashIndicator.SetModulate(indicatorColor);
|
||||||
}
|
}
|
||||||
public void OnDashEnded()
|
public void OnDashEnded()
|
||||||
@ -522,15 +575,18 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
// Weapon planted anywhere else
|
// Weapon planted anywhere else
|
||||||
_playerState.SendEvent("dash_ended");
|
_playerState.SendEvent("dash_ended");
|
||||||
|
if (isOnFloorCustom())
|
||||||
|
RestoreEmpoweredActions(); // Make sure to restore actions if we're still on the ground
|
||||||
}
|
}
|
||||||
public void OnWeaponThrown()
|
public void OnWeaponThrown()
|
||||||
{
|
{
|
||||||
|
DashSystem.CancelDash();
|
||||||
|
_playerState.SendEvent("cancel_aim");
|
||||||
|
|
||||||
RemoveChild(WeaponRoot);
|
RemoveChild(WeaponRoot);
|
||||||
GetTree().GetRoot().AddChild(WeaponRoot);
|
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||||
|
|
||||||
DashSystem.CancelDash();
|
|
||||||
|
|
||||||
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.TargetLocation;
|
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.TargetLocation;
|
||||||
WeaponSystem.ThrowWeapon(
|
WeaponSystem.ThrowWeapon(
|
||||||
weaponTargetLocation,
|
weaponTargetLocation,
|
||||||
@ -540,32 +596,38 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
public void OnAimingEntered()
|
public void OnAimingEntered()
|
||||||
{
|
{
|
||||||
|
if (!WeaponSystem.InHandState.Active)
|
||||||
|
{
|
||||||
|
OnDashStarted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isOnFloorCustom() && CanPerformEmpoweredAction())
|
if (!isOnFloorCustom() && CanPerformEmpoweredAction())
|
||||||
ReduceTimeScaleWhileAiming();
|
ReduceTimeScaleWhileAiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnAimingExited()
|
||||||
|
{
|
||||||
|
DashSystem.CancelDash();
|
||||||
|
}
|
||||||
|
|
||||||
// Regular processes
|
// Regular processes
|
||||||
public void HandleWeaponInHand(float delta)
|
public void HandleWeaponInHand(float delta)
|
||||||
{
|
{
|
||||||
RotateWeaponWithPlayer();
|
if (WeaponSystem.InHandState.Active)
|
||||||
|
RotateWeaponWithPlayer();
|
||||||
}
|
}
|
||||||
public void HandleAiming(float delta)
|
public void HandleAiming(float delta)
|
||||||
{
|
{
|
||||||
RotateWeaponWithPlayer();
|
RotateWeaponWithPlayer();
|
||||||
if (isOnFloorCustom())
|
|
||||||
ResetTimeScale();
|
|
||||||
if (CanPerformEmpoweredAction())
|
if (CanPerformEmpoweredAction())
|
||||||
DashSystem.PrepareDash();
|
DashSystem.PrepareDash();
|
||||||
else
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("aim_canceled");
|
|
||||||
DashSystem.CancelDash();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Physics processes
|
// Physics processes
|
||||||
public void HandleGrounded(float delta)
|
public void HandleGrounded(float delta)
|
||||||
{
|
{
|
||||||
|
_canDash = true;
|
||||||
if (!isOnFloorCustom())
|
if (!isOnFloorCustom())
|
||||||
_playerState.SendEvent("start_falling");
|
_playerState.SendEvent("start_falling");
|
||||||
}
|
}
|
||||||
|
14
systems/inputs/base_mode/aim_pressed.tres
Normal file
14
systems/inputs/base_mode/aim_pressed.tres
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://bebstkm608wxx"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cluhc11vixkf1" path="res://addons/guide/guide_action.gd" id="1_bvbvh"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_bvbvh")
|
||||||
|
name = &""
|
||||||
|
action_value_type = 0
|
||||||
|
block_lower_priority_actions = true
|
||||||
|
emit_as_godot_actions = false
|
||||||
|
is_remappable = false
|
||||||
|
display_name = ""
|
||||||
|
display_category = ""
|
||||||
|
metadata/_custom_type_script = "uid://cluhc11vixkf1"
|
@ -1,4 +1,4 @@
|
|||||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=81 format=3 uid="uid://bl5crtu1gkrtr"]
|
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=86 format=3 uid="uid://bl5crtu1gkrtr"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
||||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
||||||
@ -17,6 +17,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://b52rqq28tuqpg" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="15_fykw6"]
|
[ext_resource type="Script" uid="uid://b52rqq28tuqpg" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="15_fykw6"]
|
||||||
[ext_resource type="Script" uid="uid://b4cdrn4paoj3i" path="res://addons/guide/triggers/guide_trigger_down.gd" id="15_g6bbx"]
|
[ext_resource type="Script" uid="uid://b4cdrn4paoj3i" path="res://addons/guide/triggers/guide_trigger_down.gd" id="15_g6bbx"]
|
||||||
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/empower_down.tres" id="16_0qat1"]
|
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/empower_down.tres" id="16_0qat1"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bebstkm608wxx" path="res://systems/inputs/base_mode/aim_pressed.tres" id="16_li5ak"]
|
||||||
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/base_mode/aim_release.tres" id="16_rvpjj"]
|
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/base_mode/aim_release.tres" id="16_rvpjj"]
|
||||||
[ext_resource type="Script" uid="uid://biiggjw6tv4uq" path="res://addons/guide/triggers/guide_trigger_released.gd" id="17_s8kjn"]
|
[ext_resource type="Script" uid="uid://biiggjw6tv4uq" path="res://addons/guide/triggers/guide_trigger_released.gd" id="17_s8kjn"]
|
||||||
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="18_vibkn"]
|
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/base_mode/aim_cancel.tres" id="18_vibkn"]
|
||||||
@ -156,6 +157,31 @@ triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_2tfaw")])
|
|||||||
script = ExtResource("1_qmhk6")
|
script = ExtResource("1_qmhk6")
|
||||||
action = ExtResource("14_yp12v")
|
action = ExtResource("14_yp12v")
|
||||||
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_q86qg")])
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_q86qg")])
|
||||||
|
metadata/_guide_input_mappings_collapsed = false
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_llfhp"]
|
||||||
|
script = ExtResource("10_cvxqo")
|
||||||
|
axis = 4
|
||||||
|
joy_index = -1
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ib0yi"]
|
||||||
|
script = ExtResource("15_fykw6")
|
||||||
|
actuation_threshold = 0.5
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_r6kml"]
|
||||||
|
script = ExtResource("3_yp12v")
|
||||||
|
override_action_settings = false
|
||||||
|
is_remappable = false
|
||||||
|
display_name = ""
|
||||||
|
display_category = ""
|
||||||
|
input = SubResource("Resource_llfhp")
|
||||||
|
modifiers = Array[ExtResource("5_0qat1")]([])
|
||||||
|
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_ib0yi")])
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_tb8ii"]
|
||||||
|
script = ExtResource("1_qmhk6")
|
||||||
|
action = ExtResource("16_li5ak")
|
||||||
|
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_r6kml")])
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_fykw6"]
|
[sub_resource type="Resource" id="Resource_fykw6"]
|
||||||
script = ExtResource("10_cvxqo")
|
script = ExtResource("10_cvxqo")
|
||||||
@ -355,5 +381,5 @@ input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_v2ywt")])
|
|||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("23_llfhp")
|
script = ExtResource("23_llfhp")
|
||||||
display_name = ""
|
display_name = ""
|
||||||
mappings = Array[ExtResource("1_qmhk6")]([SubResource("Resource_88x08"), SubResource("Resource_tgr2g"), SubResource("Resource_iarn8"), SubResource("Resource_cvxqo"), SubResource("Resource_vibkn"), SubResource("Resource_iihs4"), SubResource("Resource_2hs2y"), SubResource("Resource_0s4kt"), SubResource("Resource_xt1x5"), SubResource("Resource_ew1hw"), SubResource("Resource_0qat1"), SubResource("Resource_vtk18")])
|
mappings = Array[ExtResource("1_qmhk6")]([SubResource("Resource_88x08"), SubResource("Resource_tgr2g"), SubResource("Resource_iarn8"), SubResource("Resource_cvxqo"), SubResource("Resource_tb8ii"), SubResource("Resource_vibkn"), SubResource("Resource_iihs4"), SubResource("Resource_2hs2y"), SubResource("Resource_0s4kt"), SubResource("Resource_xt1x5"), SubResource("Resource_ew1hw"), SubResource("Resource_0qat1"), SubResource("Resource_vtk18")])
|
||||||
metadata/_custom_type_script = "uid://dsa1dnifd6w32"
|
metadata/_custom_type_script = "uid://dsa1dnifd6w32"
|
||||||
|
@ -11,6 +11,7 @@ class_name InputController
|
|||||||
|
|
||||||
@export_group("Trigger actions")
|
@export_group("Trigger actions")
|
||||||
@export var aim_down:GUIDEAction
|
@export var aim_down:GUIDEAction
|
||||||
|
@export var aim_pressed:GUIDEAction
|
||||||
@export var aim_released:GUIDEAction
|
@export var aim_released:GUIDEAction
|
||||||
@export var empower_down:GUIDEAction
|
@export var empower_down:GUIDEAction
|
||||||
@export var empower_released:GUIDEAction
|
@export var empower_released:GUIDEAction
|
||||||
@ -25,6 +26,7 @@ signal input_rotate_y(value: float)
|
|||||||
signal input_rotate_floorplane(value: float)
|
signal input_rotate_floorplane(value: float)
|
||||||
|
|
||||||
signal input_aim_down
|
signal input_aim_down
|
||||||
|
signal input_aim_pressed
|
||||||
signal input_aim_released
|
signal input_aim_released
|
||||||
signal input_empower_down
|
signal input_empower_down
|
||||||
signal input_empower_released
|
signal input_empower_released
|
||||||
@ -38,6 +40,7 @@ func _ready() -> void:
|
|||||||
GUIDE.enable_mapping_context(base_mode)
|
GUIDE.enable_mapping_context(base_mode)
|
||||||
|
|
||||||
aim_down.triggered.connect(on_input_aim_down)
|
aim_down.triggered.connect(on_input_aim_down)
|
||||||
|
aim_pressed.triggered.connect(on_input_aim_pressed)
|
||||||
aim_released.triggered.connect(on_input_aim_released)
|
aim_released.triggered.connect(on_input_aim_released)
|
||||||
empower_down.triggered.connect(on_input_empower_down)
|
empower_down.triggered.connect(on_input_empower_down)
|
||||||
empower_released.triggered.connect(on_input_empower_released)
|
empower_released.triggered.connect(on_input_empower_released)
|
||||||
@ -62,6 +65,9 @@ func on_input_jump():
|
|||||||
func on_input_aim_down():
|
func on_input_aim_down():
|
||||||
input_aim_down.emit()
|
input_aim_down.emit()
|
||||||
|
|
||||||
|
func on_input_aim_pressed():
|
||||||
|
input_aim_pressed.emit()
|
||||||
|
|
||||||
func on_input_aim_released():
|
func on_input_aim_released():
|
||||||
input_aim_released.emit()
|
input_aim_released.emit()
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
|
|
||||||
public void OnThrownWeaponReachesGround(Node other)
|
public void OnThrownWeaponReachesGround(Node other)
|
||||||
{
|
{
|
||||||
|
GD.Print(other.Name);
|
||||||
PlantWeaponInWall();
|
PlantWeaponInWall();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user