Events.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. registerInputEvent("fxDtsBrick", "WormholeIncoming", "Self fxDtsBrick");
  2. registerInputEvent("fxDtsBrick", "WormholeOutgoing", "Self fxDtsBrick");
  3. registerInputEvent("fxDtsBrick", "WormholeShutdown", "Self fxDtsBrick");
  4. registerInputEvent("fxDtsBrick", "onValidIDC", "Self fxDtsBrick");
  5. registerInputEvent("fxDtsBrick", "onValidIDC_D", "Self fxDtsBrick");
  6. registerInputEvent("fxDtsBrick", "onValidIDC_O", "Self fxDtsBrick");
  7. registerInputEvent("fxDtsBrick", "onConfirmIDC", "Self fxDtsBrick");
  8. registerOutputEvent("fxDtsBrick", "MessageAllInRange", "string 200 255", 0);
  9. registerOutputEvent("fxDtsBrick", "CheckIDC", "string 200 255", 1);
  10. function fxDtsBrick::WormholeIncoming(%brick, %cl)
  11. {
  12. $InputTarget_Self = %brick;
  13. %brick.processInputEvent("IncomingWormhole", %cl);
  14. %brick.processInputEvent("WormholeIncoming", %cl);
  15. }
  16. function fxDtsBrick::WormholeOutgoing(%brick, %cl)
  17. {
  18. $InputTarget_Self = %brick;
  19. %brick.processInputEvent("WormholeOutgoing", %cl);
  20. }
  21. function fxDtsBrick::WormholeShutdown(%brick, %cl)
  22. {
  23. $InputTarget_Self = %brick;
  24. %brick.processInputEvent("WormholeShutdown", %cl);
  25. }
  26. function fxDtsBrick::ReceivedValidIDC(%brick, %idc, %cl)
  27. {
  28. %brick.lastValidIDC = %idc;
  29. $InputTarget_Self = %brick;
  30. %brick.processInputEvent("onValidIDC", %cl);
  31. }
  32. function fxDtsBrick::ReceivedValidIDC_D(%brick, %idc, %cl)
  33. {
  34. %brick.lastValidIDC = %idc;
  35. $InputTarget_Self = %brick;
  36. %brick.processInputEvent("onValidIDC_D", %cl);
  37. }
  38. function fxDtsBrick::ReceivedValidIDC_O(%brick, %idc, %cl)
  39. {
  40. %brick.lastValidIDC = %idc;
  41. $InputTarget_Self = %brick;
  42. %brick.processInputEvent("onValidIDC_O", %cl);
  43. }
  44. function fxDtsBrick::CheckIDC(%brick, %list, %cl)
  45. {
  46. %idc = %brick.lastValidIDC;
  47. %words = getWordCount(%list);
  48. $InputTarget_Self = %brick;
  49. for(%i=0;%i<%words;%i++)
  50. if(getWord(%list, %i) $= %idc)
  51. { %brick.processInputEvent("onConfirmIDC", %cl); return; }
  52. }
  53. function fxDtsBrick::MessageAllInRange(%brick, %msg)
  54. {
  55. if(%brick.lastValidIDC !$= "")
  56. %msg = strReplace(%msg, "[IDC]", %brick.lastValidIDC);
  57. MessageAllInRange(%brick.getPosition(), %msg);
  58. }
  59. function MessageAllInRange(%pos, %msg)
  60. {
  61. %gates = StargateNetwork.getCount();
  62. for(%i=0;%i<%gates;%i++)
  63. {
  64. %gate = StargateNetwork.getObject(%i);
  65. if(isObject(%pair = %gate.linkedGate)
  66. || isObject(%pair = %gate.masterGate))
  67. {
  68. %gateDist[%i] = getMin(vectorDist(%pos, %gate.getPosition()),
  69. vectorDist(%pos, %pair.getPosition()));
  70. }
  71. }
  72. %clients = ClientGroup.getCount();
  73. for(%i=0;%i<%clients;%i++)
  74. {
  75. %this = ClientGroup.getObject(%i);
  76. if(!%this.hasSpawnedOnce) %loc = "0 0 0";
  77. else %loc = %this.getControlObject().getEyePoint();
  78. if(vectorDist(%pos, %loc) < 256)
  79. %this.chatMessage(%msg);
  80. else
  81. {
  82. for(%j=0;%j<%gates;%j++)
  83. {
  84. if(%gateDist[%j] $= "") continue; %sumDist = vectorDist(%loc, StargateNetwork.getObject(%j).getPosition()) + %gateDist[%j];
  85. if(%sumDist < 256) { %this.chatMessage(%msg); break; }
  86. }
  87. }
  88. }
  89. }