stunnable targets on hit
This commit is contained in:
@@ -130,11 +130,16 @@ public partial class Enemy : CharacterBody3D,
|
||||
Events.Subscribe<KnockbackDone>(Tag.RequestTag(TagsManager, "events.combat.knockback_received"), OnKnockbackReceived);
|
||||
Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.death"), OnDeath);
|
||||
Events.Subscribe(Tag.RequestTag(TagsManager, "events.enemy.request_projectile"), ProjectileTokenRequested);
|
||||
|
||||
}
|
||||
|
||||
private bool IsStunned()
|
||||
{
|
||||
return Tags.CombinedTags.HasTag(Tag.RequestTag(TagsManager, "status.stunned"));
|
||||
}
|
||||
|
||||
private void ProjectileTokenRequested(EventData obj)
|
||||
{
|
||||
if (IsStunned()) return;
|
||||
// TODO: replace with token manager
|
||||
Events.Raise(new EventData<OnProjectileSpawned>
|
||||
{
|
||||
@@ -154,24 +159,34 @@ public partial class Enemy : CharacterBody3D,
|
||||
{
|
||||
// Only trigger gameplay-related effects on specific frames
|
||||
if(Engine.GetPhysicsFrames() % 10 == 0) ProcessGameplay(delta);
|
||||
|
||||
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
|
||||
LookAt(targetPlanar);
|
||||
|
||||
if (!IsStunned())
|
||||
{
|
||||
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
|
||||
LookAt(targetPlanar);
|
||||
}
|
||||
|
||||
var inputs = new MovementInputs(
|
||||
Velocity: Velocity,
|
||||
TargetLocation: Target.GlobalPosition,
|
||||
isOnFloor: IsOnFloor(),
|
||||
gravity: GetGravity(),
|
||||
delta: delta
|
||||
IsOnFloor: IsOnFloor(),
|
||||
IsStunned: IsStunned(),
|
||||
Gravity: GetGravity(),
|
||||
Delta: delta
|
||||
);
|
||||
Velocity = ComputeVelocity(inputs);
|
||||
|
||||
Velocity += ComputeKnockback();
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
public void ProcessGameplay(double delta)
|
||||
{
|
||||
if (IsStunned())
|
||||
{
|
||||
GD.Print("Cannot attack, stunned!");
|
||||
return;
|
||||
}
|
||||
// if (_hitAbilityHandle == null) return;
|
||||
|
||||
var bodies = DamageBox.GetOverlappingBodies();
|
||||
|
||||
Reference in New Issue
Block a user