Clean up events, add weapon tag for weaker on swing
This commit is contained in:
@@ -39,4 +39,10 @@ public partial class BossAModelView : EnemyModelView3D, INode3D
|
||||
ExplodingModel.Show();
|
||||
DeathAnimation.Play("Animation");
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||
DeathAnimation.AnimationFinished -= DeathAnimation_AnimationFinished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,5 +180,6 @@ public partial class BossTypeA : Enemy, IHaveEngagePlayerBehavior, IHaveFollowBe
|
||||
EngagePlayerBehavior.TakeAction -= PerformAction;
|
||||
PlayerDetector.BodyEntered -= PlayerDetector_BodyEntered;
|
||||
PlayerDetector.BodyExited -= PlayerDetector_BodyExited;
|
||||
(EnemyModelView as BossAModelView).OnDeathAnimationCompleted -= EnemyModelView3D_OnDeathAnimationCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,4 +69,10 @@ public abstract partial class Enemy2D : Enemy
|
||||
if (body is IPlayer)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alert());
|
||||
}
|
||||
|
||||
public new void OnExitTree()
|
||||
{
|
||||
base.OnExitTree();
|
||||
LineOfSight.BodyEntered -= LineOfSight_BodyEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,5 +129,6 @@ public abstract partial class EnemyModelView : Node3D, IEnemyModelView
|
||||
{
|
||||
if (AnimationTree != null)
|
||||
AnimationTree.Get(_parametersPlayback).As<AnimationNodeStateMachinePlayback>().Stop();
|
||||
AnimationTree.AnimationFinished -= AnimationTree_AnimationFinished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,23 +18,33 @@ public partial class Michael : Enemy2D, IHavePatrolBehavior, IHaveEngagePlayerBe
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
FollowBehavior.Init(NavigationAgent);
|
||||
PatrolBehavior.Init(NavigationAgent);
|
||||
PatrolBehavior.HomePosition = GlobalPosition;
|
||||
PatrolBehavior.OnVelocityComputed += OnVelocityComputed;
|
||||
FollowBehavior.OnVelocityComputed += OnVelocityComputed;
|
||||
EngagePlayerBehavior.TakeAction += EngagePlayerBehavior_TakeAction;
|
||||
EngagePlayerBehavior.AcquireTarget += EngagePlayerBehavior_AcquireTarget;
|
||||
PlayerDetector.BodyEntered += PlayerDetector_BodyEntered;
|
||||
PlayerDetector.BodyExited += PlayerDetector_BodyExited;
|
||||
SetPhysicsProcess(true);
|
||||
FollowBehavior.Init(NavigationAgent);
|
||||
PatrolBehavior.Init(NavigationAgent);
|
||||
PatrolBehavior.HomePosition = GlobalPosition;
|
||||
PatrolBehavior.OnVelocityComputed += OnVelocityComputed;
|
||||
FollowBehavior.OnVelocityComputed += OnVelocityComputed;
|
||||
EngagePlayerBehavior.TakeAction += EngagePlayerBehavior_TakeAction;
|
||||
EngagePlayerBehavior.AcquireTarget += EngagePlayerBehavior_AcquireTarget;
|
||||
PlayerDetector.BodyEntered += PlayerDetector_BodyEntered;
|
||||
PlayerDetector.BodyExited += PlayerDetector_BodyExited;
|
||||
SetPhysicsProcess(true);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Patrol());
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Patrol());
|
||||
}
|
||||
|
||||
|
||||
public override void Move() => EnemyModelView.PlayIdleAnimation();
|
||||
|
||||
public new void OnExitTree()
|
||||
{
|
||||
base.OnExitTree();
|
||||
PatrolBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
FollowBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
EngagePlayerBehavior.TakeAction -= EngagePlayerBehavior_TakeAction;
|
||||
EngagePlayerBehavior.AcquireTarget -= EngagePlayerBehavior_AcquireTarget;
|
||||
PlayerDetector.BodyEntered -= PlayerDetector_BodyEntered;
|
||||
PlayerDetector.BodyExited -= PlayerDetector_BodyExited;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,12 @@ public partial class GoldSproingy : Enemy2D, IHavePatrolBehavior, IHaveFleeBehav
|
||||
}
|
||||
|
||||
public override void Move() => EnemyModelView.PlayIdleAnimation();
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
PatrolBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
PlayerDetector.BodyExited -= PlayerDetector_BodyExited;
|
||||
FleeBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
PlayerDetector.BodyEntered -= GoldSproingyFlee;
|
||||
}
|
||||
}
|
||||
@@ -52,4 +52,9 @@ public partial class DemonWall : Enemy3D
|
||||
{
|
||||
EnemyModelView.Attack(_maximumWallMoveAmount);
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
_attackTimer.Timeout -= AttackTimer_Timeout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,19 @@ public partial class DemonWallArm : EnemyModelView
|
||||
|
||||
public new void OnReady()
|
||||
{
|
||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
base.OnReady();
|
||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
base.OnReady();
|
||||
}
|
||||
|
||||
private void Hitbox_AreaEntered(Area3D area)
|
||||
{
|
||||
var target = area.GetOwner();
|
||||
if (target is IPlayer player)
|
||||
base.OnPlayerHit(new AttackEventArgs(AttackData));
|
||||
var target = area.GetOwner();
|
||||
if (target is IPlayer player)
|
||||
base.OnPlayerHit(new AttackEventArgs(AttackData));
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user