Files
Pal3.Unity/Assets/Scripts/Engine/Navigation/Path.cs
T
Jiaqi (0x7c13) Liu e870cf487a Add core protocol regression tests and copyright checks
Cover SCE command contracts, binary readers, resource layouts and full local CPK decompression for PAL3 and PAL3A. Fix CVD time rebasing, binary read bounds and short reads, and CPK/NAV validation.

Standardize first-party copyright headers, preserve correct creation years, and update console source generation. Validate both variants in Unity and verify all live CPK entries.
2026-11-12 13:37:27 +08:00

75 lines
2.0 KiB
C#

// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Engine.Navigation
{
using System.Collections.Generic;
using Pal3.Core.Contract.Enums;
using Vector3 = UnityEngine.Vector3;
public enum EndOfPathActionType
{
Idle = 0,
DisposeSelf,
WaitAndReverse
}
public sealed class Path
{
public MovementMode MovementMode { get; private set; }
public EndOfPathActionType EndOfPathAction { get; private set; }
public bool IgnoreObstacle { get; private set; }
private readonly List<Vector3> _wayPoints = new ();
private int _currentWayPointIndex;
public void SetPath(Vector3[] wayPoints,
MovementMode movementMode,
EndOfPathActionType endOfPathAction,
bool ignoreObstacle)
{
Clear();
_wayPoints.AddRange(wayPoints);
_currentWayPointIndex = 0;
MovementMode = movementMode;
EndOfPathAction = endOfPathAction;
IgnoreObstacle = ignoreObstacle;
}
public void Clear()
{
MovementMode = 0;
EndOfPathAction = EndOfPathActionType.Idle;
_wayPoints.Clear();
_currentWayPointIndex = 0;
}
public bool MoveToNextWayPoint()
{
return ++_currentWayPointIndex < _wayPoints.Count;
}
public bool IsEndOfPath()
{
return !(_wayPoints.Count > 0 && _currentWayPointIndex < _wayPoints.Count);
}
public Vector3[] GetAllWayPoints()
{
return _wayPoints.ToArray();
}
public Vector3 GetCurrentWayPoint()
{
return _wayPoints[_currentWayPointIndex];
}
}
}