Revert some pathing stuff, adjust general spawn rates
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Linq;
|
||||
using Zennysoft.Game.Abstractions.Entity;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
@@ -72,8 +73,7 @@ public partial class PatrolBehavior : Node3D, IBehavior
|
||||
{
|
||||
var nextVelocity = _navigationAgent.GetNextPathPosition();
|
||||
var parent = GetParent() as Node3D;
|
||||
var position = new Vector3(parent.GlobalPosition.X, GlobalPosition.Y, parent.GlobalPosition.Z);
|
||||
var velocity = position.DirectionTo(nextVelocity) * (float)_patrolSpeed * (float)delta;
|
||||
var velocity = parent.GlobalPosition.DirectionTo(nextVelocity) * (float)_patrolSpeed * (float)delta;
|
||||
EmitSignal(SignalName.OnVelocityComputed, velocity);
|
||||
}
|
||||
|
||||
@@ -83,16 +83,9 @@ public partial class PatrolBehavior : Node3D, IBehavior
|
||||
rng.Randomize();
|
||||
var randomPointX = rng.RandfRange(-_patrolRange, _patrolRange);
|
||||
var randomPointZ = rng.RandfRange(-_patrolRange, _patrolRange);
|
||||
_navigationAgent.TargetPosition = HomePosition + new Vector3(randomPointX, 0, randomPointZ);
|
||||
if (!_navigationAgent.IsTargetReachable())
|
||||
{
|
||||
_recursiveCounter++;
|
||||
if (_recursiveCounter <= 100)
|
||||
SetPatrolTarget();
|
||||
else
|
||||
_navigationAgent.TargetPosition = HomePosition;
|
||||
}
|
||||
_recursiveCounter = 0;
|
||||
var patrolPoint = HomePosition + new Vector3(randomPointX, 0, randomPointZ);
|
||||
var rid = NavigationServer3D.GetMaps().Single();
|
||||
_navigationAgent.TargetPosition = NavigationServer3D.MapGetClosestPoint(rid, patrolPoint);
|
||||
}
|
||||
|
||||
private void PatrolTimer_Timeout() => SetPatrolTarget();
|
||||
|
||||
Reference in New Issue
Block a user