Get replay working from dropdown menu. (right now everyone has the replay button. We will hide it for most cases later on)

This commit is contained in:
2018-05-09 10:49:54 -05:00
parent d5a04c9d77
commit e7856a9d3e
5 changed files with 94 additions and 10 deletions

View File

@ -81,6 +81,10 @@ namespace EduNetworkBuilder
private List<AnimationClass> Animations = new List<AnimationClass>();
public bool ReplayInProgress = false;
public DateTime NextReplayAction = DateTime.UtcNow;
public int NextReplayIndex = -1;
/// <summary>
/// WhatFrom: If we are launched from a homework, we remember it here.
/// </summary>
@ -1642,6 +1646,28 @@ namespace EduNetworkBuilder
}
}
}
if(ReplayInProgress && myPackets.Count == 0)
{
if(DateTime.UtcNow >= NextReplayAction)
{
//We are doing a replay and enough time has passed from the last replay...
NBSettings Settings = NB.GetSettings();
ActionCollection AC = Settings.GetUserActionCollection();
bool Success = AC.RunAction(NextReplayIndex++);
NextReplayAction = DateTime.UtcNow.AddMilliseconds(NB.MillisecondsBetweenReplays);
if(Success)
{
//we did something. keep replaying
NB.MarkToUpdate();
}
else
{
//replay finished
ReplayInProgress = false;
}
}
}
//if (myPackets.Count > 50)
//Console.WriteLine("Packets: " + myPackets.Count.ToString());
if (myPackets.Count > 0)