using System; using UnityEngine; using UnityEngine.AI; namespace Code.OfficeGame.BattleMode.Actions { public class MovementBattleActionData : BattleActionData { public bool WasStarted = false; public Vector3 Position; public Quaternion Rotation; public NavMeshPath Path; public Vector3[] Corners; public int CurrentCornerIndex; public bool IsRotateOnly; public int CurrentFrame; 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, WasStarted = WasStarted, CurrentCornerIndex = CurrentCornerIndex, IsRotateOnly = IsRotateOnly, CurrentFrame = CurrentFrame }; } public override void RestoreSnapshot(BattleActionData snapshot) { TotalFrames = snapshot.TotalFrames; if (snapshot is not MovementBattleActionData moveSnapshot) return; CurrentFrame = moveSnapshot.CurrentFrame; Position = moveSnapshot.Position; Rotation = moveSnapshot.Rotation; Path = moveSnapshot.Path; CurrentCornerIndex = moveSnapshot.CurrentCornerIndex; WasStarted = moveSnapshot.WasStarted; IsRotateOnly = moveSnapshot.IsRotateOnly; 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; } } }