Pathplanning now ignores grid.

WorldChunkRefactoring
Martin Felis 2023-05-03 12:10:01 +02:00
parent 3ebf6d76d8
commit 1ae17ed63b
2 changed files with 40 additions and 7 deletions

View File

@ -97,7 +97,7 @@ public class NavigationComponent : Node
}
public void Plan(Vector3 fromPositionWorld, Vector3 toPositionWorld)
public void PlanGridPath(Vector3 fromPositionWorld, Vector3 toPositionWorld)
{
Vector2 fromPositionOffset = TileWorld.WorldToOffsetCoords(fromPositionWorld);
Vector2 toPositionOffset = TileWorld.WorldToOffsetCoords(toPositionWorld);
@ -134,23 +134,56 @@ public class NavigationComponent : Node
}
public void Plan(Vector3 fromPositionWorld, Vector3 toPositionWorld, Quat toWorldOrientation)
public void PlanGridPath(Vector3 fromPositionWorld, Vector3 toPositionWorld, Quat toWorldOrientation)
{
Plan(fromPositionWorld, toPositionWorld);
PlanGridPath(fromPositionWorld, toPositionWorld);
_pathWorldNavigationPoints.Add(new NavigationPoint(toWorldOrientation));
}
public void Plan(Transform fromTransformWorld, NavigationPoint navigationPoint)
public void PlanGridPath(Transform fromTransformWorld, NavigationPoint navigationPoint)
{
if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position)
&& navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation))
{
Plan(fromTransformWorld.origin, navigationPoint.WorldPosition, navigationPoint.WorldOrientation);
PlanGridPath(fromTransformWorld.origin, navigationPoint.WorldPosition, navigationPoint.WorldOrientation);
} else if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position))
{
Plan(fromTransformWorld.origin, navigationPoint.WorldPosition);
PlanGridPath(fromTransformWorld.origin, navigationPoint.WorldPosition);
} else
{
throw new NotImplementedException();
}
}
public void PlanDirectPath(Vector3 fromPositionWorld, Vector3 toPositionWorld)
{
_pathWorldNavigationPoints.Clear();
_pathWorldNavigationPoints.Add(new NavigationPoint(toPositionWorld));
UpdateCurrentGoal();
}
public void PlanDirectPath(Vector3 fromPositionWorld, Vector3 toPositionWorld, Quat toWorldOrientation)
{
PlanDirectPath(fromPositionWorld, toPositionWorld);
_pathWorldNavigationPoints.Add(new NavigationPoint(toWorldOrientation));
}
public void PlanDirectPath(Transform fromTransformWorld, NavigationPoint navigationPoint)
{
if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position)
&& navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation))
{
PlanDirectPath(fromTransformWorld.origin, navigationPoint.WorldPosition, navigationPoint.WorldOrientation);
} else if (navigationPoint.Flags.HasFlag(NavigationPoint.NavigationFlags.Position))
{
PlanDirectPath(fromTransformWorld.origin, navigationPoint.WorldPosition);
} else
{
throw new NotImplementedException();

View File

@ -76,7 +76,7 @@ public class Player : Entity
if (currentTask is TaskQueueComponent.NavigationTask)
{
TaskQueueComponent.NavigationTask navigationTask = (TaskQueueComponent.NavigationTask)currentTask;
_navigationComponent.Plan(GlobalTransform, navigationTask.NavigationPoint);
_navigationComponent.PlanDirectPath(GlobalTransform, navigationTask.NavigationPoint);
}
}
}