MethodName to nameof()

controller-support
HumanoidSandvichDispenser 2023-08-16 21:02:49 -07:00
parent dc5c06dafa
commit 316c9e8bc4
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
2 changed files with 4 additions and 7 deletions

View File

@ -36,11 +36,10 @@ public partial class PursueState : ThinkerState
NPC.Target = NPC.GlobalPosition.DirectionTo(pos); NPC.Target = NPC.GlobalPosition.DirectionTo(pos);
NPC.LastSeenPosition = pos; NPC.LastSeenPosition = pos;
if (NPC.GlobalPosition.DistanceTo(pos) < MinDistanceToTarget) if (NPC.HasLineOfSight(bestTarget))
{ {
if (NPC.HasLineOfSight(bestTarget)) if (NPC.GlobalPosition.DistanceTo(pos) < MinDistanceToTarget)
{ {
GD.Print("To attack state");
return AttackState; return AttackState;
} }
} }
@ -48,11 +47,9 @@ public partial class PursueState : ThinkerState
else else
{ {
// go to last seen position of last best target // go to last seen position of last best target
GD.Print("Last seen " + NPC.LastSeenPosition);
NavigationAgent.TargetPosition = NPC.LastSeenPosition; NavigationAgent.TargetPosition = NPC.LastSeenPosition;
} }
return null;
return PassiveState ?? base.Think();
} }
public override ThinkerState PhysicsProcess(double delta) public override ThinkerState PhysicsProcess(double delta)

View File

@ -97,7 +97,7 @@ public partial class World : Node
EventBus = this.GetEventBus(); EventBus = this.GetEventBus();
EventBus.RequestMoveToArea += (Events.RequestAreaArgs args) => EventBus.RequestMoveToArea += (Events.RequestAreaArgs args) =>
{ {
CallDeferred(MethodName.MoveToArea, args.Area, args.Connector); CallDeferred(nameof(MoveToArea), args.Area, args.Connector);
}; };
EventBus.RegisteredBoss += RegisterBoss; EventBus.RegisteredBoss += RegisterBoss;
EventBus.DeregisteredBoss += DeregisterBoss; EventBus.DeregisteredBoss += DeregisterBoss;