CLEAR.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. namespace OpenVIII.Fields.Scripts.Instructions
  3. {
  4. /// <summary>
  5. /// Resets all variables and game data.
  6. /// Only used when starting a new game (and in debug rooms).
  7. /// </summary>
  8. internal sealed class CLEAR : JsmInstruction
  9. {
  10. public CLEAR()
  11. {
  12. }
  13. public CLEAR(Int32 parameter, IStack<IJsmExpression> stack)
  14. : this()
  15. {
  16. }
  17. public override String ToString()
  18. {
  19. return $"{nameof(CLEAR)}()";
  20. }
  21. public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
  22. {
  23. sw.Format(formatterContext, services)
  24. .StaticType(nameof(IGameplayService))
  25. .Method(nameof(IGameplayService.ResetAllData))
  26. .Comment(nameof(CLEAR));
  27. }
  28. public override IAwaitable TestExecute(IServices services)
  29. {
  30. ServiceId.Gameplay[services].ResetAllData();
  31. return DummyAwaitable.Instance;
  32. }
  33. }
  34. }