add revert as well as undo

main
Anton Franzluebbers 2023-08-23 14:56:42 -04:00
parent ddaff1c86f
commit a99d5c8d93
2 changed files with 24 additions and 2 deletions

View File

@ -21,7 +21,7 @@ namespace VelNet
/// <summary>
/// Reset to the last UndoState. This only takes ownership if the IPackState component is also a NetworkComponent
/// Reset to the last UndoState and remove the state from history. This only takes ownership if the IPackState component is also a NetworkComponent
/// </summary>
public void Undo()
{
@ -43,6 +43,28 @@ namespace VelNet
}
}
/// <summary>
/// Reset to the last UndoState. This only takes ownership if the IPackState component is also a NetworkComponent
/// </summary>
public void Revert()
{
byte[][] lastStates = undoBuffer.LastOrDefault();
if (lastStates != null)
{
for (int i = 0; i < objects.Count; i++)
{
objects[i].networkObject.TakeOwnership();
objects[i].UnpackState(lastStates[i]);
}
if (debugLog) Debug.Log($"Revert {objects.Count} objects");
}
else
{
if (debugLog) Debug.Log($"No more undo to undo");
}
}
public void SaveUndoState()
{
byte[][] states = new byte[objects.Count][];

View File

@ -1,7 +1,7 @@
{
"name": "edu.uga.engr.vel.velnet",
"displayName": "VelNet",
"version": "1.2.2",
"version": "1.2.3",
"unity": "2019.1",
"description": "A custom networking library for Unity.",
"keywords": [