lots of tutorial fixed
This commit is contained in:
@@ -8,6 +8,13 @@ using RustyOptions;
|
||||
|
||||
public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
public enum AllowedInputs
|
||||
{
|
||||
All,
|
||||
MoveCamera,
|
||||
None,
|
||||
}
|
||||
|
||||
// User API to important child nodes.
|
||||
public HeadSystem HeadSystem;
|
||||
public Bobbing Bobbing;
|
||||
@@ -44,7 +51,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private float _inputRotateY;
|
||||
private float _inputRotateFloorplane;
|
||||
|
||||
private int _framesSinceJumpAtApex = 0;
|
||||
private int _framesSinceJumpAtApex;
|
||||
|
||||
// Timers
|
||||
private Timer _timeScaleAimInAirTimer;
|
||||
@@ -158,12 +165,14 @@ public partial class PlayerController : CharacterBody3D
|
||||
PlayerUi.SetNumberOfDashesLeft(value);
|
||||
}
|
||||
}
|
||||
public bool TutorialDone { get; set; } = false;
|
||||
public bool TutorialDone { get; set; }
|
||||
|
||||
public AllowedInputs CurrentlyAllowedInputs { get; set; } = AllowedInputs.All;
|
||||
|
||||
private bool _canDashAirborne = true;
|
||||
private bool _isWallJumpAvailable = true;
|
||||
private bool _canDash = true;
|
||||
private bool _shouldMantleOnDashEnded = false;
|
||||
private bool _shouldMantleOnDashEnded;
|
||||
|
||||
private StateChart _playerState;
|
||||
|
||||
@@ -198,20 +207,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var config = new ConfigFile();
|
||||
LoadSettings();
|
||||
|
||||
// Load data from a file.
|
||||
Error err = config.Load("user://config.cfg");
|
||||
|
||||
// If the file didn't load, ignore it.
|
||||
if (err != Error.Ok)
|
||||
{
|
||||
throw new Exception("Couldn't load config.cfg");
|
||||
}
|
||||
|
||||
_lookSensitivityMultiplier = (float) config.GetValue("InputSettings", "LookSensitivity", 1.0f);
|
||||
_headBobbingMultiplier = (float) config.GetValue("InputSettings", "HeadBobbingWhileWalking", 1.0f);
|
||||
_fovChangeMultiplier = (float) config.GetValue("InputSettings", "FovChangeWithSpeed", 1.0f);
|
||||
///////////////////////////
|
||||
// Getting components /////
|
||||
///////////////////////////
|
||||
@@ -385,10 +382,40 @@ public partial class PlayerController : CharacterBody3D
|
||||
_onMegajumpFromWall.Taken += OnMegajumpFromWall;
|
||||
}
|
||||
|
||||
public void SetAllowedInputsAll()
|
||||
{
|
||||
CurrentlyAllowedInputs = AllowedInputs.All;
|
||||
}
|
||||
public void SetAllowedInputsMoveCamera()
|
||||
{
|
||||
CurrentlyAllowedInputs = AllowedInputs.MoveCamera;
|
||||
}
|
||||
public void SetAllowedInputsNone()
|
||||
{
|
||||
CurrentlyAllowedInputs = AllowedInputs.None;
|
||||
}
|
||||
|
||||
public void LoadSettings()
|
||||
{
|
||||
var config = new ConfigFile();
|
||||
|
||||
// Load data from a file.
|
||||
Error err = config.Load("user://config.cfg");
|
||||
|
||||
// If the file didn't load, ignore it.
|
||||
if (err != Error.Ok)
|
||||
{
|
||||
throw new Exception("Couldn't load config.cfg");
|
||||
}
|
||||
|
||||
_lookSensitivityMultiplier = (float) config.GetValue("InputSettings", "LookSensitivity", 1.0f);
|
||||
_headBobbingMultiplier = (float) config.GetValue("InputSettings", "HeadBobbingWhileWalking", 1.0f);
|
||||
_fovChangeMultiplier = (float) config.GetValue("InputSettings", "FovChangeWithSpeed", 1.0f);
|
||||
}
|
||||
|
||||
public void OnTutorialDone(Node3D _)
|
||||
{
|
||||
TutorialDone = true;
|
||||
GD.Print("tutorial done");
|
||||
}
|
||||
|
||||
public void OnWallDetected()
|
||||
@@ -476,6 +503,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
public void OnDoubleJumpStarted()
|
||||
{
|
||||
_canDash = true;
|
||||
OnJumpStarted(DoubleJumpStartVelocity);
|
||||
}
|
||||
public void OnMegaJumpStarted()
|
||||
@@ -508,7 +536,10 @@ public partial class PlayerController : CharacterBody3D
|
||||
var wallNormal = WallHugSystem.GetWallNormal().UnwrapOr(Vector3.Up);
|
||||
var jumpVector = wallNormal * jumpStrength;
|
||||
|
||||
SetHorizontalVelocity(new Vector2(jumpVector.X, jumpVector.Z));
|
||||
var currentHorizontalVelocity = new Vector2(Velocity.X, Velocity.Z);
|
||||
var wallJumpHorizontalVelocity = new Vector2(jumpVector.X, jumpVector.Z);
|
||||
|
||||
SetHorizontalVelocity(currentHorizontalVelocity + wallJumpHorizontalVelocity);;
|
||||
}
|
||||
public void OnJumpFromWall()
|
||||
{
|
||||
@@ -661,11 +692,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
public void OnInputEmpowerDown()
|
||||
{
|
||||
_playerState.SendEvent("empower_down");
|
||||
// _playerState.SendEvent("empower_down");
|
||||
}
|
||||
public void OnInputEmpowerReleased()
|
||||
{
|
||||
_playerState.SendEvent("empower_released");
|
||||
// _playerState.SendEvent("empower_released");
|
||||
}
|
||||
public void OnInputDashPressed()
|
||||
{
|
||||
@@ -747,11 +778,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void DashToFlyingWeaponTweenEnded()
|
||||
{
|
||||
// Get the weapon back
|
||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||
AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
WeaponSystem.ResetWeapon();
|
||||
RecoverWeapon();
|
||||
|
||||
var vel = _dashDirection * PostDashSpeed;
|
||||
SetVelocity(vel);
|
||||
@@ -774,6 +801,14 @@ public partial class PlayerController : CharacterBody3D
|
||||
var dashTween = CreatePositionTween(dashLocation, AimedDashTime);
|
||||
dashTween.Finished += DashToPlantedWeaponTweenEnded;
|
||||
}
|
||||
|
||||
public void RecoverWeapon()
|
||||
{
|
||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||
AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
WeaponSystem.ResetWeapon();
|
||||
}
|
||||
|
||||
public void DashToPlantedWeaponTweenEnded()
|
||||
{
|
||||
@@ -782,12 +817,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
||||
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
||||
|
||||
// Get the weapon back
|
||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||
AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
WeaponSystem.ResetWeapon();
|
||||
|
||||
RecoverWeapon();
|
||||
|
||||
var resultingEvent = shouldDashToHanging ? "to_planted" : "dash_finished";
|
||||
_playerState.SendEvent(resultingEvent);
|
||||
}
|
||||
@@ -976,7 +1007,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
IsCapsuleHeightLessThanNormal = CapsuleCollider.IsCapsuleHeightLessThanNormal(),
|
||||
CurrentSpeedGreaterThanWalkSpeed = false,
|
||||
IsCrouchingHeight = CapsuleCollider.IsCrouchingHeight(),
|
||||
Delta = (float)delta,
|
||||
Delta = delta,
|
||||
FloorMaxAngle = FloorMaxAngle,
|
||||
GlobalPositionFromDriver = GlobalPosition,
|
||||
Velocity = Velocity,
|
||||
|
||||
Reference in New Issue
Block a user