throwing weapon back on
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
[gd_scene load_steps=44 format=3 uid="uid://bei4nhkf8lwdo"]
|
[gd_scene load_steps=43 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="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
||||||
[ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://systems/inputs/base_mode/rotate_y.tres" id="4_rxwoh"]
|
[ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://systems/inputs/base_mode/rotate_y.tres" id="4_rxwoh"]
|
||||||
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="5_4u7i3"]
|
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="5_4u7i3"]
|
||||||
@ -64,14 +63,14 @@ MegaJumpStartVelocity = 30.0
|
|||||||
MegaJumpHangTimeInFrames = 12
|
MegaJumpHangTimeInFrames = 12
|
||||||
MegaJumpGravityLesseningFactor = 1.2
|
MegaJumpGravityLesseningFactor = 1.2
|
||||||
WallJumpStartVelocity = 8.0
|
WallJumpStartVelocity = 8.0
|
||||||
|
MaxNumberOfEmpoweredActions = 3
|
||||||
SimpleDashStrength = 15.0
|
SimpleDashStrength = 15.0
|
||||||
PoweredDashStrength = 50.0
|
PoweredDashStrength = 30.0
|
||||||
AimedDashTime = 0.2
|
AimedDashTime = 0.2
|
||||||
|
PostDashSpeed = 30.0
|
||||||
WallHugGravityLesseningFactor = 15.0
|
WallHugGravityLesseningFactor = 15.0
|
||||||
WallHugDownwardMaxSpeed = 8.0
|
WallHugDownwardMaxSpeed = 8.0
|
||||||
WallHugHorizontalDeceleration = 0.5
|
WallHugHorizontalDeceleration = 0.5
|
||||||
MaxNumberOfDashActions = 2
|
|
||||||
DashTimeDilationCurve = ExtResource("2_2q0ik")
|
|
||||||
|
|
||||||
[node name="InputController" type="Node3D" parent="."]
|
[node name="InputController" type="Node3D" parent="."]
|
||||||
script = ExtResource("16_v31n3")
|
script = ExtResource("16_v31n3")
|
||||||
@ -426,6 +425,12 @@ to = NodePath("../Dashing/AimedDash")
|
|||||||
event = &"aimed_dash"
|
event = &"aimed_dash"
|
||||||
delay_in_seconds = "0.0"
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
|
[node name="OnWeaponDash" type="Node" parent="StateChart/Root/Movement"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../Dashing/ToWeaponDash")
|
||||||
|
event = &"weapon_dash"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Mantling" type="Node" parent="StateChart/Root/Movement"]
|
[node name="Mantling" type="Node" parent="StateChart/Root/Movement"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
@ -503,6 +508,15 @@ script = ExtResource("27_34snm")
|
|||||||
[node name="AimedDash" type="Node" parent="StateChart/Root/Movement/Dashing"]
|
[node name="AimedDash" type="Node" parent="StateChart/Root/Movement/Dashing"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToWeaponDash" type="Node" parent="StateChart/Root/Movement/Dashing"]
|
||||||
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
[node name="ToPlantedWeapon" type="Node" parent="StateChart/Root/Movement/Dashing/ToWeaponDash"]
|
||||||
|
script = ExtResource("28_n7qhm")
|
||||||
|
to = NodePath("../../../OnWall/Hanging")
|
||||||
|
event = &"to_planted"
|
||||||
|
delay_in_seconds = "0.0"
|
||||||
|
|
||||||
[node name="Grounded" type="Node" parent="StateChart/Root/Movement"]
|
[node name="Grounded" type="Node" parent="StateChart/Root/Movement"]
|
||||||
script = ExtResource("27_34snm")
|
script = ExtResource("27_34snm")
|
||||||
|
|
||||||
|
@ -118,6 +118,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
// Dash
|
// Dash
|
||||||
[ExportGroup("Dash")]
|
[ExportGroup("Dash")]
|
||||||
|
[Export(PropertyHint.Range, "0,5,1,or_greater")]
|
||||||
|
public int MaxNumberOfEmpoweredActions { get; set; } = 1;
|
||||||
// Simple dash
|
// Simple dash
|
||||||
[ExportSubgroup("Simple")]
|
[ExportSubgroup("Simple")]
|
||||||
[Export(PropertyHint.Range, "0,50,0.1")]
|
[Export(PropertyHint.Range, "0,50,0.1")]
|
||||||
@ -129,9 +131,13 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
[Export(PropertyHint.Range, "0,100,0.1")]
|
[Export(PropertyHint.Range, "0,100,0.1")]
|
||||||
public float PoweredDashStrength { get; set; } = 10f;
|
public float PoweredDashStrength { get; set; } = 10f;
|
||||||
// Aimed Dash
|
// Aimed Dash
|
||||||
[ExportSubgroup("Aimed")]
|
[ExportSubgroup("Special")]
|
||||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
public float AimedDashTime { get; set; } = 0.1f;
|
public float AimedDashTime { get; set; } = 0.1f;
|
||||||
|
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
||||||
|
public float PostDashSpeed { get; set; } = 100f;
|
||||||
|
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||||
|
public float TimeScaleAimInAir { get; set; } = 0.05f;
|
||||||
|
|
||||||
// Wall hug
|
// Wall hug
|
||||||
[ExportGroup("Wall hug")]
|
[ExportGroup("Wall hug")]
|
||||||
@ -145,16 +151,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
private float _targetSpeed;
|
private float _targetSpeed;
|
||||||
private float _gravity;
|
private float _gravity;
|
||||||
|
|
||||||
[ExportCategory("Other")]
|
|
||||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
|
||||||
public float TimeScaleAimInAir { get; set; } = 0.05f;
|
|
||||||
[Export(PropertyHint.Range, "0,5,1,or_greater")]
|
|
||||||
public int MaxNumberOfDashActions { get; set; } = 1;
|
|
||||||
|
|
||||||
[Export]
|
|
||||||
public Curve DashTimeDilationCurve { get; set; }
|
|
||||||
private bool _canDash = true;
|
|
||||||
|
|
||||||
private int _empoweredActionsLeft;
|
private int _empoweredActionsLeft;
|
||||||
public int EmpoweredActionsLeft
|
public int EmpoweredActionsLeft
|
||||||
{
|
{
|
||||||
@ -167,7 +163,8 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool _isWallJumpAvailable = true;
|
private bool _isWallJumpAvailable = true;
|
||||||
private bool _isActionPerfectlyTimed = false;
|
private bool _canDash = true;
|
||||||
|
private bool _shouldMantleOnDashEnded = false;
|
||||||
|
|
||||||
private StateChart _playerState;
|
private StateChart _playerState;
|
||||||
|
|
||||||
@ -217,7 +214,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
// DashIndicator = GetNode<TextureRect>("%DashIndicator");
|
// DashIndicator = GetNode<TextureRect>("%DashIndicator");
|
||||||
PowerCooldownIndicator = GetNode<ColorRect>("%DashCooldownIndicator");
|
PowerCooldownIndicator = GetNode<ColorRect>("%DashCooldownIndicator");
|
||||||
PowerCooldownIndicator.Visible = false;
|
PowerCooldownIndicator.Visible = false;
|
||||||
EmpoweredActionsLeft = MaxNumberOfDashActions;
|
EmpoweredActionsLeft = MaxNumberOfEmpoweredActions;
|
||||||
_targetSpeed = WalkSpeed;
|
_targetSpeed = WalkSpeed;
|
||||||
|
|
||||||
// Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
|
// Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
|
||||||
@ -330,7 +327,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
HealthSystem.Init(healthSystemParams);
|
HealthSystem.Init(healthSystemParams);
|
||||||
Stamina.SetSpeeds(WalkSpeed, WalkSpeed);
|
Stamina.SetSpeeds(WalkSpeed, WalkSpeed);
|
||||||
|
|
||||||
EmpoweredActionsLeft = MaxNumberOfDashActions;
|
EmpoweredActionsLeft = MaxNumberOfEmpoweredActions;
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Signal setup ///////////
|
// Signal setup ///////////
|
||||||
@ -374,7 +371,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_poweredDash.StateExited += OnPoweredDashFinished;
|
_poweredDash.StateExited += OnPoweredDashFinished;
|
||||||
|
|
||||||
_aimedDash.StateEntered += OnAimedDashStarted;
|
_aimedDash.StateEntered += OnAimedDashStarted;
|
||||||
_aimedDash.StatePhysicsProcessing += HandleAimedDash;
|
|
||||||
_aimedDash.StateExited += OnAimedDashFinished;
|
_aimedDash.StateExited += OnAimedDashFinished;
|
||||||
|
|
||||||
_simpleDashCooldownTimer.Timeout += DashCooldownTimeout;
|
_simpleDashCooldownTimer.Timeout += DashCooldownTimeout;
|
||||||
@ -432,6 +428,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
}
|
}
|
||||||
public void HandleWallHanging(float delta)
|
public void HandleWallHanging(float delta)
|
||||||
{
|
{
|
||||||
|
GD.Print("Hanging");
|
||||||
WallHang(delta);
|
WallHang(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,27 +440,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
MantleToLocation(MantleSystem.FindMantleInFrontOfPlayer().Unwrap());
|
MantleToLocation(MantleSystem.FindMantleInFrontOfPlayer().Unwrap());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (_grounded.Active || _coyoteEnabled.Active)
|
|
||||||
// {
|
|
||||||
// if (_empowerOn.Active && CanPerformEmpoweredAction())
|
|
||||||
// {
|
|
||||||
// PerformEmpoweredAction();
|
|
||||||
// PerformJump(JumpTypes.JumpFromDash);
|
|
||||||
// _playerState.SendEvent("megajump");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if (_doubleJumpEnabled.Active)
|
|
||||||
// if (_empowerOn.Active && CanPerformEmpoweredAction())
|
|
||||||
// {
|
|
||||||
// PerformEmpoweredAction();
|
|
||||||
// PerformJump(JumpTypes.JumpFromDash);
|
|
||||||
// _playerState.SendEvent("megajump");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// PerformJump(JumpTypes.DoubleJump);
|
|
||||||
// else if (_onWall.Active)
|
|
||||||
// JumpFromWall(_empowerOn.Active);
|
|
||||||
|
|
||||||
if (_empowerOn.Active && CanPerformEmpoweredAction())
|
if (_empowerOn.Active && CanPerformEmpoweredAction())
|
||||||
{
|
{
|
||||||
@ -633,7 +609,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
public void PowerCooldownExpired()
|
public void PowerCooldownExpired()
|
||||||
{
|
{
|
||||||
EmpoweredActionsLeft += 1;
|
EmpoweredActionsLeft += 1;
|
||||||
var eventToSend = EmpoweredActionsLeft == MaxNumberOfDashActions ? "fully_charged" : "recharge";
|
var eventToSend = EmpoweredActionsLeft == MaxNumberOfEmpoweredActions ? "fully_charged" : "recharge";
|
||||||
_playerState.SendEvent(eventToSend);
|
_playerState.SendEvent(eventToSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,10 +631,6 @@ 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()
|
||||||
{
|
{
|
||||||
@ -677,7 +649,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
{
|
{
|
||||||
if (_aiming.Active)
|
if (_aiming.Active)
|
||||||
{
|
{
|
||||||
OnWeaponThrown();
|
ThrowWeapon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void OnInputEmpowerDown()
|
public void OnInputEmpowerDown()
|
||||||
@ -688,7 +660,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
{
|
{
|
||||||
_playerState.SendEvent("empower_released");
|
_playerState.SendEvent("empower_released");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnInputDashPressed()
|
public void OnInputDashPressed()
|
||||||
{
|
{
|
||||||
if (_aiming.Active && CanPerformEmpoweredAction())
|
if (_aiming.Active && CanPerformEmpoweredAction())
|
||||||
@ -714,18 +685,25 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
_playerState.SendEvent("dash");
|
_playerState.SendEvent("dash");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAimingEntered()
|
public void OnAimingEntered()
|
||||||
{
|
{
|
||||||
// if (!WeaponSystem.InHandState.Active)
|
if (!CanPerformEmpoweredAction())
|
||||||
// {
|
return;
|
||||||
// OnDashStarted();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if (CanPerformEmpoweredAction())
|
|
||||||
DashSystem.StartPreparingDash();
|
|
||||||
|
|
||||||
if (!isOnFloorCustom() && CanPerformEmpoweredAction())
|
if (WeaponSystem.FlyingState.Active)
|
||||||
|
{
|
||||||
|
DashToFlyingWeapon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WeaponSystem.PlantedState.Active)
|
||||||
|
{
|
||||||
|
DashToPlantedWeapon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DashSystem.StartPreparingDash();
|
||||||
|
if (!isOnFloorCustom())
|
||||||
ReduceTimeScaleWhileAiming();
|
ReduceTimeScaleWhileAiming();
|
||||||
}
|
}
|
||||||
public void HandleAiming(float delta)
|
public void HandleAiming(float delta)
|
||||||
@ -740,41 +718,75 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
DashSystem.StopPreparingDash();
|
DashSystem.StopPreparingDash();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _shouldMantleOnDashEnded = false;
|
public void DashToFlyingWeapon()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("cancel_aim");
|
||||||
|
_playerState.SendEvent("weapon_dash");
|
||||||
|
PerformEmpoweredAction();
|
||||||
|
|
||||||
|
DashSystem.ShouldMantle = false;
|
||||||
|
_dashDirection = (WeaponSystem.GlobalPosition - GlobalPosition).Normalized();
|
||||||
|
|
||||||
|
var dashTween = CreatePositionTween(WeaponSystem.GlobalPosition, AimedDashTime);
|
||||||
|
dashTween.Finished += DashToFlyingWeaponTweenEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DashToFlyingWeaponTweenEnded()
|
||||||
|
{
|
||||||
|
// Get the weapon back
|
||||||
|
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||||
|
AddChild(WeaponRoot);
|
||||||
|
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||||
|
WeaponSystem.ResetWeapon();
|
||||||
|
|
||||||
|
var vel = _dashDirection * PostDashSpeed;
|
||||||
|
SetVelocity(vel);
|
||||||
|
_playerState.SendEvent("dash_finished");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DashToPlantedWeapon()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("cancel_aim");
|
||||||
|
_playerState.SendEvent("weapon_dash");
|
||||||
|
PerformEmpoweredAction();
|
||||||
|
|
||||||
|
DashSystem.ShouldMantle = false;
|
||||||
|
var dashLocation = WeaponSystem.PlantLocation;
|
||||||
|
if (WeaponSystem.IsPlantedInWall())
|
||||||
|
dashLocation += WeaponSystem.PlantNormal * _playerRadius;
|
||||||
|
if (WeaponSystem.IsPlantedUnderPlatform())
|
||||||
|
dashLocation += Vector3.Down * _playerHeight;
|
||||||
|
|
||||||
|
var dashTween = CreatePositionTween(dashLocation, AimedDashTime);
|
||||||
|
dashTween.Finished += DashToPlantedWeaponTweenEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DashToPlantedWeaponTweenEnded()
|
||||||
|
{
|
||||||
|
// Store the weapon state before resetting it
|
||||||
|
var isPlantedOnWall = WeaponSystem.IsPlantedInWall();
|
||||||
|
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
||||||
|
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
||||||
|
|
||||||
|
// Get the weapon back
|
||||||
|
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||||
|
AddChild(WeaponRoot);
|
||||||
|
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||||
|
WeaponSystem.ResetWeapon();
|
||||||
|
|
||||||
|
var resultingEvent = shouldDashToHanging ? "to_planted" : "dash_finished";
|
||||||
|
_playerState.SendEvent(resultingEvent);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnAimedDashStarted()
|
public void OnAimedDashStarted()
|
||||||
{
|
{
|
||||||
// if (WeaponSystem.FlyingState.Active)
|
|
||||||
// {
|
|
||||||
// DashSystem.ShouldMantle = false;
|
|
||||||
// DashSystem.PlannedPlayerLocation = WeaponSystem.GlobalPosition;
|
|
||||||
// }
|
|
||||||
// else if (WeaponSystem.PlantedState.Active)
|
|
||||||
// {
|
|
||||||
// DashSystem.ShouldMantle = false;
|
|
||||||
// var dashLocation = WeaponSystem.PlantLocation;
|
|
||||||
// if (WeaponSystem.IsPlantedInWall())
|
|
||||||
// {
|
|
||||||
// dashLocation += WeaponSystem.PlantNormal * 0.5f; // Player radius
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (WeaponSystem.IsPlantedUnderPlatform())
|
|
||||||
// {
|
|
||||||
// dashLocation += Vector3.Down * 1f; // Player height
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// DashSystem.PlannedPlayerLocation = dashLocation;
|
|
||||||
// }
|
|
||||||
// _dashDirection = (DashSystem.PlannedPlayerLocation - GlobalPosition).Normalized();
|
|
||||||
|
|
||||||
// Adjusting for player height, where the middle of the capsule should get to the dash location instead of the
|
// Adjusting for player height, where the middle of the capsule should get to the dash location instead of the
|
||||||
// feet of the capsule
|
// feet of the capsule
|
||||||
// GD.Print(DashSystem.CollisionNormal);
|
|
||||||
var correction = DashSystem.CollisionNormal == Vector3.Down ? _playerHeight : DashSystem.DashCastRadius;
|
var correction = DashSystem.CollisionNormal == Vector3.Down ? _playerHeight : DashSystem.DashCastRadius;
|
||||||
var correctedLocation = DashSystem.PlannedLocation + Vector3.Down * correction;
|
var correctedLocation = DashSystem.PlannedLocation + Vector3.Down * correction;
|
||||||
|
|
||||||
var dashTween = CreatePositionTween(correctedLocation, AimedDashTime);
|
var dashTween = CreatePositionTween(correctedLocation, AimedDashTime);
|
||||||
dashTween.TweenMethod(Callable.From<float>(AimedDashTweenOngoing), 0.0f, 1.0f, AimedDashTime);
|
// dashTween.TweenMethod(Callable.From<float>(AimedDashTweenOngoing), 0.0f, 1.0f, AimedDashTime);
|
||||||
dashTween.Finished += AimedDashTweenEnded;
|
dashTween.Finished += AimedDashTweenEnded;
|
||||||
|
|
||||||
_shouldMantleOnDashEnded = DashSystem.ShouldMantle;
|
_shouldMantleOnDashEnded = DashSystem.ShouldMantle;
|
||||||
@ -791,19 +803,27 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
return tween;
|
return tween;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleAimedDash(float delta)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AimedDashTweenOngoing(float progress)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AimedDashTweenEnded()
|
public void AimedDashTweenEnded()
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("dash_finished");
|
_playerState.SendEvent("dash_finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ThrowWeapon()
|
||||||
|
{
|
||||||
|
_playerState.SendEvent("cancel_aim");
|
||||||
|
|
||||||
|
RemoveChild(WeaponRoot);
|
||||||
|
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||||
|
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||||
|
|
||||||
|
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.PlannedLocation;
|
||||||
|
WeaponSystem.ThrowWeapon(
|
||||||
|
weaponTargetLocation,
|
||||||
|
DashSystem.HasHit,
|
||||||
|
DashSystem.CollisionPoint,
|
||||||
|
DashSystem.CollisionNormal);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnAimedDashFinished()
|
public void OnAimedDashFinished()
|
||||||
{
|
{
|
||||||
@ -848,7 +868,9 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
|
|
||||||
public void OnPoweredDashFinished()
|
public void OnPoweredDashFinished()
|
||||||
{
|
{
|
||||||
// Try mantling here
|
// Try mantling but don't know if this is useful
|
||||||
|
if (CanMantle())
|
||||||
|
MantleToLocation(MantleSystem.FindMantleInFrontOfPlayer().Unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishPoweredDash()
|
public void FinishPoweredDash()
|
||||||
@ -902,96 +924,6 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
_playerState.SendEvent("grounded");
|
_playerState.SendEvent("grounded");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dashing and weapon throwing
|
|
||||||
public void OnDashStarted()
|
|
||||||
{
|
|
||||||
if (!CanPerformEmpoweredAction())
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("aim_canceled");
|
|
||||||
_playerState.SendEvent("dash_ended");
|
|
||||||
DashSystem.StopPreparingDash();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PerformEmpoweredAction();
|
|
||||||
if (WeaponSystem.FlyingState.Active)
|
|
||||||
{
|
|
||||||
DashSystem.ShouldMantle = false;
|
|
||||||
DashSystem.PlannedLocation = WeaponSystem.GlobalPosition;
|
|
||||||
}
|
|
||||||
else if (WeaponSystem.PlantedState.Active)
|
|
||||||
{
|
|
||||||
DashSystem.ShouldMantle = false;
|
|
||||||
var dashLocation = WeaponSystem.PlantLocation;
|
|
||||||
if (WeaponSystem.IsPlantedInWall())
|
|
||||||
{
|
|
||||||
dashLocation += WeaponSystem.PlantNormal * 0.5f; // Player radius
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WeaponSystem.IsPlantedUnderPlatform())
|
|
||||||
{
|
|
||||||
dashLocation += Vector3.Down * 1f; // Player height
|
|
||||||
}
|
|
||||||
|
|
||||||
DashSystem.PlannedLocation = dashLocation;
|
|
||||||
}
|
|
||||||
_dashDirection = (DashSystem.PlannedLocation - GlobalPosition).Normalized();
|
|
||||||
}
|
|
||||||
public void OnDashEnded()
|
|
||||||
{
|
|
||||||
// Regular dash
|
|
||||||
if (WeaponSystem.InHandState.Active)
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("dash_ended");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the weapon state before resetting it
|
|
||||||
var isPlantedOnWall = WeaponSystem.IsPlantedInWall();
|
|
||||||
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
|
||||||
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
|
||||||
var isFlying = WeaponSystem.FlyingState.Active;
|
|
||||||
|
|
||||||
// Get the weapon back
|
|
||||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
|
||||||
AddChild(WeaponRoot);
|
|
||||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
|
||||||
WeaponSystem.ResetWeapon();
|
|
||||||
|
|
||||||
if (isFlying)
|
|
||||||
{
|
|
||||||
var vel = _dashDirection * DashSystem.PostDashSpeed;
|
|
||||||
SetVelocity(vel);
|
|
||||||
_playerState.SendEvent("dash_ended");
|
|
||||||
return; // In case states aren't exclusives
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldDashToHanging)
|
|
||||||
{
|
|
||||||
_playerState.SendEvent("dash_to_planted");
|
|
||||||
return; // In case states aren't exclusives
|
|
||||||
}
|
|
||||||
|
|
||||||
// Weapon planted anywhere else
|
|
||||||
_playerState.SendEvent("dash_ended");
|
|
||||||
}
|
|
||||||
public void OnWeaponThrown()
|
|
||||||
{
|
|
||||||
DashSystem.StopPreparingDash();
|
|
||||||
_playerState.SendEvent("cancel_aim");
|
|
||||||
|
|
||||||
RemoveChild(WeaponRoot);
|
|
||||||
GetTree().GetRoot().AddChild(WeaponRoot);
|
|
||||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
|
||||||
|
|
||||||
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.TargetLocation;
|
|
||||||
WeaponSystem.ThrowWeapon(
|
|
||||||
weaponTargetLocation,
|
|
||||||
DashSystem.HasHit,
|
|
||||||
DashSystem.CollisionPoint,
|
|
||||||
DashSystem.CollisionNormal);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regular processes
|
// Regular processes
|
||||||
public void HandleWeaponInHand(float delta)
|
public void HandleWeaponInHand(float delta)
|
||||||
{
|
{
|
||||||
@ -1142,10 +1074,7 @@ public partial class PlayerController : CharacterBody3D
|
|||||||
///////////////////////////
|
///////////////////////////
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
TweenQueueSystem.ProcessTweens();
|
|
||||||
|
|
||||||
LookAround();
|
LookAround();
|
||||||
// MoveAround(delta);
|
|
||||||
CameraModifications((float) delta);
|
CameraModifications((float) delta);
|
||||||
HandleStairs((float) delta);
|
HandleStairs((float) delta);
|
||||||
}
|
}
|
||||||
|
@ -74,25 +74,6 @@ public partial class DashSystem: Node3D
|
|||||||
_dashIndicatorAnim = GetNode<AnimationPlayer>("DashIndicator/AnimationPlayer");
|
_dashIndicatorAnim = GetNode<AnimationPlayer>("DashIndicator/AnimationPlayer");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 RecurseThroughCollisions(Vector3 previousCollisionPoint, Vector3 previousNormal, int recursionDepth)
|
|
||||||
{
|
|
||||||
if (recursionDepth == 0)
|
|
||||||
return previousCollisionPoint;
|
|
||||||
|
|
||||||
var startPoint = previousCollisionPoint + previousNormal*_playerHeight;
|
|
||||||
_playerCast3D.SetGlobalPosition(startPoint);
|
|
||||||
_playerCast3D.SetTargetPosition(-previousNormal*_playerRadius);
|
|
||||||
|
|
||||||
var hasHit = _playerCast3D.IsColliding();
|
|
||||||
if (!hasHit)
|
|
||||||
return previousCollisionPoint;
|
|
||||||
|
|
||||||
return RecurseThroughCollisions(
|
|
||||||
_playerCast3D.GetCollisionPoint(0),
|
|
||||||
_playerCast3D.GetCollisionNormal(0),
|
|
||||||
recursionDepth - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DashLocation ComputeDashLocation()
|
private DashLocation ComputeDashLocation()
|
||||||
{
|
{
|
||||||
var targetLocation = _dashCast3D.ToGlobal(_dashCast3D.TargetPosition);
|
var targetLocation = _dashCast3D.ToGlobal(_dashCast3D.TargetPosition);
|
||||||
@ -109,18 +90,6 @@ public partial class DashSystem: Node3D
|
|||||||
var globalSweepPath = targetLocation - _dashCast3D.GlobalPosition;
|
var globalSweepPath = targetLocation - _dashCast3D.GlobalPosition;
|
||||||
var locationAlongPath = _dashCast3D.GlobalPosition + globalSweepPath * fraction;
|
var locationAlongPath = _dashCast3D.GlobalPosition + globalSweepPath * fraction;
|
||||||
return new DashLocation(true, locationAlongPath, collisionPoint, collisionNormal);
|
return new DashLocation(true, locationAlongPath, collisionPoint, collisionNormal);
|
||||||
|
|
||||||
// // Pushes the point down when dashing to under a platform so head doesn't clip
|
|
||||||
// var maxPushDownDistance = 0.9f;
|
|
||||||
// var correctionProportion = (float) Mathf.Remap(CollisionNormal.Y, -0.5, -1, 0, 1);
|
|
||||||
// var proportion = (float)Mathf.Remap(_dashCast3D.GlobalRotation.X, 0, 1.57, 0, 1);
|
|
||||||
// var finalLocation = locationAlongPath
|
|
||||||
// + CollisionNormal
|
|
||||||
// * maxPushDownDistance
|
|
||||||
// * Mathf.Clamp(proportion, 0, 1)
|
|
||||||
// * Mathf.Clamp(correctionProportion, 0, 1);
|
|
||||||
//
|
|
||||||
// return new DashLocation(true, finalLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareDash()
|
public void PrepareDash()
|
||||||
|
@ -54,7 +54,7 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
PlantLocation = collisionLocation;
|
PlantLocation = collisionLocation;
|
||||||
PlantNormal = collisionNormal;
|
PlantNormal = collisionNormal;
|
||||||
LookAt(end);
|
LookAt(end);
|
||||||
|
|
||||||
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
|
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, StraightThrowDuration));
|
||||||
if (hasHit)
|
if (hasHit)
|
||||||
tween.Finished += PlantWeaponInWall;
|
tween.Finished += PlantWeaponInWall;
|
||||||
|
Reference in New Issue
Block a user