using System; using UnityEngine; using UnityEngine.AI; namespace Code.OfficeGame.BattleMode.Actions { public class MovementBattleActionData : BattleActionData { public Vector3 Position; public Quaternion Rotation; public NavMeshPath Path; public Vector3[] Corners; public int CurrentCornerIndex; public override BattleActionData GetSnapshot() { Vector3[] cornersCopy = null; if (Corners != null) { cornersCopy = new Vector3[Corners.Length]; Array.Copy(Corners, cornersCopy, Corners.Length); } return new MovementBattleActionData { TotalFrames = TotalFrames, Position = Position, Rotation = Rotation, Path = Path, Corners = cornersCopy, CurrentCornerIndex = CurrentCornerIndex }; } public override void RestoreSnapshot(BattleActionData snapshot) { TotalFrames = snapshot.TotalFrames; if (snapshot is not MovementBattleActionData moveSnapshot) return; Position = moveSnapshot.Position; Rotation = moveSnapshot.Rotation; Path = moveSnapshot.Path; CurrentCornerIndex = moveSnapshot.CurrentCornerIndex; if (moveSnapshot.Corners != null) { if (Corners == null || Corners.Length != moveSnapshot.Corners.Length) Corners = new Vector3[moveSnapshot.Corners.Length]; Array.Copy(moveSnapshot.Corners, Corners, moveSnapshot.Corners.Length); } else Corners = null; } } }