Snapshots. Better actions

This commit is contained in:
ThomasCharester committed 2026-10-30 21:48:56 +03:00
1 parent 71bb4c3b5b
commit 31850e77bc
73 files changed
+31948 -80048

No files matched your search

@@ -0,0 +1,10 @@
namespace Code.OfficeGame.BattleMode.Actions
{
public abstract class BattleActionData
{
public int TotalFrames;
public abstract BattleActionData GetSnapshot();
public abstract void RestoreSnapshot(BattleActionData snapshot);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dec8cd0d83354b05a5766a6fd7f3db95
timeCreated: 1793314110
@@ -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;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 39d3651a2dc5444ca0801b647b60d47e
timeCreated: 1793314117
@@ -0,0 +1,15 @@
namespace Code.OfficeGame.BattleMode.Actions
{
public class NoneBattleActionData : BattleActionData
{
public override BattleActionData GetSnapshot()
{
return new NoneBattleActionData();
}
public override void RestoreSnapshot(BattleActionData snapshot)
{
TotalFrames = snapshot.TotalFrames;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 73b4bda13326404db2b0ad653ad43dce
timeCreated: 1793372539
@@ -0,0 +1,24 @@
namespace Code.OfficeGame.BattleMode.Actions
{
public class WaitBattleActionData : BattleActionData
{
public int WaitFrames;
public override BattleActionData GetSnapshot()
{
return new WaitBattleActionData
{
TotalFrames = TotalFrames,
WaitFrames = WaitFrames
};
}
public override void RestoreSnapshot(BattleActionData snapshot)
{
TotalFrames = snapshot.TotalFrames;
if (snapshot is not WaitBattleActionData waitSnapshot) return;
WaitFrames = waitSnapshot.WaitFrames;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1650fc3ffbfd48b0b2bd9a1b31988d8f
timeCreated: 1793314128