refacto: moved systems from player controller physics process to their own signal based systems
This commit is contained in:
@ -17,6 +17,8 @@ public partial class MantleSystem: Node3D
|
||||
private ShapeCast3D _wallInFrontCast3D;
|
||||
private ShapeCast3D _mantleCast3D;
|
||||
private RayCast3D _mantleCheckCast3D;
|
||||
|
||||
private Option<Vector3> _mantleLocation;
|
||||
|
||||
public void Init(Node3D head)
|
||||
{
|
||||
@ -25,21 +27,29 @@ public partial class MantleSystem: Node3D
|
||||
_mantleCast3D = GetNode<ShapeCast3D>("MantleCast3D");
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantleInFrontOfPlayer()
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
base._PhysicsProcess(delta);
|
||||
|
||||
_wallInFrontCast3D.SetRotation(new Vector3(
|
||||
_wallInFrontCast3D.Rotation.X,
|
||||
_head.Rotation.Y,
|
||||
_wallInFrontCast3D.Rotation.Z));
|
||||
|
||||
|
||||
if (!_wallInFrontCast3D.IsColliding())
|
||||
{
|
||||
return Option<Vector3>.None;
|
||||
_mantleLocation = Option<Vector3>.None;
|
||||
return;
|
||||
}
|
||||
|
||||
var collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0);
|
||||
var collisionNormal = _wallInFrontCast3D.GetCollisionNormal(0);
|
||||
return FindMantleLocationAtPoint(collisionPoint, collisionNormal);
|
||||
_mantleLocation = FindMantleLocationAtPoint(collisionPoint, collisionNormal);
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantleInFrontOfPlayer()
|
||||
{
|
||||
return _mantleLocation;
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantleLocationAtPoint(Vector3 point, Vector3 wallNormal)
|
||||
|
@ -22,7 +22,7 @@ debug_shape_custom_color = Color(1, 0, 0, 1)
|
||||
[node name="WallInFrontCast3D" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CapsuleShape3D_qu4wy")
|
||||
target_position = Vector3(0, 0, -1.5)
|
||||
target_position = Vector3(0, 0, -2)
|
||||
max_results = 1
|
||||
collision_mask = 2
|
||||
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
||||
|
Reference in New Issue
Block a user