basic forge setup and refactored for some warning
This commit is contained in:
@@ -19,28 +19,26 @@ public partial class DashSystem: Node3D
|
||||
public Vector3 TargetLocation { get; set; }
|
||||
public Vector3 CollisionPoint { get; set; }
|
||||
public Vector3 CollisionNormal { get; set; }
|
||||
public GodotObject CollidedObject { get; set; }
|
||||
public GodotObject? CollidedObject { get; set; }
|
||||
public Vector3 PlannedLocation { get; set; }
|
||||
|
||||
public bool ShouldMantle { get; set; }
|
||||
public Vector3 PlannedMantleLocation { get; set; }
|
||||
public MantleSystem MantleSystem { get; set; }
|
||||
public MantleSystem MantleSystem { get; set; } = null!;
|
||||
|
||||
internal HeadSystem _head;
|
||||
public ShapeCast3D DashCast3D;
|
||||
internal Camera3D _camera;
|
||||
internal Vector3 _dashDirection = Vector3.Zero;
|
||||
internal HeadSystem Head = null!;
|
||||
public ShapeCast3D DashCast3D = null!;
|
||||
internal Camera3D Camera = null!;
|
||||
internal Vector3 DashDirection = Vector3.Zero;
|
||||
|
||||
internal ShapeCast3D _dashCastDrop;
|
||||
internal MeshInstance3D _dashDropIndicator;
|
||||
internal MeshInstance3D _dashDropLocationIndicator;
|
||||
internal ShapeCast3D DashCastDrop = null!;
|
||||
internal MeshInstance3D DashDropIndicator = null!;
|
||||
internal MeshInstance3D DashDropLocationIndicator = null!;
|
||||
internal MeshInstance3D DashTarget = null!;
|
||||
internal CpuParticles3D DashIndicator = null!;
|
||||
internal AnimationPlayer DashIndicatorAnim = null!;
|
||||
|
||||
internal MeshInstance3D _dashTarget;
|
||||
internal CpuParticles3D _dashIndicator;
|
||||
internal AnimationPlayer _dashIndicatorAnim;
|
||||
|
||||
[Export]
|
||||
public PackedScene DashIndicatorScene { get; set; }
|
||||
[Export] public PackedScene DashIndicatorScene { get; set; } = null!;
|
||||
|
||||
[Signal]
|
||||
public delegate void DashStartedEventHandler();
|
||||
@@ -59,22 +57,22 @@ public partial class DashSystem: Node3D
|
||||
var dashShape = DashCast3D.GetShape() as SphereShape3D;
|
||||
DashCastRadius = dashShape!.Radius;
|
||||
|
||||
_dashCastDrop = GetNode<ShapeCast3D>("DashCastDrop");
|
||||
_dashDropIndicator = GetNode<MeshInstance3D>("DashDropIndicator");
|
||||
_dashDropIndicator.Visible = false;
|
||||
_dashDropLocationIndicator = GetNode<MeshInstance3D>("DashDropLocationIndicator");
|
||||
_dashDropLocationIndicator.Visible = false;
|
||||
DashCastDrop = GetNode<ShapeCast3D>("DashCastDrop");
|
||||
DashDropIndicator = GetNode<MeshInstance3D>("DashDropIndicator");
|
||||
DashDropIndicator.Visible = false;
|
||||
DashDropLocationIndicator = GetNode<MeshInstance3D>("DashDropLocationIndicator");
|
||||
DashDropLocationIndicator.Visible = false;
|
||||
|
||||
_head = head;
|
||||
_camera = camera;
|
||||
Head = head;
|
||||
Camera = camera;
|
||||
|
||||
MantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
MantleSystem.Init();
|
||||
|
||||
_dashTarget = GetNode<MeshInstance3D>("DashTarget");
|
||||
_dashTarget.SetVisible(false);
|
||||
_dashIndicator = GetNode<CpuParticles3D>("DashIndicator");
|
||||
_dashIndicatorAnim = GetNode<AnimationPlayer>("DashIndicator/AnimationPlayer");
|
||||
DashTarget = GetNode<MeshInstance3D>("DashTarget");
|
||||
DashTarget.SetVisible(false);
|
||||
DashIndicator = GetNode<CpuParticles3D>("DashIndicator");
|
||||
DashIndicatorAnim = GetNode<AnimationPlayer>("DashIndicator/AnimationPlayer");
|
||||
}
|
||||
|
||||
internal DashLocation ComputeDashLocation()
|
||||
@@ -98,13 +96,13 @@ public partial class DashSystem: Node3D
|
||||
|
||||
public void PrepareDash()
|
||||
{
|
||||
DashCast3D.SetRotation(_head.GetGlobalLookRotation());
|
||||
DashCast3D.SetRotation(Head.GetGlobalLookRotation());
|
||||
|
||||
(HasHit, PlannedLocation, CollisionPoint, CollisionNormal, CollidedObject) = ComputeDashLocation();
|
||||
CanDashThroughTarget = false;
|
||||
if (CollidedObject is ITargetable targetable)
|
||||
if (CollidedObject is ITargetable)
|
||||
{
|
||||
_dashTarget.SetVisible(false);
|
||||
DashTarget.SetVisible(false);
|
||||
CanDashThroughTarget = true;
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +110,7 @@ public partial class DashSystem: Node3D
|
||||
MantleSystem.SetGlobalPosition(PlannedLocation);
|
||||
MantleSystem.SetRotation(new Vector3(
|
||||
MantleSystem.Rotation.X,
|
||||
_head.Rotation.Y,
|
||||
Head.Rotation.Y,
|
||||
MantleSystem.Rotation.Z));
|
||||
MantleSystem.ProcessMantle(false);
|
||||
ShouldMantle = MantleSystem.IsMantlePossible;
|
||||
@@ -120,41 +118,18 @@ public partial class DashSystem: Node3D
|
||||
// Setup dash target
|
||||
var targetColor = HasHit ? new Color(1f, 0.2f, 0.2f) : new Color(1f, 1f, 1f);
|
||||
targetColor = ShouldMantle ? new Color(0.2f, 0.2f, 1f) : targetColor;
|
||||
var targetMaterial = (StandardMaterial3D) _dashTarget.GetSurfaceOverrideMaterial(0);
|
||||
var targetMaterial = (StandardMaterial3D) DashTarget.GetSurfaceOverrideMaterial(0);
|
||||
targetMaterial.SetAlbedo(targetColor);
|
||||
_dashTarget.SetVisible(true);
|
||||
DashTarget.SetVisible(true);
|
||||
var targetLocation = ShouldMantle ? MantleSystem.FirstMantleProfilePoint : PlannedLocation;
|
||||
_dashTarget.SetGlobalPosition(targetLocation);
|
||||
return;
|
||||
|
||||
var shouldShowDropIndicator = !HasHit && !ShouldMantle;
|
||||
_dashDropIndicator.SetVisible(shouldShowDropIndicator);
|
||||
_dashDropLocationIndicator.SetVisible(shouldShowDropIndicator);
|
||||
if (shouldShowDropIndicator)
|
||||
{
|
||||
_dashCastDrop.GlobalPosition = targetLocation; // Place drop indication cast at dash location
|
||||
var startDropLocation = targetLocation; // Start of the drop is the dash target location
|
||||
|
||||
// End of the drop is either max cast distance or first collision
|
||||
var hasDropLocationHit = _dashCastDrop.IsColliding();
|
||||
var endDropLocation = hasDropLocationHit ? _dashCastDrop.GetCollisionPoint(0) : _dashCastDrop.ToGlobal(DashCast3D.TargetPosition);
|
||||
|
||||
// Only show drop location indicator if drop cast has hit
|
||||
_dashDropLocationIndicator.SetVisible(hasDropLocationHit);
|
||||
_dashDropLocationIndicator.SetGlobalPosition(endDropLocation);
|
||||
|
||||
var dropLength = (endDropLocation - startDropLocation).Length();
|
||||
var dropDirection = (endDropLocation - startDropLocation).Normalized();
|
||||
_dashDropIndicator.SetScale(new Vector3(1, dropLength, 1));
|
||||
_dashDropIndicator.SetGlobalPosition(startDropLocation + dropDirection * dropLength * 0.5f);
|
||||
}
|
||||
DashTarget.SetGlobalPosition(targetLocation);
|
||||
}
|
||||
|
||||
public void StopPreparingDash()
|
||||
{
|
||||
CanDashThroughTarget = false;
|
||||
_dashTarget.SetVisible(false);
|
||||
_dashDropIndicator.SetVisible(false);
|
||||
_dashDropLocationIndicator.SetVisible(false);
|
||||
DashTarget.SetVisible(false);
|
||||
DashDropIndicator.SetVisible(false);
|
||||
DashDropLocationIndicator.SetVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user