PUSHOFF.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. namespace OpenVIII.Fields.Scripts.Instructions
  3. {
  4. /// <summary>
  5. /// Disables this entity's "push" script. See PUSHON.
  6. /// </summary>
  7. internal sealed class PUSHOFF : JsmInstruction
  8. {
  9. public PUSHOFF()
  10. {
  11. }
  12. public PUSHOFF(Int32 parameter, IStack<IJsmExpression> stack)
  13. : this()
  14. {
  15. }
  16. public override String ToString()
  17. {
  18. return $"{nameof(PUSHOFF)}()";
  19. }
  20. public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
  21. {
  22. sw.Format(formatterContext, services)
  23. .Property(nameof(FieldObject.Model))
  24. .Property(nameof(FieldObjectInteraction.IsPushScriptActive))
  25. .Assign(false)
  26. .Comment(nameof(PUSHOFF));
  27. }
  28. public override IAwaitable TestExecute(IServices services)
  29. {
  30. FieldObject currentObject = ServiceId.Field[services].Engine.CurrentObject;
  31. currentObject.Interaction.IsPushScriptActive = false;
  32. return DummyAwaitable.Instance;
  33. }
  34. }
  35. }