WIP: integrating forge systems into the game, now trying periodic abilities
This commit is contained in:
@@ -12,7 +12,9 @@ using Movementtests.tools;
|
||||
|
||||
namespace Movementtests.systems;
|
||||
|
||||
public record struct WeaponLandPayload(int Damage, bool IsCritical);
|
||||
public record struct WeaponLandPayload();
|
||||
public record struct WeaponFlyingPayload(string Message);
|
||||
public record struct WeaponLeftPayload();
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_sword.png")]
|
||||
public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
@@ -41,6 +43,7 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
public StateChartState FlyingState = null!;
|
||||
public StateChartState PlantedState = null!;
|
||||
private ShapeCast3D _dashCast3D = null!;
|
||||
public Timer WeaponFlyingTick = null!;
|
||||
|
||||
private Transform3D _startTransform;
|
||||
private Vector3 _startMeshRotation;
|
||||
@@ -53,7 +56,9 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
public MeshInstance3D WeaponLocationIndicator { get; set; } = null!;
|
||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; } = null!;
|
||||
public MeshInstance3D WeaponMesh { get; set; } = null!;
|
||||
|
||||
|
||||
public Tag WeaponLeftTag;
|
||||
public Tag WeaponFlyingTickTag;
|
||||
public Tag WeaponLandTag;
|
||||
|
||||
public void Init()
|
||||
@@ -66,6 +71,8 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
WeaponLocationIndicator = GetNode<MeshInstance3D>("WeaponLocationIndicator");
|
||||
WeaponLocationIndicator.Visible = false;
|
||||
WeaponLocationIndicatorMaterial = (WeaponLocationIndicator.GetActiveMaterial(0) as StandardMaterial3D)!;
|
||||
|
||||
WeaponFlyingTick = GetNode<Timer>("WeaponFlyingTick");
|
||||
|
||||
WeaponMesh = GetNode<MeshInstance3D>("Weapon");
|
||||
_startMeshRotation = WeaponMesh.Rotation;
|
||||
@@ -88,12 +95,29 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
Abilities = new(this);
|
||||
Events = new();
|
||||
|
||||
WeaponLeftTag = Tag.RequestTag(tagsManager, "events.weapon.left");
|
||||
WeaponFlyingTickTag = Tag.RequestTag(tagsManager, "events.weapon.flyingTick");
|
||||
WeaponLandTag = Tag.RequestTag(tagsManager, "events.weapon.land");
|
||||
|
||||
BodyEntered += OnThrownWeaponReachesGround;
|
||||
|
||||
InHandState.StateExited += WeaponLeft;
|
||||
InHandState.StateEntered += WeaponBack;
|
||||
FlyingState.StateEntered += FlyingStarted;
|
||||
FlyingState.StateExited += FlyingEnded;
|
||||
|
||||
WeaponFlyingTick.Timeout += RaiseWeaponFlyingTickEvent;
|
||||
}
|
||||
|
||||
public void FlyingStarted()
|
||||
{
|
||||
RaiseWeaponFlyingTickEvent();
|
||||
WeaponFlyingTick.Start();
|
||||
}
|
||||
|
||||
public void FlyingEnded()
|
||||
{
|
||||
WeaponFlyingTick.Stop();
|
||||
}
|
||||
|
||||
public void WeaponLeft()
|
||||
@@ -121,6 +145,7 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
public void ThrowWeapon(Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal, Node collidedObject)
|
||||
{
|
||||
_weaponState.SendEvent("throw");
|
||||
RaiseWeaponLeftEvent();
|
||||
|
||||
// WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 1f, 1f);
|
||||
|
||||
@@ -129,7 +154,6 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
PlantNormal = collisionNormal;
|
||||
LookAt(end);
|
||||
|
||||
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.TweenProperty(this, "global_position", end, StraightThrowDuration);
|
||||
if (hasHit)
|
||||
@@ -149,7 +173,30 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
Source = this,
|
||||
Target = victim,
|
||||
EventMagnitude = 25f,
|
||||
Payload = new WeaponLandPayload(Damage: 25, IsCritical: true)
|
||||
Payload = new WeaponLandPayload()
|
||||
});
|
||||
}
|
||||
|
||||
public void RaiseWeaponLeftEvent()
|
||||
{
|
||||
Events.Raise(new EventData<WeaponLeftPayload>
|
||||
{
|
||||
EventTags = WeaponLeftTag.GetSingleTagContainer(),
|
||||
Source = this,
|
||||
EventMagnitude = 25f,
|
||||
Payload = new WeaponLeftPayload()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void RaiseWeaponFlyingTickEvent()
|
||||
{
|
||||
Events.Raise(new EventData<WeaponFlyingPayload>
|
||||
{
|
||||
EventTags = WeaponFlyingTickTag.GetSingleTagContainer(),
|
||||
Source = this,
|
||||
EventMagnitude = 12f,
|
||||
Payload = new WeaponFlyingPayload(Message: "flying")
|
||||
});
|
||||
}
|
||||
|
||||
@@ -170,6 +217,8 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
public void RethrowWeapon()
|
||||
{
|
||||
_weaponState.SendEvent("throw");
|
||||
RaiseWeaponLeftEvent();
|
||||
|
||||
_throwDirection = Vector3.Up;
|
||||
ThrowWeaponOnCurve();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user