Snapshots. Better actions
This commit is contained in:
1 parent
71bb4c3b5b
commit
31850e77bc
73 files changed
+31948
-80048
No files matched your search
@@ -0,0 +1,55 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user