dash indicators
This commit is contained in:
@@ -6,6 +6,12 @@ namespace Movementtests.systems;
|
||||
|
||||
public partial class WeaponSystem : RigidBody3D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void WeaponThrownEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void WeaponRetrievedEventHandler();
|
||||
|
||||
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
||||
public float ThrowForce { get; set; } = 1f;
|
||||
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
|
||||
@@ -26,6 +32,11 @@ public partial class WeaponSystem : RigidBody3D
|
||||
private Vector3 _throwDirection;
|
||||
public Vector3 PlantLocation { get; set; }
|
||||
public Vector3 PlantNormal { get; set; }
|
||||
|
||||
public MeshInstance3D WeaponLocationIndicator { get; set; }
|
||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; }
|
||||
public MeshInstance3D WeaponMesh { get; set; }
|
||||
public StandardMaterial3D WeaponMaterial { get; set; }
|
||||
|
||||
public void Init(Node3D head, Camera3D camera)
|
||||
{
|
||||
@@ -36,6 +47,13 @@ public partial class WeaponSystem : RigidBody3D
|
||||
InHandState = StateChartState.Of(GetNode("StateChart/Root/InHand"));
|
||||
FlyingState = StateChartState.Of(GetNode("StateChart/Root/Flying"));
|
||||
PlantedState = StateChartState.Of(GetNode("StateChart/Root/Planted"));
|
||||
|
||||
WeaponLocationIndicator = GetNode<MeshInstance3D>("WeaponLocationIndicator");
|
||||
WeaponLocationIndicator.Visible = false;
|
||||
WeaponLocationIndicatorMaterial = WeaponLocationIndicator.GetActiveMaterial(0) as StandardMaterial3D;
|
||||
|
||||
WeaponMesh = GetNode<MeshInstance3D>("Weapon");
|
||||
WeaponMaterial = WeaponMesh.GetActiveMaterial(0) as StandardMaterial3D;
|
||||
|
||||
_tweenQueueSystem = GetNode<TweenQueueSystem>("TweenQueueSystem");
|
||||
_tweenQueueSystem.Init(this);
|
||||
@@ -44,11 +62,30 @@ public partial class WeaponSystem : RigidBody3D
|
||||
Freeze = true;
|
||||
|
||||
BodyEntered += OnThrownWeaponReachesGround;
|
||||
|
||||
InHandState.StateExited += WeaponLeft;
|
||||
InHandState.StateEntered += WeaponBack;
|
||||
}
|
||||
|
||||
public void WeaponLeft()
|
||||
{
|
||||
WeaponLocationIndicator.Visible = true;
|
||||
WeaponMaterial!.UseFovOverride = false;
|
||||
EmitSignalWeaponThrown();
|
||||
}
|
||||
|
||||
public void WeaponBack()
|
||||
{
|
||||
WeaponLocationIndicator.Visible = false;
|
||||
WeaponMaterial!.UseFovOverride = true;
|
||||
EmitSignalWeaponRetrieved();
|
||||
}
|
||||
|
||||
public void ThrowWeapon(Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal)
|
||||
{
|
||||
_weaponState.SendEvent("throw");
|
||||
|
||||
WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 1f, 1f);
|
||||
|
||||
_throwDirection = (end - GlobalPosition).Normalized();
|
||||
PlantLocation = collisionLocation;
|
||||
@@ -71,6 +108,9 @@ public partial class WeaponSystem : RigidBody3D
|
||||
public void PlantWeaponInWall()
|
||||
{
|
||||
_weaponState.SendEvent("plant");
|
||||
|
||||
WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 0.2f, 0.2f);
|
||||
|
||||
Freeze = true;
|
||||
GlobalPosition = PlantLocation;
|
||||
LookAt(GlobalTransform.Origin + PlantNormal, Vector3.Up, true);
|
||||
|
||||
Reference in New Issue
Block a user