/// <summary>Executes the callback part of the while command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> /// <param name="integer">While Index holder.</param> public static bool TryWhileCIL(CommandQueue queue, CommandEntry entry, IntegerTag integer) { WhileCommandData dat = queue.CurrentRunnable.EntryData[entry.BlockStart - 1] as WhileCommandData; integer.Internal = ++dat.Index; if (IfCommand.TryIf(queue, entry, new List <Argument>(dat.ComparisonArgs))) { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "While looping: " + TextStyle.Separate + dat.Index + TextStyle.Base + "..."); } return(true); } if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "While stopping."); } return(false); }
/// <summary>Executes the comparison input part of the while command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static bool TryWhileNumberedCIL(CommandQueue queue, CommandEntry entry) { bool success = IfCommand.TryIf(queue, entry, new List <Argument>(entry.Arguments)); if (!success) { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Not looping."); } return(false); } entry.SetData(queue, new WhileCommandData() { Index = 1, ComparisonArgs = entry.Arguments }); if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "While looping..."); } return(true); }
/// <summary>Executes the command via CIL.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">Entry to be executed.</param> public static bool TryIfCIL(CommandQueue queue, CommandEntry entry) { entry.SetData(queue, new IfCommandData() { Result = 0 }); if (entry.Arguments.Length == 0) { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Else is reached, executing block..."); } ((IfCommandData)entry.GetData(queue)).Result = 1; return(true); } List <Argument> args = new(entry.Arguments); args.RemoveAt(0); bool success = IfCommand.TryIf(queue, entry, args); if (success) { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Else-If is true, executing..."); } ((IfCommandData)entry.GetData(queue)).Result = 1; } else { if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Else-If is false, doing nothing!"); } } return(success); }