gd: state getters
This commit is contained in:
@ -41,11 +41,20 @@ public partial class PlayerController : CharacterBody3D
|
||||
private bool _dashCanceled;
|
||||
|
||||
private StateChart _playerState;
|
||||
// Actions state
|
||||
private StateChartState _weaponInHand;
|
||||
private StateChartState _aiming;
|
||||
private StateChartState _dashing;
|
||||
private StateChartState _weaponThrown;
|
||||
private StateChartState _hanging;
|
||||
private StateChartState _actionHanging;
|
||||
// Movement state
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _movHanging;
|
||||
private StateChartState _wallHugging;
|
||||
private StateChartState _airborne;
|
||||
private StateChartState _coyoteEnabled;
|
||||
private StateChartState _doubleJumpEnabled;
|
||||
private StateChartState _falling;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@ -93,11 +102,20 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
// State management
|
||||
_playerState = StateChart.Of(GetNode("StateChart"));
|
||||
_weaponInHand = StateChartState.Of(GetNode("StateChart/Root/WeaponInHand"));
|
||||
_aiming = StateChartState.Of(GetNode("StateChart/Root/Aiming"));
|
||||
_dashing = StateChartState.Of(GetNode("StateChart/Root/Dashing"));
|
||||
_weaponThrown = StateChartState.Of(GetNode("StateChart/Root/WeaponThrown"));
|
||||
_hanging = StateChartState.Of(GetNode("StateChart/Root/Hanging"));
|
||||
// Actions states
|
||||
_weaponInHand = StateChartState.Of(GetNode("StateChart/Root/Actions/WeaponInHand"));
|
||||
_aiming = StateChartState.Of(GetNode("StateChart/Root/Actions/Aiming"));
|
||||
_dashing = StateChartState.Of(GetNode("StateChart/Root/Actions/Dashing"));
|
||||
_weaponThrown = StateChartState.Of(GetNode("StateChart/Root/Actions/WeaponThrown"));
|
||||
_actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||
// Movement states
|
||||
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
|
||||
_movHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/Hanging"));
|
||||
_wallHugging = StateChartState.Of(GetNode("StateChart/Root/Movement/WallHugging"));
|
||||
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
||||
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
|
||||
_doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||
_falling = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/Falling"));
|
||||
|
||||
///////////////////////////
|
||||
// Initialize components //
|
||||
@ -162,19 +180,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
_dashDirection = (DashSystem.DashResolve.DashLocation - GlobalPosition).Normalized();
|
||||
DashSystem.Dash();
|
||||
}
|
||||
|
||||
public void OnWeaponThrown()
|
||||
{
|
||||
RemoveChild(WeaponRoot);
|
||||
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
|
||||
var (hasHit, location, collisionPoint, collisionNormal) = DashSystem.DashComputation;
|
||||
var (endWithMantle, dashLocation, mantleLocation) = DashSystem.DashResolve;
|
||||
|
||||
DashSystem.CancelDash();
|
||||
WeaponSystem.ThrowWeapon(location, hasHit, collisionPoint, collisionNormal);
|
||||
}
|
||||
|
||||
public void OnDashEnded()
|
||||
{
|
||||
@ -215,6 +220,19 @@ public partial class PlayerController : CharacterBody3D
|
||||
_playerState.SendEvent("dash_ended");
|
||||
}
|
||||
|
||||
public void OnWeaponThrown()
|
||||
{
|
||||
RemoveChild(WeaponRoot);
|
||||
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
|
||||
var (hasHit, location, collisionPoint, collisionNormal) = DashSystem.DashComputation;
|
||||
var (endWithMantle, dashLocation, mantleLocation) = DashSystem.DashResolve;
|
||||
|
||||
DashSystem.CancelDash();
|
||||
WeaponSystem.ThrowWeapon(location, hasHit, collisionPoint, collisionNormal);
|
||||
}
|
||||
|
||||
public void OnInputMove(Vector3 value)
|
||||
{
|
||||
_inputMove = value;
|
||||
@ -277,7 +295,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
isOnFloorCustom(),
|
||||
isPlayerDead,
|
||||
isHeadTouchingCeiling,
|
||||
_hanging.Active);
|
||||
_actionHanging.Active);
|
||||
MoveSystem.MoveAround(moveAroundParams);
|
||||
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
|
Reference in New Issue
Block a user