DCOLSUB.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. namespace OpenVIII.Fields.Scripts.Instructions
  4. {
  5. internal sealed class DCOLSUB : JsmInstruction
  6. {
  7. private readonly IJsmExpression _r;
  8. private readonly IJsmExpression _g;
  9. private readonly IJsmExpression _b;
  10. public DCOLSUB(IJsmExpression r, IJsmExpression g, IJsmExpression b)
  11. {
  12. _r = r;
  13. _g = g;
  14. _b = b;
  15. }
  16. public DCOLSUB(Int32 parameter, IStack<IJsmExpression> stack)
  17. : this(
  18. b: stack.Pop(),
  19. g: stack.Pop(),
  20. r: stack.Pop())
  21. {
  22. }
  23. public override String ToString()
  24. {
  25. return $"{nameof(DCOLSUB)}({nameof(_r)}: {_r}, {nameof(_g)}: {_g}, {nameof(_b)}: {_b})";
  26. }
  27. public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
  28. {
  29. sw.Format(formatterContext, services)
  30. .StaticType(nameof(IRenderingService))
  31. .Method(nameof(IRenderingService.SubScreenColor))
  32. .Argument("r", _r)
  33. .Argument("g", _g)
  34. .Argument("b", _b)
  35. .Comment(nameof(DCOLSUB));
  36. }
  37. public override IAwaitable TestExecute(IServices services)
  38. {
  39. ServiceId.Rendering[services].SubScreenColor(
  40. new Color(
  41. _r.Int32(services),
  42. _g.Int32(services),
  43. _b.Int32(services)));
  44. return DummyAwaitable.Instance;
  45. }
  46. }
  47. }