add revert as well as undo
parent
4ba96b70a5
commit
593afca4d1
|
|
@ -21,7 +21,7 @@ namespace VelNet
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public void Undo()
|
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()
|
public void SaveUndoState()
|
||||||
{
|
{
|
||||||
byte[][] states = new byte[objects.Count][];
|
byte[][] states = new byte[objects.Count][];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.velnet",
|
"name": "edu.uga.engr.vel.velnet",
|
||||||
"displayName": "VelNet",
|
"displayName": "VelNet",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"description": "A custom networking library for Unity.",
|
"description": "A custom networking library for Unity.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue