improved weapon system and cleaner weapon setup
This commit is contained in:
@@ -272,9 +272,7 @@ collision_mask = 256
|
|||||||
DashSpeed = 0.2
|
DashSpeed = 0.2
|
||||||
PostDashSpeed = 30.0
|
PostDashSpeed = 30.0
|
||||||
|
|
||||||
[node name="WeaponRoot" type="Node3D" parent="."]
|
[node name="WeaponSystem" parent="." instance=ExtResource("29_wv70j")]
|
||||||
|
|
||||||
[node name="WeaponSystem" parent="WeaponRoot" instance=ExtResource("29_wv70j")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.173648, -0.984808, 0, 0.984808, 0.173648, 0.45268, 1.44035, -0.692528)
|
transform = Transform3D(1, 0, 0, 0, 0.173648, -0.984808, 0, 0.984808, 0.173648, 0.45268, 1.44035, -0.692528)
|
||||||
mass = 10.0
|
mass = 10.0
|
||||||
gravity_scale = 3.0
|
gravity_scale = 3.0
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
public DashSystem DashSystem;
|
public DashSystem DashSystem;
|
||||||
public CollisionShape3D StandingCollider;
|
public CollisionShape3D StandingCollider;
|
||||||
public CollisionShape3D SlideCollider;
|
public CollisionShape3D SlideCollider;
|
||||||
public Node3D WeaponRoot;
|
|
||||||
public WeaponSystem WeaponSystem;
|
public WeaponSystem WeaponSystem;
|
||||||
public WallHugSystem WallHugSystem;
|
public WallHugSystem WallHugSystem;
|
||||||
public PlayerUi PlayerUi;
|
public PlayerUi PlayerUi;
|
||||||
@@ -309,6 +308,8 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
private StateChartState _onWallHanging;
|
private StateChartState _onWallHanging;
|
||||||
private StateChartState _onWallRunning;
|
private StateChartState _onWallRunning;
|
||||||
|
|
||||||
|
private Transition _onDashEnded;
|
||||||
|
|
||||||
private Transition _onJumpFromWall;
|
private Transition _onJumpFromWall;
|
||||||
private Transition _onJumpFromWallFalling;
|
private Transition _onJumpFromWallFalling;
|
||||||
private Transition _onLeaveWallFromRun;
|
private Transition _onLeaveWallFromRun;
|
||||||
@@ -342,8 +343,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
Node3D cameraSmooth = GetNode<Node3D>("HeadSystem/CameraSmooth");
|
Node3D cameraSmooth = GetNode<Node3D>("HeadSystem/CameraSmooth");
|
||||||
|
|
||||||
// Movement stuff
|
// Movement stuff
|
||||||
WeaponRoot = GetNode<Node3D>("WeaponRoot");
|
WeaponSystem = GetNode<WeaponSystem>("WeaponSystem");
|
||||||
WeaponSystem = GetNode<WeaponSystem>("WeaponRoot/WeaponSystem");
|
|
||||||
MantleSystem = GetNode<MantleSystem>("HeadSystem/MantleSystem");
|
MantleSystem = GetNode<MantleSystem>("HeadSystem/MantleSystem");
|
||||||
StandingCollider = GetNode<CollisionShape3D>("StandingCollider");
|
StandingCollider = GetNode<CollisionShape3D>("StandingCollider");
|
||||||
SlideCollider = GetNode<CollisionShape3D>("SlideCollider");
|
SlideCollider = GetNode<CollisionShape3D>("SlideCollider");
|
||||||
@@ -384,6 +384,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
_airGlidingDoubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"));
|
_airGlidingDoubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled"));
|
||||||
_onGroundSlideJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide/OnJump"));
|
_onGroundSlideJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide/OnJump"));
|
||||||
_onAirGlideDoubleJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled/OnJump"));
|
_onAirGlideDoubleJump = Transition.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlideDoubleJumpEnabled/OnJump"));
|
||||||
|
_onDashEnded = Transition.Of(GetNode("StateChart/Root/Movement/Dashing/OnDashEnded"));
|
||||||
|
|
||||||
// _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
// _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||||
_powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired"));
|
_powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired"));
|
||||||
@@ -495,6 +496,9 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
_onWallHanging.StatePhysicsProcessing += HandleWallHanging;
|
_onWallHanging.StatePhysicsProcessing += HandleWallHanging;
|
||||||
_onWallRunning.StatePhysicsProcessing += HandleWallRunning;
|
_onWallRunning.StatePhysicsProcessing += HandleWallRunning;
|
||||||
|
|
||||||
|
_onWallHanging.StateExited += RecoverWeapon;
|
||||||
|
_onDashEnded.Taken += RecoverWeapon;
|
||||||
|
|
||||||
_onJumpFromWall.Taken += OnJumpFromWall;
|
_onJumpFromWall.Taken += OnJumpFromWall;
|
||||||
_onJumpFromWallFalling.Taken += OnJumpFromWall;
|
_onJumpFromWallFalling.Taken += OnJumpFromWall;
|
||||||
_onLeaveWallFromRun.Taken += OnLeaveWallFromRun;
|
_onLeaveWallFromRun.Taken += OnLeaveWallFromRun;
|
||||||
@@ -542,9 +546,9 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
if (TutorialDone)
|
if (TutorialDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RemoveChild(WeaponRoot);
|
RemoveChild(WeaponSystem);
|
||||||
GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, WeaponRoot);
|
GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, WeaponSystem);
|
||||||
WeaponRoot.CallDeferred(Node3D.MethodName.SetGlobalPosition, TutorialWeaponTarget.GlobalPosition);
|
WeaponSystem.CallDeferred(Node3D.MethodName.SetGlobalPosition, TutorialWeaponTarget.GlobalPosition);
|
||||||
WeaponSystem.CallDeferred(WeaponSystem.MethodName.PlaceWeaponForTutorial, TutorialWeaponTarget.GlobalPosition);
|
WeaponSystem.CallDeferred(WeaponSystem.MethodName.PlaceWeaponForTutorial, TutorialWeaponTarget.GlobalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -820,10 +824,6 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
FovMultiplier: _fovChangeMultiplier);
|
FovMultiplier: _fovChangeMultiplier);
|
||||||
HeadSystem.LookAround(lookAroundInputs);
|
HeadSystem.LookAround(lookAroundInputs);
|
||||||
}
|
}
|
||||||
public void RotateWeaponWithPlayer()
|
|
||||||
{
|
|
||||||
WeaponRoot.SetRotation(HeadSystem.Rotation);
|
|
||||||
}
|
|
||||||
public Vector3 GetGlobalForwardFacingVector()
|
public Vector3 GetGlobalForwardFacingVector()
|
||||||
{
|
{
|
||||||
return Transform.Basis * HeadSystem.Transform.Basis * Vector3.Forward;
|
return Transform.Basis * HeadSystem.Transform.Basis * Vector3.Forward;
|
||||||
@@ -1554,9 +1554,6 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
}
|
}
|
||||||
public void HandleAiming(float delta)
|
public void HandleAiming(float delta)
|
||||||
{
|
{
|
||||||
if (WeaponSystem.InHandState.Active)
|
|
||||||
RotateWeaponWithPlayer();
|
|
||||||
|
|
||||||
DashIndicatorMeshCylinder.Height = DashSystem.PlannedLocation.DistanceTo(GlobalPosition);
|
DashIndicatorMeshCylinder.Height = DashSystem.PlannedLocation.DistanceTo(GlobalPosition);
|
||||||
DashIndicatorNode.LookAt(DashSystem.PlannedLocation);
|
DashIndicatorNode.LookAt(DashSystem.PlannedLocation);
|
||||||
|
|
||||||
@@ -1624,7 +1621,8 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
public void ThrowWeapon()
|
public void ThrowWeapon()
|
||||||
{
|
{
|
||||||
_playerState.SendEvent("cancel_aim");
|
_playerState.SendEvent("cancel_aim");
|
||||||
RemoveChildNode(WeaponRoot);
|
RemoveChildNode(WeaponSystem);
|
||||||
|
HeadSystem.HideWeapon();
|
||||||
|
|
||||||
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.PlannedLocation;
|
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.PlannedLocation;
|
||||||
WeaponSystem.ThrowWeapon(
|
WeaponSystem.ThrowWeapon(
|
||||||
@@ -1635,7 +1633,10 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
}
|
}
|
||||||
public void RecoverWeapon()
|
public void RecoverWeapon()
|
||||||
{
|
{
|
||||||
RecoverChildNode(WeaponRoot);
|
if (WeaponSystem.GetParent() == this) return;
|
||||||
|
|
||||||
|
HeadSystem.ShowWeapon();
|
||||||
|
RecoverChildNode(WeaponSystem);
|
||||||
WeaponSystem.ResetWeapon();
|
WeaponSystem.ResetWeapon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1688,8 +1689,6 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
var isPlantedUnderPlatform = WeaponSystem.IsPlantedUnderPlatform();
|
||||||
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
var shouldDashToHanging = isPlantedOnWall || isPlantedUnderPlatform;
|
||||||
|
|
||||||
RecoverWeapon();
|
|
||||||
|
|
||||||
var resultingEvent = shouldDashToHanging ? "dash_to_planted" : "dash_finished";
|
var resultingEvent = shouldDashToHanging ? "dash_to_planted" : "dash_finished";
|
||||||
_playerState.SendEvent(resultingEvent);
|
_playerState.SendEvent(resultingEvent);
|
||||||
}
|
}
|
||||||
@@ -1705,8 +1704,6 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
MoveSlideAndHandleStairs((float) delta);
|
MoveSlideAndHandleStairs((float) delta);
|
||||||
MantleSystem.ProcessMantle(_grounded.Active);
|
MantleSystem.ProcessMantle(_grounded.Active);
|
||||||
|
|
||||||
if (WeaponSystem.InHandState.Active)
|
|
||||||
RotateWeaponWithPlayer();
|
|
||||||
if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
|
if (WeaponSystem.InHandState.Active && !_aiming.Active && TutorialDone)
|
||||||
{
|
{
|
||||||
DashIndicatorMesh.Visible = false;
|
DashIndicatorMesh.Visible = false;
|
||||||
|
|||||||
@@ -184,6 +184,15 @@ public partial class HeadSystem : Node3D
|
|||||||
_camera.Fov = Mathf.Lerp(_camera.Fov, targetFov, (float) delta * FovChangeSpeed);
|
_camera.Fov = Mathf.Lerp(_camera.Fov, targetFov, (float) delta * FovChangeSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void HideWeapon()
|
||||||
|
{
|
||||||
|
_fpRig.Visible = false;
|
||||||
|
}
|
||||||
|
public void ShowWeapon()
|
||||||
|
{
|
||||||
|
_fpRig.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
public float ComputeCameraInclineFactor(Vector3 direction)
|
public float ComputeCameraInclineFactor(Vector3 direction)
|
||||||
{
|
{
|
||||||
var forward = GetForwardHorizontalVector().Normalized();
|
var forward = GetForwardHorizontalVector().Normalized();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
private TweenQueueSystem _tweenQueueSystem;
|
private TweenQueueSystem _tweenQueueSystem;
|
||||||
|
|
||||||
private Transform3D _startTransform;
|
private Transform3D _startTransform;
|
||||||
|
private Transform3D _startMeshTransform;
|
||||||
|
|
||||||
private Vector3 _throwDirection;
|
private Vector3 _throwDirection;
|
||||||
public Vector3 PlantLocation { get; set; }
|
public Vector3 PlantLocation { get; set; }
|
||||||
@@ -36,7 +37,6 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
public MeshInstance3D WeaponLocationIndicator { get; set; }
|
public MeshInstance3D WeaponLocationIndicator { get; set; }
|
||||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; }
|
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; }
|
||||||
public MeshInstance3D WeaponMesh { get; set; }
|
public MeshInstance3D WeaponMesh { get; set; }
|
||||||
public StandardMaterial3D WeaponMaterial { get; set; }
|
|
||||||
|
|
||||||
public void Init(Node3D head, Camera3D camera)
|
public void Init(Node3D head, Camera3D camera)
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
WeaponLocationIndicatorMaterial = WeaponLocationIndicator.GetActiveMaterial(0) as StandardMaterial3D;
|
WeaponLocationIndicatorMaterial = WeaponLocationIndicator.GetActiveMaterial(0) as StandardMaterial3D;
|
||||||
|
|
||||||
WeaponMesh = GetNode<MeshInstance3D>("Weapon");
|
WeaponMesh = GetNode<MeshInstance3D>("Weapon");
|
||||||
WeaponMaterial = WeaponMesh.GetActiveMaterial(0) as StandardMaterial3D;
|
_startMeshTransform = WeaponMesh.Transform;
|
||||||
|
|
||||||
_tweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
|
_tweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
|
||||||
_tweenQueueSystem.Init(this);
|
_tweenQueueSystem.Init(this);
|
||||||
@@ -71,16 +71,14 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
public void WeaponLeft()
|
public void WeaponLeft()
|
||||||
{
|
{
|
||||||
Visible = true;
|
Visible = true;
|
||||||
WeaponLocationIndicator.Visible = true;
|
// WeaponLocationIndicator.Visible = true;
|
||||||
WeaponMaterial!.UseFovOverride = false;
|
|
||||||
EmitSignalWeaponThrown();
|
EmitSignalWeaponThrown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WeaponBack()
|
public void WeaponBack()
|
||||||
{
|
{
|
||||||
Visible = false;
|
Visible = false;
|
||||||
WeaponLocationIndicator.Visible = false;
|
// WeaponLocationIndicator.Visible = false;
|
||||||
WeaponMaterial!.UseFovOverride = true;
|
|
||||||
EmitSignalWeaponRetrieved();
|
EmitSignalWeaponRetrieved();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +94,7 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
{
|
{
|
||||||
_weaponState.SendEvent("throw");
|
_weaponState.SendEvent("throw");
|
||||||
|
|
||||||
WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 1f, 1f);
|
// WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 1f, 1f);
|
||||||
|
|
||||||
_throwDirection = (end - GlobalPosition).Normalized();
|
_throwDirection = (end - GlobalPosition).Normalized();
|
||||||
PlantLocation = collisionLocation;
|
PlantLocation = collisionLocation;
|
||||||
@@ -120,10 +118,11 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
{
|
{
|
||||||
_weaponState.SendEvent("plant");
|
_weaponState.SendEvent("plant");
|
||||||
|
|
||||||
WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 0.2f, 0.2f);
|
// WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 0.2f, 0.2f);
|
||||||
|
|
||||||
Freeze = true;
|
Freeze = true;
|
||||||
GlobalPosition = PlantLocation;
|
GlobalPosition = PlantLocation;
|
||||||
|
WeaponMesh.Transform = _startMeshTransform;
|
||||||
LookAt(GlobalTransform.Origin + PlantNormal, Vector3.Up, true);
|
LookAt(GlobalTransform.Origin + PlantNormal, Vector3.Up, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,11 +150,12 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _PhysicsProcess(double _delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (!FlyingState.Active) return;
|
if (!FlyingState.Active) return;
|
||||||
|
|
||||||
LookAt(GlobalTransform.Origin + LinearVelocity.Normalized(), Vector3.Up, false);
|
WeaponMesh.Rotation = new Vector3(WeaponMesh.Rotation.X, WeaponMesh.Rotation.Y + (float) delta * 100, WeaponMesh.Rotation.Z);
|
||||||
|
//LookAt(GlobalTransform.Origin + LinearVelocity.Normalized(), Vector3.Up, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPlantedUnderPlatform()
|
public bool IsPlantedUnderPlatform()
|
||||||
|
|||||||
Reference in New Issue
Block a user