gdcore-tools 2.0.0-beta9 → 2.0.0-gd-v5.4.218-autobuild

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +64 -64
  2. package/dist/Runtime/Extensions/3D/JsExtension.js +7 -3
  3. package/dist/Runtime/Extensions/DialogueTree/JsExtension.js +44 -32
  4. package/dist/Runtime/Extensions/DialogueTree/bondage.js/dist/bondage.min.js +10 -10
  5. package/dist/Runtime/Extensions/DialogueTree/bondage.js/version.txt +5 -5
  6. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js +2 -2
  7. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
  8. package/dist/Runtime/Extensions/Firebase/A_firebasejs/NOTICE.txt +6 -6
  9. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  10. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  11. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  12. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  13. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  14. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  15. package/dist/Runtime/Extensions/PhysicsBehavior/box2djs/box2d.js +804 -804
  16. package/dist/Runtime/Extensions/Shopify/shopify-buy.umd.polyfilled.min.js +1 -1
  17. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  18. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  19. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  20. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  21. package/dist/Runtime/Extensions/TileMap/example/anotherIsland.json +5768 -5768
  22. package/dist/Runtime/Extensions/TileMap/example/island.json +5822 -5822
  23. package/dist/Runtime/Model3DManager.js +1 -1
  24. package/dist/Runtime/Model3DManager.js.map +2 -2
  25. package/dist/Runtime/ResourceLoader.js +1 -1
  26. package/dist/Runtime/ResourceLoader.js.map +2 -2
  27. package/dist/Runtime/capturemanager.js +2 -0
  28. package/dist/Runtime/capturemanager.js.map +7 -0
  29. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
  30. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  31. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  32. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  33. package/dist/Runtime/jsonmanager.js +1 -1
  34. package/dist/Runtime/jsonmanager.js.map +2 -2
  35. package/dist/Runtime/layer.js +1 -1
  36. package/dist/Runtime/layer.js.map +2 -2
  37. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
  38. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  39. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  40. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  41. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  42. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  43. package/dist/Runtime/runtimegame.js +1 -1
  44. package/dist/Runtime/runtimegame.js.map +2 -2
  45. package/dist/Runtime/runtimewatermark.js +2 -2
  46. package/dist/Runtime/runtimewatermark.js.map +2 -2
  47. package/dist/Runtime/scenestack.js +1 -1
  48. package/dist/Runtime/scenestack.js.map +2 -2
  49. package/dist/Runtime/spriteruntimeobject.js +1 -1
  50. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  51. package/dist/lib/libGD.cjs +21 -21
  52. package/dist/lib/libGD.wasm +0 -0
  53. package/gd.d.ts +22 -6
  54. package/package.json +1 -1
  55. package/dist/Runtime/Extensions/TileMap/helper/node_modules/.package-lock.json +0 -19
  56. package/dist/Runtime/Extensions/TileMap/helper/node_modules/@types/pako/index.d.ts +0 -165
  57. package/dist/Runtime/Extensions/TileMap/helper/node_modules/@types/pako/package.json +0 -35
  58. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.js +0 -2
  59. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.js.map +0 -7
  60. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.min.js +0 -2
  61. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.js +0 -2
  62. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.js.map +0 -7
  63. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.min.js +0 -2
  64. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.js +0 -2
  65. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.js.map +0 -7
  66. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.min.js +0 -2
  67. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.js +0 -2
  68. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.js.map +0 -7
  69. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.min.js +0 -2
  70. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.js +0 -2
  71. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.js.map +0 -7
  72. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.min.js +0 -2
  73. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.js +0 -2
  74. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.js.map +0 -7
  75. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.min.js +0 -2
  76. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/index.js +0 -2
  77. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/index.js.map +0 -7
  78. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/deflate.js +0 -2
  79. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/deflate.js.map +0 -7
  80. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/inflate.js +0 -2
  81. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/inflate.js.map +0 -7
  82. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/common.js +0 -2
  83. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/common.js.map +0 -7
  84. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/strings.js +0 -2
  85. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/strings.js.map +0 -7
  86. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/adler32.js +0 -2
  87. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/adler32.js.map +0 -7
  88. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/constants.js +0 -2
  89. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/constants.js.map +0 -7
  90. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/crc32.js +0 -2
  91. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/crc32.js.map +0 -7
  92. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/deflate.js +0 -2
  93. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/deflate.js.map +0 -7
  94. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/gzheader.js +0 -2
  95. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/gzheader.js.map +0 -7
  96. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inffast.js +0 -2
  97. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inffast.js.map +0 -7
  98. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inflate.js +0 -2
  99. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inflate.js.map +0 -7
  100. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inftrees.js +0 -2
  101. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inftrees.js.map +0 -7
  102. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/messages.js +0 -2
  103. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/messages.js.map +0 -7
  104. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/trees.js +0 -2
  105. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/trees.js.map +0 -7
  106. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/zstream.js +0 -2
  107. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/zstream.js.map +0 -7
  108. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/package.json +0 -64
  109. package/types/index.d.ts +0 -23
  110. package/types/open_project.d.ts +0 -25
@@ -1,5 +1,5 @@
1
- This extension is using bondage.js library to parse yarn syntax.
2
- https://github.com/hylyh/bondage.js
3
-
4
- The current build used is built from commit 3c63e21
5
-
1
+ This extension is using bondage.js library to parse yarn syntax.
2
+ https://github.com/hylyh/bondage.js
3
+
4
+ The current build used is built from commit 3c63e21
5
+
@@ -1,3 +1,3 @@
1
- var gdjs;(function(e){const s=new e.Logger("Dialogue tree");e.dialogueTree={},e.dialogueTree.runner=new bondage.Runner,e.dialogueTree.loadFromSceneVariable=function(i,t){this.runner=e.dialogueTree.runner;try{this.yarnData=JSON.parse(i.getAsString()),this.runner.load(this.yarnData),t&&t.length>0&&e.dialogueTree.startFrom(t)}catch(a){s.error("Error while loading from scene variable: ",a)}},e.dialogueTree.loadFromJsonFile=function(i,t,a){i.getGame().getJsonManager().loadJson(t,function(r,n){if(r)s.error("An error happened while loading JSON resource:",r);else{if(!n)return;e.dialogueTree.yarnData=n;try{e.dialogueTree.runner.load(e.dialogueTree.yarnData)}catch(o){s.error("An error happened while loading parsing the dialogue tree data:",o)}a&&a.length>0&&e.dialogueTree.startFrom(a)}})},e.dialogueTree.stopRunningDialogue=function(){this.dialogueIsRunning&&(this.dialogueIsRunning=!1),this.dialogueData&&(this.dialogueData=null),this.dialogueText="",this.clipTextEnd=0},e.dialogueTree.isRunning=function(){return this.dialogueIsRunning&&!this.dialogueData&&this.dialogueText&&this.clipTextEnd>=this.dialogueText.length&&(this.dialogueIsRunning=!1),this.dialogueIsRunning},e.dialogueTree.scrollClippedText=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning)){if(e.dialogueTree._isLineTypeCommand()&&this.dialogueDataType==="text"&&this.dialogueBranchTitle===this.dialogueData.data.title&&this.lineNum===this.dialogueData.lineNum&&e.dialogueTree.hasClippedScrollingCompleted()){e.dialogueTree.goToNextDialogueLine();return}this.dialogueText&&this.dialogueDataType==="text"&&this.clipTextEnd<this.dialogueText.length&&(this.clipTextEnd+=1)}},e.dialogueTree.completeClippedTextScrolling=function(){this.pauseScrolling||!this.dialogueIsRunning||!this.dialogueText||this.dialogueDataType!=="text"||(this.clipTextEnd=this.dialogueText.length)},e.dialogueTree.hasClippedScrollingCompleted=function(){return!this.dialogueIsRunning||this.dialogueDataType===""?!1:this.dialogueData&&this.dialogueText.length>0&&this.clipTextEnd>=this.dialogueText.length?(e.dialogueTree.getVariable("debug")&&s.warn("Scroll completed:",this.clipTextEnd,"/",this.dialogueText.length),!0):!1},e.dialogueTree.getClippedLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText.substring(0,this.clipTextEnd+1):""},e.dialogueTree.getLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText:""},e.dialogueTree.commandParametersCount=function(){return this.commandParameters&&this.commandParameters.length>1?this.commandParameters.length-1:0},e.dialogueTree.getCommandParameter=function(i){if(i===-1&&this.commandParameters.length>0)return this.commandParameters[0];if(this.commandParameters&&this.commandParameters.length>=i+1){const t=this.commandParameters[i+1];return t||""}return""},e.dialogueTree.isCommandCalled=function(i){if(!this.dialogueIsRunning)return!1;const t=e.dialogueTree.commandCalls,a=e.dialogueTree.clipTextEnd,r=e.dialogueTree.dialogueText;return this.pauseScrolling||!t?!1:this.commandCalls.some(function(n,o){if(a!==0&&a<n.time)return!1;if(n.cmd==="wait"&&(a===0||a!==r.length)&&(e.dialogueTree.pauseScrolling=!0,setTimeout(function(){e.dialogueTree.pauseScrolling=!1,t.splice(o,1),e.dialogueTree.getVariable("debug")&&s.info("CMD:",n)},parseInt(n.params[1],10))),n.cmd===i)return e.dialogueTree.commandParameters=n.params,t.splice(o,1),e.dialogueTree.getVariable("debug")&&s.info("CMD:",n),!0})},e.dialogueTree._normalizedOptionIndex=function(i){return i>=this.options.length&&(i=this.options.length-1),i<0&&(i=0),i},e.dialogueTree._cycledOptionIndex=function(i){return i>=this.options.length&&(i=0),i<0&&(i=this.options.length-1),i},e.dialogueTree.getLineOption=function(i){return!this.dialogueIsRunning||!this.options.length?[]:(i=e.dialogueTree._normalizedOptionIndex(i),this.options[i])},e.dialogueTree.getLineOptionsText=function(i,t){if(!this.dialogueIsRunning||!this.options.length)return"";let a="";return this.options.forEach(function(r,n){n===e.dialogueTree.selectedOption?a+=i:a+=i.replace(/.*/g," "),a+=r,t&&(a+=`
2
- `)}),a},e.dialogueTree.getLineOptionsTextHorizontal=function(i){return this.getLineOptionsText(i,!1)},e.dialogueTree.getLineOptionsTextVertical=function(i){return this.getLineOptionsText(i,!0)},e.dialogueTree.getLineOptionsCount=function(){return this.dialogueIsRunning&&this.options.length?this.optionsCount:0},e.dialogueTree.confirmSelectOption=function(){if(!!this.dialogueIsRunning&&this.dialogueData.select&&!this.selectedOptionUpdated&&this.selectedOption!==-1){this.commandCalls=[];try{this.dialogueData.select(this.selectedOption),this.dialogueData=this.dialogue.next().value,e.dialogueTree.goToNextDialogueLine()}catch(i){s.error("An error happened when trying to access the dialogue branch!",i)}}},e.dialogueTree.selectNextOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption+=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectPreviousOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption-=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectOption=function(i){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption=e.dialogueTree._normalizedOptionIndex(i),this.selectedOptionUpdated=!0)},e.dialogueTree.getSelectedOption=function(){if(!!this.dialogueIsRunning)return this.dialogueData.select?this.selectedOption:0},e.dialogueTree.hasSelectedOptionChanged=function(){return this.selectedOptionUpdated?(this.selectedOptionUpdated=!1,this.selectedOption===-1&&(this.selectedOption=0),!0):!1},e.dialogueTree.isDialogueLineType=function(i){if(!this.dialogueIsRunning)return!1;if(this.commandCalls&&i==="command"){if(this.commandCalls.some(function(t){return e.dialogueTree.clipTextEnd>t.time&&t.cmd==="wait"}))return!this.pauseScrolling;if(this.commandCalls.length>0&&this.commandParameters.length>0)return!0}return this.dialogueDataType===i},e.dialogueTree.hasDialogueBranch=function(i){return this.runner&&this.runner.yarnNodes&&Object.keys(this.runner.yarnNodes).some(function(t){return t===i})},e.dialogueTree.startFrom=function(i){this.runner=e.dialogueTree.runner,!!this.hasDialogueBranch(i)&&(this.optionsCount=0,this.options=[],this.tagParameters=[],this.dialogue=this.runner.run(i),this.dialogueText="",this.clipTextEnd=0,this.commandCalls=[],this.commandParameters=[],this.pauseScrolling=!1,this.dialogueData=this.dialogue.next().value,this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,e.dialogueTree._isLineTypeText()?this.dialogueDataType="text":e.dialogueTree._isLineTypeOptions()?this.dialogueDataType="options":this.dialogueDataType="command",this.dialogueIsRunning=!0,e.dialogueTree.goToNextDialogueLine())},e.dialogueTree._isLineTypeText=function(){return this.dialogueData instanceof bondage.TextResult},e.dialogueTree._isLineTypeOptions=function(){return this.dialogueData instanceof bondage.OptionsResult},e.dialogueTree._isLineTypeCommand=function(){return this.dialogueData instanceof bondage.CommandResult},e.dialogueTree.goToNextDialogueLine=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning))if(this.optionsCount=0,this.selectedOption=-1,this.selectedOptionUpdated=!1,e.dialogueTree.getVariable("debug")&&s.info("Parsing:",this.dialogueData),!this.dialogueData)e.dialogueTree.stopRunningDialogue();else if(e.dialogueTree._isLineTypeText())this.lineNum===this.dialogueData.lineNum&&this.dialogueBranchTitle===this.dialogueData.data.title?(this.clipTextEnd=this.dialogueText.length-1,this.dialogueText+=(this.dialogueText===""?"":" ")+this.dialogueData.text):(this.clipTextEnd=0,this.dialogueText=this.dialogueData.text),this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,this.dialogueDataType="text",this.dialogueData=this.dialogue.next().value;else if(e.dialogueTree._isLineTypeOptions())this.commandCalls=[],this.dialogueDataType="options",this.dialogueText="",this.clipTextEnd=0,this.optionsCount=this.dialogueData.options.length,this.options=this.dialogueData.options,this.selectedOptionUpdated=!0;else if(e.dialogueTree._isLineTypeCommand()){this.dialogueDataType="command";const i=this.dialogueData.text.split(" "),t=this.commandCalls.length&&this.commandCalls[this.commandCalls.length-1].cmd==="wait"?1:0;this.commandCalls.push({cmd:i[0],params:i,time:this.dialogueText.length+t}),this.dialogueData=this.dialogue.next().value,e.dialogueTree.goToNextDialogueLine()}else this.dialogueDataType="unknown"},e.dialogueTree.getBranchTitle=function(){return this.dialogueIsRunning?this.dialogueBranchTitle:""},e.dialogueTree.branchTitleIs=function(i){return this.dialogueIsRunning?this.dialogueBranchTitle===i:!1},e.dialogueTree.getBranchTags=function(){return this.dialogueIsRunning?this.dialogueBranchTags.join(","):""},e.dialogueTree.getBranchTag=function(i){return this.dialogueIsRunning&&this.dialogueBranchTags.length?(i>this.dialogueBranchTags.length-1&&(i=this.dialogueBranchTags.length-1),this.dialogueBranchTags[i]):""},e.dialogueTree.branchContainsTag=function(i){return this.tagParameters=[],this.dialogueIsRunning&&this.dialogueBranchTags.length?this.dialogueBranchTags.some(function(t){const a=t.match(/([^\(]+)\(([^\)]+)\)/i);return e.dialogueTree.tagParameters=a?a[2].split(","):[],a?a[1]===i:t===i}):!1},e.dialogueTree.getTagParameter=function(i){if(this.dialogueIsRunning&&this.tagParameters.length>=i){const t=this.tagParameters[i];return t||""}return""},e.dialogueTree.getVisitedBranchTitles=function(){return this.dialogueIsRunning?Object.keys(this.runner.visited).join(","):""},e.dialogueTree.branchTitleHasBeenVisited=function(i){return i||(i=this.dialogueBranchTitle),Object.keys(this.runner.visited).includes(i)&&this.runner.visited[i]},e.dialogueTree.getBranchText=function(){return this.dialogueIsRunning?this.dialogueBranchBody:""},e.dialogueTree.getVariable=function(i){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i):""},e.dialogueTree.compareVariable=function(i,t){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i)===t:!1},e.dialogueTree.setVariable=function(i,t){this.runner.variables&&this.runner.variables.set(i,t)},e.dialogueTree.saveState=function(i){const t={variables:e.dialogueTree.runner.variables.data,visited:e.dialogueTree.runner.visited};i.fromJSObject(t)},e.dialogueTree.loadState=function(i){const t=i.toJSObject();if(!t){s.error("Load state variable is empty:",i);return}try{e.dialogueTree.runner.visited=t.visited,e.dialogueTree.runner.variables.data={},Object.keys(t.variables).forEach(function(a){const r=t.variables[a];e.dialogueTree.runner.variables.set(a,r)})}catch(a){s.error("Failed to load state from variable:",i,a)}},e.dialogueTree.clearState=function(){e.dialogueTree.runner.visited={},e.dialogueTree.runner.variables.data={}}})(gdjs||(gdjs={}));
1
+ var gdjs;(function(e){const n=new e.Logger("Dialogue tree");e.dialogueTree={},e.dialogueTree.runner=new bondage.Runner,e.dialogueTree.loadFromSceneVariable=function(i,t){this.runner=e.dialogueTree.runner;try{this.yarnData=JSON.parse(i.getAsString()),this.runner.load(this.yarnData),t&&t.length>0&&e.dialogueTree.startFrom(t)}catch(a){n.error("Error while loading from scene variable: ",a)}},e.dialogueTree.loadFromJsonFile=function(i,t,a){i.getGame().getJsonManager().loadJson(t,function(s,r){if(s)n.error("An error happened while loading JSON resource:",s);else{if(!r)return;e.dialogueTree.yarnData=r;try{e.dialogueTree.runner.load(e.dialogueTree.yarnData)}catch(o){n.error("An error happened while loading parsing the dialogue tree data:",o)}a&&a.length>0&&e.dialogueTree.startFrom(a)}})},e.dialogueTree.stopRunningDialogue=function(){this.dialogueIsRunning&&(this.dialogueIsRunning=!1),this.dialogueData&&(this.dialogueData=null),this.dialogueText="",this.clipTextEnd=0},e.dialogueTree.isRunning=function(){return this.dialogueIsRunning&&!this.dialogueData&&this.dialogueText&&this.clipTextEnd>=this.dialogueText.length&&(this.dialogueIsRunning=!1),this.dialogueIsRunning},e.dialogueTree.scrollClippedText=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning)){if(e.dialogueTree._isLineTypeCommand()&&this.dialogueDataType==="text"&&this.dialogueBranchTitle===this.dialogueData.data.title&&this.lineNum===this.dialogueData.lineNum&&e.dialogueTree.hasClippedScrollingCompleted()){e.dialogueTree.goToNextDialogueLine();return}this.dialogueText&&this.dialogueDataType==="text"&&this.clipTextEnd<this.dialogueText.length&&(this.clipTextEnd+=1)}},e.dialogueTree.completeClippedTextScrolling=function(){this.pauseScrolling||!this.dialogueIsRunning||!this.dialogueText||this.dialogueDataType!=="text"||(this.clipTextEnd=this.dialogueText.length)},e.dialogueTree.hasClippedScrollingCompleted=function(){return!this.dialogueIsRunning||this.dialogueDataType===""?!1:this.dialogueData&&this.dialogueText.length>0&&this.clipTextEnd>=this.dialogueText.length?(e.dialogueTree.getVariable("debug")&&n.warn("Scroll completed:",this.clipTextEnd,"/",this.dialogueText.length),!0):!1},e.dialogueTree.getClippedLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText.substring(0,this.clipTextEnd+1):""},e.dialogueTree.getLineText=function(){return this.dialogueIsRunning&&this.dialogueText.length?this.dialogueText:""},e.dialogueTree.commandParametersCount=function(){return this.commandParameters&&this.commandParameters.length>1?this.commandParameters.length-1:0},e.dialogueTree.getCommandParameter=function(i){if(i===-1&&this.commandParameters.length>0)return this.commandParameters[0];if(this.commandParameters&&this.commandParameters.length>=i+1){const t=this.commandParameters[i+1];return t||""}return""},e.dialogueTree.isCommandCalled=function(i){if(!this.dialogueIsRunning)return!1;const t=e.dialogueTree.commandCalls,a=e.dialogueTree.clipTextEnd,s=e.dialogueTree.dialogueText;return this.pauseScrolling||!t?!1:this.commandCalls.some(function(r,o){if(a!==0&&a<r.time)return!1;if(r.cmd==="wait"&&(a===0||a!==s.length)&&(e.dialogueTree.pauseScrolling=!0,setTimeout(function(){e.dialogueTree.pauseScrolling=!1,t.splice(o,1),e.dialogueTree.getVariable("debug")&&n.info("CMD:",r)},parseInt(r.params[1],10))),r.cmd===i)return e.dialogueTree.commandParameters=r.params,t.splice(o,1),e.dialogueTree.getVariable("debug")&&n.info("CMD:",r),!0})},e.dialogueTree._normalizedOptionIndex=function(i){return i>=this.options.length&&(i=this.options.length-1),i<0&&(i=0),i},e.dialogueTree._cycledOptionIndex=function(i){return i>=this.options.length&&(i=0),i<0&&(i=this.options.length-1),i},e.dialogueTree.getLineOption=function(i){return!this.dialogueIsRunning||!this.options.length?[]:(i=e.dialogueTree._normalizedOptionIndex(i),this.options[i])},e.dialogueTree.getLineOptionsText=function(i,t){if(!this.dialogueIsRunning||!this.options.length)return"";let a="";return this.options.forEach(function(s,r){r===e.dialogueTree.selectedOption?a+=i:a+=i.replace(/.*/g," "),a+=s,t&&(a+=`
2
+ `)}),a},e.dialogueTree.getLineOptionsTextHorizontal=function(i){return this.getLineOptionsText(i,!1)},e.dialogueTree.getLineOptionsTextVertical=function(i){return this.getLineOptionsText(i,!0)},e.dialogueTree.getLineOptionsCount=function(){return this.dialogueIsRunning&&this.options.length?this.optionsCount:0},e.dialogueTree.confirmSelectOption=function(){if(!!this.dialogueIsRunning&&this.dialogueData.select&&!this.selectedOptionUpdated&&this.selectedOption!==-1){this.commandCalls=[];try{this.dialogueData.select(this.selectedOption);try{this.dialogueData=this.dialogue.next().value}catch(i){n.error("Error while confirming in the dialogue tree. Verify if there is a syntax error? Full error is: ",i);return}e.dialogueTree.goToNextDialogueLine()}catch(i){n.error("An error happened when trying to access the dialogue branch!",i)}}},e.dialogueTree.selectNextOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption+=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectPreviousOption=function(){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption-=1,this.selectedOption=e.dialogueTree._cycledOptionIndex(this.selectedOption),this.selectedOptionUpdated=!0)},e.dialogueTree.selectOption=function(i){!this.dialogueIsRunning||this.dialogueData.select&&(this.selectedOption=e.dialogueTree._normalizedOptionIndex(i),this.selectedOptionUpdated=!0)},e.dialogueTree.getSelectedOption=function(){if(!!this.dialogueIsRunning)return this.dialogueData.select?this.selectedOption:0},e.dialogueTree.hasSelectedOptionChanged=function(){return this.selectedOptionUpdated?(this.selectedOptionUpdated=!1,this.selectedOption===-1&&(this.selectedOption=0),!0):!1},e.dialogueTree.isDialogueLineType=function(i){if(!this.dialogueIsRunning)return!1;if(this.commandCalls&&i==="command"){if(this.commandCalls.some(function(t){return e.dialogueTree.clipTextEnd>t.time&&t.cmd==="wait"}))return!this.pauseScrolling;if(this.commandCalls.length>0&&this.commandParameters.length>0)return!0}return this.dialogueDataType===i},e.dialogueTree.hasDialogueBranch=function(i){return this.runner&&this.runner.yarnNodes&&Object.keys(this.runner.yarnNodes).some(function(t){return t===i})},e.dialogueTree.startFrom=function(i){if(this.runner=e.dialogueTree.runner,!!this.hasDialogueBranch(i)){this.optionsCount=0,this.options=[],this.tagParameters=[];try{this.dialogue=this.runner.run(i)}catch(t){n.error("Error while setting up the dialogue tree. Verify if there is a syntax error? Full error is: ",t);return}this.dialogueText="",this.clipTextEnd=0,this.commandCalls=[],this.commandParameters=[],this.pauseScrolling=!1;try{this.dialogueData=this.dialogue.next().value}catch(t){n.error("Error while starting the dialogue tree. Verify if there is a syntax error? Full error is: ",t);return}this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,e.dialogueTree._isLineTypeText()?this.dialogueDataType="text":e.dialogueTree._isLineTypeOptions()?this.dialogueDataType="options":this.dialogueDataType="command",this.dialogueIsRunning=!0,e.dialogueTree.goToNextDialogueLine()}},e.dialogueTree._isLineTypeText=function(){return this.dialogueData instanceof bondage.TextResult},e.dialogueTree._isLineTypeOptions=function(){return this.dialogueData instanceof bondage.OptionsResult},e.dialogueTree._isLineTypeCommand=function(){return this.dialogueData instanceof bondage.CommandResult},e.dialogueTree.goToNextDialogueLine=function(){if(!(this.pauseScrolling||!this.dialogueIsRunning))if(this.optionsCount=0,this.selectedOption=-1,this.selectedOptionUpdated=!1,e.dialogueTree.getVariable("debug")&&n.info("Parsing:",this.dialogueData),!this.dialogueData)e.dialogueTree.stopRunningDialogue();else if(e.dialogueTree._isLineTypeText()){this.lineNum===this.dialogueData.lineNum&&this.dialogueBranchTitle===this.dialogueData.data.title?(this.clipTextEnd=this.dialogueText.length-1,this.dialogueText+=(this.dialogueText===""?"":" ")+this.dialogueData.text):(this.clipTextEnd=0,this.dialogueText=this.dialogueData.text),this.dialogueBranchTags=this.dialogueData.data.tags,this.dialogueBranchTitle=this.dialogueData.data.title,this.dialogueBranchBody=this.dialogueData.data.body,this.lineNum=this.dialogueData.lineNum,this.dialogueDataType="text";try{this.dialogueData=this.dialogue.next().value}catch(i){n.error("Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ",i);return}}else if(e.dialogueTree._isLineTypeOptions())this.commandCalls=[],this.dialogueDataType="options",this.dialogueText="",this.clipTextEnd=0,this.optionsCount=this.dialogueData.options.length,this.options=this.dialogueData.options,this.selectedOptionUpdated=!0;else if(e.dialogueTree._isLineTypeCommand()){this.dialogueDataType="command";const i=this.dialogueData.text.split(" "),t=this.commandCalls.length&&this.commandCalls[this.commandCalls.length-1].cmd==="wait"?1:0;this.commandCalls.push({cmd:i[0],params:i,time:this.dialogueText.length+t});try{this.dialogueData=this.dialogue.next().value}catch(a){n.error("Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ",a);return}e.dialogueTree.goToNextDialogueLine()}else this.dialogueDataType="unknown"},e.dialogueTree.getBranchTitle=function(){return this.dialogueIsRunning?this.dialogueBranchTitle:""},e.dialogueTree.branchTitleIs=function(i){return this.dialogueIsRunning?this.dialogueBranchTitle===i:!1},e.dialogueTree.getBranchTags=function(){return this.dialogueIsRunning?this.dialogueBranchTags.join(","):""},e.dialogueTree.getBranchTag=function(i){return this.dialogueIsRunning&&this.dialogueBranchTags.length?(i>this.dialogueBranchTags.length-1&&(i=this.dialogueBranchTags.length-1),this.dialogueBranchTags[i]):""},e.dialogueTree.branchContainsTag=function(i){return this.tagParameters=[],this.dialogueIsRunning&&this.dialogueBranchTags.length?this.dialogueBranchTags.some(function(t){const a=t.match(/([^\(]+)\(([^\)]+)\)/i);return e.dialogueTree.tagParameters=a?a[2].split(","):[],a?a[1]===i:t===i}):!1},e.dialogueTree.getTagParameter=function(i){if(this.dialogueIsRunning&&this.tagParameters.length>=i){const t=this.tagParameters[i];return t||""}return""},e.dialogueTree.getVisitedBranchTitles=function(){return this.dialogueIsRunning?Object.keys(this.runner.visited).join(","):""},e.dialogueTree.branchTitleHasBeenVisited=function(i){return i||(i=this.dialogueBranchTitle),Object.keys(this.runner.visited).includes(i)&&this.runner.visited[i]},e.dialogueTree.getBranchText=function(){return this.dialogueIsRunning?this.dialogueBranchBody:""},e.dialogueTree.getVariable=function(i){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i):""},e.dialogueTree.getVariableAsNumber=function(i){if(this.runner.variables&&i in this.runner.variables.data){const t=this.runner.variables.get(i);return typeof t!="number"?parseFloat(t)||0:isFinite(t)?t:0}return 0},e.dialogueTree.getVariableAsString=function(i){return this.runner.variables&&i in this.runner.variables.data?""+this.runner.variables.get(i):""},e.dialogueTree.compareVariable=function(i,t){return this.runner.variables&&i in this.runner.variables.data?this.runner.variables.get(i)===t:!1},e.dialogueTree.setVariable=function(i,t){this.runner.variables&&this.runner.variables.set(i,t)},e.dialogueTree.saveState=function(i){const t={variables:e.dialogueTree.runner.variables.data,visited:e.dialogueTree.runner.visited};i.fromJSObject(t)},e.dialogueTree.loadState=function(i){const t=i.toJSObject();if(!t){n.error("Load state variable is empty:",i);return}try{e.dialogueTree.runner.visited=t.visited,e.dialogueTree.runner.variables.data={},Object.keys(t.variables).forEach(function(a){const s=t.variables[a];e.dialogueTree.runner.variables.set(a,s)})}catch(a){n.error("Failed to load state from variable:",i,a)}},e.dialogueTree.clearState=function(){e.dialogueTree.runner.visited={},e.dialogueTree.runner.variables.data={}}})(gdjs||(gdjs={}));
3
3
  //# sourceMappingURL=dialoguetools.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/DialogueTree/dialoguetools.ts"],
4
- "sourcesContent": ["// @ts-nocheck - Weird usage of `this` in this file. Should be refactored.\n\nnamespace gdjs {\n const logger = new gdjs.Logger('Dialogue tree');\n\n gdjs.dialogueTree = {};\n gdjs.dialogueTree.runner = new bondage.Runner();\n\n /**\n * Load the Dialogue Tree data of the game. Initialize The Dialogue Tree, so as it can be used in the game.\n * @param sceneVar The variable to load the Dialogue tree data from. The data is a JSON string, created by Yarn.\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n gdjs.dialogueTree.loadFromSceneVariable = function (\n sceneVar: gdjs.Variable,\n startDialogueNode: string\n ) {\n this.runner = gdjs.dialogueTree.runner;\n try {\n this.yarnData = JSON.parse(sceneVar.getAsString());\n this.runner.load(this.yarnData);\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n } catch (e) {\n logger.error('Error while loading from scene variable: ', e);\n }\n };\n\n /**\n * Load the Dialogue Tree data from a JSON resource.\n *\n * @param instanceContainer The scene where the dialogue is running.\n * @param jsonResourceName The JSON resource where to load the Dialogue Tree data from. The data is a JSON string usually created with [Yarn Dialogue Editor](https://github.com/InfiniteAmmoInc/Yarn).\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n gdjs.dialogueTree.loadFromJsonFile = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n jsonResourceName: string,\n startDialogueNode: string\n ) {\n instanceContainer\n .getGame()\n .getJsonManager()\n .loadJson(jsonResourceName, function (error, content) {\n if (error) {\n logger.error('An error happened while loading JSON resource:', error);\n } else {\n if (!content) {\n return;\n }\n gdjs.dialogueTree.yarnData = content;\n try {\n gdjs.dialogueTree.runner.load(gdjs.dialogueTree.yarnData);\n } catch (error) {\n logger.error(\n 'An error happened while loading parsing the dialogue tree data:',\n error\n );\n }\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n }\n });\n };\n\n /**\n * Stop the currently running dialogue\n */\n gdjs.dialogueTree.stopRunningDialogue = function () {\n if (this.dialogueIsRunning) {\n this.dialogueIsRunning = false;\n }\n if (this.dialogueData) {\n this.dialogueData = null;\n }\n this.dialogueText = '';\n this.clipTextEnd = 0;\n };\n\n /**\n * Check if the Dialogue Tree is currently parsing data.\n * For example, you can do things like disabling player movement while talking to a NPC.\n */\n gdjs.dialogueTree.isRunning = function () {\n if (\n this.dialogueIsRunning &&\n !this.dialogueData &&\n this.dialogueText &&\n this.clipTextEnd >= this.dialogueText.length\n ) {\n this.dialogueIsRunning = false;\n }\n return this.dialogueIsRunning;\n };\n\n /**\n * Scroll the clipped text. This can be combined with a timer and user input to control how fast the dialogue line text is scrolling.\n */\n gdjs.dialogueTree.scrollClippedText = function () {\n if (this.pauseScrolling || !this.dialogueIsRunning) {\n return;\n }\n\n // Autoscroll commands so the user doesn't have to press again.\n if (\n gdjs.dialogueTree._isLineTypeCommand() &&\n this.dialogueDataType === 'text' &&\n this.dialogueBranchTitle === this.dialogueData.data.title &&\n this.lineNum === this.dialogueData.lineNum &&\n gdjs.dialogueTree.hasClippedScrollingCompleted()\n ) {\n gdjs.dialogueTree.goToNextDialogueLine();\n return;\n }\n\n // Increment scrolling of clipped text\n if (\n this.dialogueText &&\n this.dialogueDataType === 'text' &&\n this.clipTextEnd < this.dialogueText.length\n ) {\n this.clipTextEnd += 1;\n }\n };\n\n /**\n * Scroll the clipped text to its end, so the entire text is printed. This can be useful in keeping the event sheet logic simpler, while supporting more variation.\n */\n gdjs.dialogueTree.completeClippedTextScrolling = function () {\n if (\n this.pauseScrolling ||\n !this.dialogueIsRunning ||\n !this.dialogueText ||\n this.dialogueDataType !== 'text'\n ) {\n return;\n }\n this.clipTextEnd = this.dialogueText.length;\n };\n\n /**\n * Check if text scrolling has completed.\n * Useful to prevent the user from skipping to next line before the current one has been printed fully.\n */\n gdjs.dialogueTree.hasClippedScrollingCompleted = function () {\n if (!this.dialogueIsRunning || this.dialogueDataType === '') {\n return false;\n }\n if (\n this.dialogueData &&\n this.dialogueText.length > 0 &&\n this.clipTextEnd >= this.dialogueText.length\n ) {\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.warn(\n 'Scroll completed:',\n this.clipTextEnd,\n '/',\n this.dialogueText.length\n );\n }\n return true;\n }\n return false;\n };\n\n /**\n * Get the current dialogue line with a scrolling effect (recommended).\n * Used with the scrollClippedText to achieve a classic scrolling text, as well as any <<wait>> effects to pause scrolling.\n */\n gdjs.dialogueTree.getClippedLineText = function () {\n return this.dialogueIsRunning && this.dialogueText.length\n ? this.dialogueText.substring(0, this.clipTextEnd + 1)\n : '';\n };\n\n /**\n * Get the current complete dialogue line without using any scrolling effects.\n * Note that using this instead getClippedLineText will skip any <<wait>> commands entirely.\n */\n gdjs.dialogueTree.getLineText = function () {\n return this.dialogueIsRunning && this.dialogueText.length\n ? this.dialogueText\n : '';\n };\n\n /**\n * Get the number of command parameters in a command with parameters that has been caught by a isCommandCalled condition\n */\n gdjs.dialogueTree.commandParametersCount = function () {\n if (this.commandParameters && this.commandParameters.length > 1) {\n return this.commandParameters.length - 1;\n }\n return 0;\n };\n\n /**\n * Get a command parameter in any command with parameters that has been caught by a isCommandCalled condition\n * @param paramIndex The index of the parameter to get.\n */\n gdjs.dialogueTree.getCommandParameter = function (paramIndex: float) {\n if (paramIndex === -1 && this.commandParameters.length > 0) {\n return this.commandParameters[0];\n }\n if (\n this.commandParameters &&\n this.commandParameters.length >= paramIndex + 1\n ) {\n const returnedParam = this.commandParameters[paramIndex + 1];\n return returnedParam ? returnedParam : '';\n }\n return '';\n };\n\n /**\n * Catch <<commands>> and <<commands with parameters>> from the current Dialogue Line.\n * You can trigger custom logic that relate to the story you are telling during the dialogue.\n *\n * @param command The command you want to check for being called. Write it without the `<<>>`.\n */\n gdjs.dialogueTree.isCommandCalled = function (command: string) {\n if (!this.dialogueIsRunning) {\n return false;\n }\n const commandCalls = gdjs.dialogueTree.commandCalls;\n const clipTextEnd = gdjs.dialogueTree.clipTextEnd;\n const dialogueText = gdjs.dialogueTree.dialogueText;\n if (this.pauseScrolling || !commandCalls) {\n return false;\n }\n return this.commandCalls.some(function (call, index) {\n if (clipTextEnd !== 0 && clipTextEnd < call.time) {\n return false;\n }\n if (\n call.cmd === 'wait' &&\n (clipTextEnd === 0 || clipTextEnd !== dialogueText.length)\n ) {\n gdjs.dialogueTree.pauseScrolling = true;\n setTimeout(function () {\n gdjs.dialogueTree.pauseScrolling = false;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n }, parseInt(call.params[1], 10));\n }\n if (call.cmd === command) {\n gdjs.dialogueTree.commandParameters = call.params;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n return true;\n }\n });\n };\n\n /**\n * Internal method to allow for capping option selection.\n */\n gdjs.dialogueTree._normalizedOptionIndex = function (optionIndex) {\n if (optionIndex >= this.options.length) {\n optionIndex = this.options.length - 1;\n }\n if (optionIndex < 0) {\n optionIndex = 0;\n }\n return optionIndex;\n };\n\n /**\n * Internal method to allow for cycling option selection.\n */\n gdjs.dialogueTree._cycledOptionIndex = function (optionIndex) {\n if (optionIndex >= this.options.length) {\n optionIndex = 0;\n }\n if (optionIndex < 0) {\n optionIndex = this.options.length - 1;\n }\n return optionIndex;\n };\n\n /**\n * Get the text of an option the player can select.\n * Used with getLineOptionsCount to render options for the player when a line of the Options type is parsed\n * @param optionIndex The index of the option you want to get\n */\n gdjs.dialogueTree.getLineOption = function (optionIndex: float) {\n if (!this.dialogueIsRunning || !this.options.length) {\n return [];\n }\n optionIndex = gdjs.dialogueTree._normalizedOptionIndex(optionIndex);\n return this.options[optionIndex];\n };\n\n /**\n * Get the text of the options the player can select, along with the selection cursor.\n * @param optionSelectionCursor The string used to draw the currently selected option's cursor\n * @param addNewLine when true each option is rendered on a new line.\n */\n gdjs.dialogueTree.getLineOptionsText = function (\n optionSelectionCursor: string,\n addNewLine: boolean\n ) {\n if (!this.dialogueIsRunning || !this.options.length) {\n return '';\n }\n let textResult = '';\n this.options.forEach(function (optionText, index) {\n if (index === gdjs.dialogueTree.selectedOption) {\n textResult += optionSelectionCursor;\n } else {\n textResult += optionSelectionCursor.replace(/.*/g, ' ');\n }\n textResult += optionText;\n if (addNewLine) {\n textResult += '\\n';\n }\n });\n return textResult;\n };\n gdjs.dialogueTree.getLineOptionsTextHorizontal = function (\n optionSelectionCursor\n ) {\n return this.getLineOptionsText(optionSelectionCursor, false);\n };\n gdjs.dialogueTree.getLineOptionsTextVertical = function (\n optionSelectionCursor\n ) {\n return this.getLineOptionsText(optionSelectionCursor, true);\n };\n\n /**\n * Get the number of options that are presented to the player, during the parsing of an Options type line.\n * @returns The number of options\n */\n gdjs.dialogueTree.getLineOptionsCount = function (): number {\n if (this.dialogueIsRunning && this.options.length) {\n return this.optionsCount;\n }\n return 0;\n };\n\n /**\n * Confirm the currently selected option, during the parsing of an Options type line.\n *\n * This will advance the dialogue tree to the dialogue branch was selected by the player.\n */\n gdjs.dialogueTree.confirmSelectOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (\n this.dialogueData.select &&\n !this.selectedOptionUpdated &&\n this.selectedOption !== -1\n ) {\n this.commandCalls = [];\n try {\n this.dialogueData.select(this.selectedOption);\n this.dialogueData = this.dialogue.next().value;\n gdjs.dialogueTree.goToNextDialogueLine();\n } catch (error) {\n logger.error(\n `An error happened when trying to access the dialogue branch!`,\n error\n );\n }\n }\n };\n\n /**\n * Select next option during Options type line parsing. Hook this to your game input.\n */\n gdjs.dialogueTree.selectNextOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption += 1;\n this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(\n this.selectedOption\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Select previous option during Options type line parsing. Hook this to your game input.\n */\n gdjs.dialogueTree.selectPreviousOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption -= 1;\n this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(\n this.selectedOption\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Select option by index during Options type line parsing.\n * @param optionIndex The index of the option to select\n */\n gdjs.dialogueTree.selectOption = function (optionIndex: float) {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption = gdjs.dialogueTree._normalizedOptionIndex(\n optionIndex\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Get the currently selected option\n * @returns The index of the currently selected option\n */\n gdjs.dialogueTree.getSelectedOption = function (): number {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n return this.selectedOption;\n }\n return 0;\n };\n\n /**\n * Check when the player has changed option selection since the last call to this function.\n *\n * Can be used to re-render your displayed dialogue options when needed.\n *\n * @returns true if the selected option was updated since the last call to this function\n */\n gdjs.dialogueTree.hasSelectedOptionChanged = function (): boolean {\n if (this.selectedOptionUpdated) {\n this.selectedOptionUpdated = false;\n if (this.selectedOption === -1) {\n this.selectedOption = 0;\n }\n return true;\n }\n return false;\n };\n\n /**\n * Check the type of the Dialogue Line that is being displayed to the player at the moment.\n *\n * There are three types:\n * - text - regular dialogue text is being parsed at the moment\n * - options - the player has reached a branching choice moment where they must select one of multiple options\n * - command - a <<command>> was called in the background, that can be used to trigger game events, but will not be displayed in the dialogue box.\n *\n * @param type The type you want to check for ( one of the three above )\n */\n gdjs.dialogueTree.isDialogueLineType = function (type: string) {\n if (!this.dialogueIsRunning) {\n return false;\n }\n if (this.commandCalls && type === 'command') {\n if (\n this.commandCalls.some(function (call) {\n return (\n gdjs.dialogueTree.clipTextEnd > call.time && call.cmd === 'wait'\n );\n })\n ) {\n return !this.pauseScrolling;\n }\n if (this.commandCalls.length > 0 && this.commandParameters.length > 0) {\n return true;\n }\n }\n return this.dialogueDataType === type;\n };\n\n /**\n * Check if a branch exists. It is also used internally whenever you use the start from action.\n * @param branchName The Dialogue Branch name you want to check.\n */\n gdjs.dialogueTree.hasDialogueBranch = function (branchName: string) {\n return (\n this.runner &&\n this.runner.yarnNodes &&\n Object.keys(this.runner.yarnNodes).some(function (node) {\n return node === branchName;\n })\n );\n };\n\n /**\n * Start parsing dialogue from a specified Dialogue tree branch.\n * Can be used if you want to store multiple dialogues inside a single Dialogue tree data set.\n * @param startDialogueNode The Dialogue Branch name you want to start parsing from.\n */\n gdjs.dialogueTree.startFrom = function (startDialogueNode: string) {\n this.runner = gdjs.dialogueTree.runner;\n if (!this.hasDialogueBranch(startDialogueNode)) {\n return;\n }\n this.optionsCount = 0;\n this.options = [];\n this.tagParameters = [];\n this.dialogue = this.runner.run(startDialogueNode);\n this.dialogueText = '';\n this.clipTextEnd = 0;\n this.commandCalls = [];\n this.commandParameters = [];\n this.pauseScrolling = false;\n this.dialogueData = this.dialogue.next().value;\n this.dialogueBranchTags = this.dialogueData.data.tags;\n this.dialogueBranchTitle = this.dialogueData.data.title;\n this.dialogueBranchBody = this.dialogueData.data.body;\n this.lineNum = this.dialogueData.lineNum;\n if (gdjs.dialogueTree._isLineTypeText()) {\n this.dialogueDataType = 'text';\n } else {\n if (gdjs.dialogueTree._isLineTypeOptions()) {\n this.dialogueDataType = 'options';\n } else {\n this.dialogueDataType = 'command';\n }\n }\n this.dialogueIsRunning = true;\n gdjs.dialogueTree.goToNextDialogueLine();\n };\n\n /**\n * Internal methods to check the type of a Dialogue Line\n */\n gdjs.dialogueTree._isLineTypeText = function () {\n return this.dialogueData instanceof bondage.TextResult;\n };\n gdjs.dialogueTree._isLineTypeOptions = function () {\n return this.dialogueData instanceof bondage.OptionsResult;\n };\n gdjs.dialogueTree._isLineTypeCommand = function () {\n return this.dialogueData instanceof bondage.CommandResult;\n };\n\n /**\n * This is the main lifecycle function.It runs once only when the user is advancing the dialogue to the next line.\n * Progress Dialogue to the next line. Hook it to your game input.\n * Note that this action can be influenced by any <<wait>> commands, but they work only if you have at least one isCommandCalled condition.\n */\n gdjs.dialogueTree.goToNextDialogueLine = function () {\n if (this.pauseScrolling || !this.dialogueIsRunning) {\n return;\n }\n this.optionsCount = 0;\n this.selectedOption = -1;\n this.selectedOptionUpdated = false;\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('Parsing:', this.dialogueData);\n }\n if (!this.dialogueData) {\n gdjs.dialogueTree.stopRunningDialogue();\n } else {\n if (gdjs.dialogueTree._isLineTypeText()) {\n if (\n this.lineNum === this.dialogueData.lineNum &&\n this.dialogueBranchTitle === this.dialogueData.data.title\n ) {\n this.clipTextEnd = this.dialogueText.length - 1;\n this.dialogueText +=\n (this.dialogueText === '' ? '' : ' ') + this.dialogueData.text;\n } else {\n this.clipTextEnd = 0;\n this.dialogueText = this.dialogueData.text;\n }\n this.dialogueBranchTags = this.dialogueData.data.tags;\n this.dialogueBranchTitle = this.dialogueData.data.title;\n this.dialogueBranchBody = this.dialogueData.data.body;\n this.lineNum = this.dialogueData.lineNum;\n this.dialogueDataType = 'text';\n this.dialogueData = this.dialogue.next().value;\n } else {\n if (gdjs.dialogueTree._isLineTypeOptions()) {\n this.commandCalls = [];\n this.dialogueDataType = 'options';\n this.dialogueText = '';\n this.clipTextEnd = 0;\n this.optionsCount = this.dialogueData.options.length;\n this.options = this.dialogueData.options;\n this.selectedOptionUpdated = true;\n } else {\n if (gdjs.dialogueTree._isLineTypeCommand()) {\n this.dialogueDataType = 'command';\n const command = this.dialogueData.text.split(' ');\n\n // If last command was to wait, increase time by one\n const offsetTime =\n this.commandCalls.length &&\n this.commandCalls[this.commandCalls.length - 1].cmd === 'wait'\n ? 1\n : 0;\n this.commandCalls.push({\n cmd: command[0],\n params: command,\n time: this.dialogueText.length + offsetTime,\n });\n this.dialogueData = this.dialogue.next().value;\n gdjs.dialogueTree.goToNextDialogueLine();\n } else {\n this.dialogueDataType = 'unknown';\n }\n }\n }\n }\n };\n\n /**\n * Get the current Dialogue Tree branch title.\n * @returns The current branch title.\n */\n gdjs.dialogueTree.getBranchTitle = function (): string {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTitle;\n }\n return '';\n };\n\n /**\n * Check if the currently parsed Dialogue branch title is a query.\n * @param title The Dialogue Branch name you want to check for.\n */\n gdjs.dialogueTree.branchTitleIs = function (title: string) {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTitle === title;\n }\n return false;\n };\n\n /**\n * Get all the branch tags from the current Dialogue branch as a string. Useful for debugging.\n * @returns The current branch tags, separated by a comma.\n */\n gdjs.dialogueTree.getBranchTags = function (): string {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTags.join(',');\n }\n return '';\n };\n\n /**\n * Get one of the current Dialogue branch tags via index.\n * @param index The index of the Dialogue Branch tag you want to get.\n * @returns The branch tag at the specified index, or an empty string if not found.\n */\n gdjs.dialogueTree.getBranchTag = function (index: float): string {\n if (this.dialogueIsRunning && this.dialogueBranchTags.length) {\n if (index > this.dialogueBranchTags.length - 1) {\n index = this.dialogueBranchTags.length - 1;\n }\n return this.dialogueBranchTags[index];\n }\n return '';\n };\n\n /**\n * Check if the current Dialogue branch contains a specific tag.\n * @param query The name of the Dialogue Branch tag you want to check.\n */\n gdjs.dialogueTree.branchContainsTag = function (query: string) {\n this.tagParameters = [];\n if (this.dialogueIsRunning && this.dialogueBranchTags.length) {\n return this.dialogueBranchTags.some(function (tag) {\n const splitTag = tag.match(/([^\\(]+)\\(([^\\)]+)\\)/i);\n gdjs.dialogueTree.tagParameters = splitTag\n ? splitTag[2].split(',')\n : [];\n return splitTag ? splitTag[1] === query : tag === query;\n });\n }\n return false;\n };\n\n /**\n * Get any tag(parameter,anotherParameter) from a tag captured by the branchContainsTag Condition\n * @param paramIndex The index of the tag parameter you want to get.\n * Leaving this empty will result in retrieving the first parameter.\n */\n gdjs.dialogueTree.getTagParameter = function (paramIndex: float) {\n if (this.dialogueIsRunning && this.tagParameters.length >= paramIndex) {\n const returnedParam = this.tagParameters[paramIndex];\n return returnedParam ? returnedParam : '';\n }\n return '';\n };\n\n /**\n * Get a list of all the titles of visited by the player Branches. Useful for debugging.\n */\n gdjs.dialogueTree.getVisitedBranchTitles = function () {\n if (this.dialogueIsRunning) {\n return Object.keys(this.runner.visited).join(',');\n }\n return '';\n };\n\n /**\n * Check if a player has visited a Dialogue Branch in the past.\n * @param title The title of the branch to check for.\n * Leaving this empty will check if the current branch title has been visited in the past.\n */\n gdjs.dialogueTree.branchTitleHasBeenVisited = function (title: string) {\n if (!title) {\n title = this.dialogueBranchTitle;\n }\n return (\n Object.keys(this.runner.visited).includes(title) &&\n this.runner.visited[title]\n );\n };\n\n /**\n * Get the entire unparsed text of the current Dialogue Branch\n */\n gdjs.dialogueTree.getBranchText = function () {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchBody;\n }\n return '';\n };\n\n /**\n * Get the value of a variable that was created by the Dialogue parses.\n * @param key The name of the variable you want to get the value of\n */\n gdjs.dialogueTree.getVariable = function (key: string) {\n if (this.runner.variables && key in this.runner.variables.data) {\n return this.runner.variables.get(key);\n }\n return '';\n };\n\n /**\n * Check if a specific variable created by the Dialogue parses exists and is equal to a specific value.\n * @param key The name of the variable you want to check the value of\n * @param value The value you want to check against\n */\n gdjs.dialogueTree.compareVariable = function (\n key: string,\n value: string | boolean | number\n ) {\n if (this.runner.variables && key in this.runner.variables.data) {\n return this.runner.variables.get(key) === value;\n }\n return false;\n };\n\n /**\n * Set a specific variable created by the Dialogue parser to a specific value.\n * @param key The name of the variable you want to set the value of\n * @param value The value you want to set\n */\n gdjs.dialogueTree.setVariable = function (\n key: string,\n value: string | boolean | number\n ) {\n if (this.runner.variables) {\n this.runner.variables.set(key, value);\n }\n };\n\n /**\n * Store the current State of the Dialogue Parser in a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param outputVariable The variable where to store the State\n */\n gdjs.dialogueTree.saveState = function (outputVariable: gdjs.Variable) {\n const dialogueState = {\n variables: gdjs.dialogueTree.runner.variables.data,\n visited: gdjs.dialogueTree.runner.visited,\n };\n outputVariable.fromJSObject(dialogueState);\n };\n\n /**\n * Load the current State of the Dialogue Parser from a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param inputVariable The structured variable where to load the State from.\n */\n gdjs.dialogueTree.loadState = function (inputVariable: gdjs.Variable) {\n const loadedState = inputVariable.toJSObject();\n if (!loadedState) {\n logger.error('Load state variable is empty:', inputVariable);\n return;\n }\n try {\n gdjs.dialogueTree.runner.visited = loadedState.visited;\n gdjs.dialogueTree.runner.variables.data = {};\n Object.keys(loadedState.variables).forEach(function (key) {\n const value = loadedState.variables[key];\n gdjs.dialogueTree.runner.variables.set(key, value);\n });\n } catch (e) {\n logger.error('Failed to load state from variable:', inputVariable, e);\n }\n };\n\n /**\n * Clear the current State of the Dialogue Parser.\n */\n gdjs.dialogueTree.clearState = function () {\n gdjs.dialogueTree.runner.visited = {};\n gdjs.dialogueTree.runner.variables.data = {};\n };\n}\n"],
5
- "mappings": "AAEA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAE/B,EAAK,aAAe,GACpB,EAAK,aAAa,OAAS,GAAI,SAAQ,OAOvC,EAAK,aAAa,sBAAwB,SACxC,EACA,EACA,CACA,KAAK,OAAS,EAAK,aAAa,OAChC,GAAI,CACF,KAAK,SAAW,KAAK,MAAM,EAAS,eACpC,KAAK,OAAO,KAAK,KAAK,UAClB,GAAqB,EAAkB,OAAS,GAClD,EAAK,aAAa,UAAU,SAEvB,EAAP,CACA,EAAO,MAAM,4CAA6C,KAW9D,EAAK,aAAa,iBAAmB,SACnC,EACA,EACA,EACA,CACA,EACG,UACA,iBACA,SAAS,EAAkB,SAAU,EAAO,EAAS,CACpD,GAAI,EACF,EAAO,MAAM,iDAAkD,OAC1D,CACL,GAAI,CAAC,EACH,OAEF,EAAK,aAAa,SAAW,EAC7B,GAAI,CACF,EAAK,aAAa,OAAO,K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Y,UAAU,GACpC,EAAK,aAAa,OAAO,UAAU,IAAI,EAAK,WAEvC,EAAP,CACA,EAAO,MAAM,sCAAuC,EAAe,KAOvE,EAAK,aAAa,WAAa,UAAY,CACzC,EAAK,aAAa,OAAO,QAAU,GACnC,EAAK,aAAa,OAAO,UAAU,KAAO,MAhzBpC",
4
+ "sourcesContent": ["// @ts-nocheck - Weird usage of `this` in this file. Should be refactored.\n\nnamespace gdjs {\n const logger = new gdjs.Logger('Dialogue tree');\n\n gdjs.dialogueTree = {};\n gdjs.dialogueTree.runner = new bondage.Runner();\n\n /**\n * Load the Dialogue Tree data of the game. Initialize The Dialogue Tree, so as it can be used in the game.\n * @param sceneVar The variable to load the Dialogue tree data from. The data is a JSON string, created by Yarn.\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n gdjs.dialogueTree.loadFromSceneVariable = function (\n sceneVar: gdjs.Variable,\n startDialogueNode: string\n ) {\n this.runner = gdjs.dialogueTree.runner;\n try {\n this.yarnData = JSON.parse(sceneVar.getAsString());\n this.runner.load(this.yarnData);\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n } catch (e) {\n logger.error('Error while loading from scene variable: ', e);\n }\n };\n\n /**\n * Load the Dialogue Tree data from a JSON resource.\n *\n * @param instanceContainer The scene where the dialogue is running.\n * @param jsonResourceName The JSON resource where to load the Dialogue Tree data from. The data is a JSON string usually created with [Yarn Dialogue Editor](https://github.com/InfiniteAmmoInc/Yarn).\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n gdjs.dialogueTree.loadFromJsonFile = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n jsonResourceName: string,\n startDialogueNode: string\n ) {\n instanceContainer\n .getGame()\n .getJsonManager()\n .loadJson(jsonResourceName, function (error, content) {\n if (error) {\n logger.error('An error happened while loading JSON resource:', error);\n } else {\n if (!content) {\n return;\n }\n gdjs.dialogueTree.yarnData = content;\n try {\n gdjs.dialogueTree.runner.load(gdjs.dialogueTree.yarnData);\n } catch (error) {\n logger.error(\n 'An error happened while loading parsing the dialogue tree data:',\n error\n );\n }\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n }\n });\n };\n\n /**\n * Stop the currently running dialogue\n */\n gdjs.dialogueTree.stopRunningDialogue = function () {\n if (this.dialogueIsRunning) {\n this.dialogueIsRunning = false;\n }\n if (this.dialogueData) {\n this.dialogueData = null;\n }\n this.dialogueText = '';\n this.clipTextEnd = 0;\n };\n\n /**\n * Check if the Dialogue Tree is currently parsing data.\n * For example, you can do things like disabling player movement while talking to a NPC.\n */\n gdjs.dialogueTree.isRunning = function () {\n if (\n this.dialogueIsRunning &&\n !this.dialogueData &&\n this.dialogueText &&\n this.clipTextEnd >= this.dialogueText.length\n ) {\n this.dialogueIsRunning = false;\n }\n return this.dialogueIsRunning;\n };\n\n /**\n * Scroll the clipped text. This can be combined with a timer and user input to control how fast the dialogue line text is scrolling.\n */\n gdjs.dialogueTree.scrollClippedText = function () {\n if (this.pauseScrolling || !this.dialogueIsRunning) {\n return;\n }\n\n // Autoscroll commands so the user doesn't have to press again.\n if (\n gdjs.dialogueTree._isLineTypeCommand() &&\n this.dialogueDataType === 'text' &&\n this.dialogueBranchTitle === this.dialogueData.data.title &&\n this.lineNum === this.dialogueData.lineNum &&\n gdjs.dialogueTree.hasClippedScrollingCompleted()\n ) {\n gdjs.dialogueTree.goToNextDialogueLine();\n return;\n }\n\n // Increment scrolling of clipped text\n if (\n this.dialogueText &&\n this.dialogueDataType === 'text' &&\n this.clipTextEnd < this.dialogueText.length\n ) {\n this.clipTextEnd += 1;\n }\n };\n\n /**\n * Scroll the clipped text to its end, so the entire text is printed. This can be useful in keeping the event sheet logic simpler, while supporting more variation.\n */\n gdjs.dialogueTree.completeClippedTextScrolling = function () {\n if (\n this.pauseScrolling ||\n !this.dialogueIsRunning ||\n !this.dialogueText ||\n this.dialogueDataType !== 'text'\n ) {\n return;\n }\n this.clipTextEnd = this.dialogueText.length;\n };\n\n /**\n * Check if text scrolling has completed.\n * Useful to prevent the user from skipping to next line before the current one has been printed fully.\n */\n gdjs.dialogueTree.hasClippedScrollingCompleted = function () {\n if (!this.dialogueIsRunning || this.dialogueDataType === '') {\n return false;\n }\n if (\n this.dialogueData &&\n this.dialogueText.length > 0 &&\n this.clipTextEnd >= this.dialogueText.length\n ) {\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.warn(\n 'Scroll completed:',\n this.clipTextEnd,\n '/',\n this.dialogueText.length\n );\n }\n return true;\n }\n return false;\n };\n\n /**\n * Get the current dialogue line with a scrolling effect (recommended).\n * Used with the scrollClippedText to achieve a classic scrolling text, as well as any <<wait>> effects to pause scrolling.\n */\n gdjs.dialogueTree.getClippedLineText = function () {\n return this.dialogueIsRunning && this.dialogueText.length\n ? this.dialogueText.substring(0, this.clipTextEnd + 1)\n : '';\n };\n\n /**\n * Get the current complete dialogue line without using any scrolling effects.\n * Note that using this instead getClippedLineText will skip any <<wait>> commands entirely.\n */\n gdjs.dialogueTree.getLineText = function () {\n return this.dialogueIsRunning && this.dialogueText.length\n ? this.dialogueText\n : '';\n };\n\n /**\n * Get the number of command parameters in a command with parameters that has been caught by a isCommandCalled condition\n */\n gdjs.dialogueTree.commandParametersCount = function () {\n if (this.commandParameters && this.commandParameters.length > 1) {\n return this.commandParameters.length - 1;\n }\n return 0;\n };\n\n /**\n * Get a command parameter in any command with parameters that has been caught by a isCommandCalled condition\n * @param paramIndex The index of the parameter to get.\n */\n gdjs.dialogueTree.getCommandParameter = function (paramIndex: float) {\n if (paramIndex === -1 && this.commandParameters.length > 0) {\n return this.commandParameters[0];\n }\n if (\n this.commandParameters &&\n this.commandParameters.length >= paramIndex + 1\n ) {\n const returnedParam = this.commandParameters[paramIndex + 1];\n return returnedParam ? returnedParam : '';\n }\n return '';\n };\n\n /**\n * Catch <<commands>> and <<commands with parameters>> from the current Dialogue Line.\n * You can trigger custom logic that relate to the story you are telling during the dialogue.\n *\n * @param command The command you want to check for being called. Write it without the `<<>>`.\n */\n gdjs.dialogueTree.isCommandCalled = function (command: string) {\n if (!this.dialogueIsRunning) {\n return false;\n }\n const commandCalls = gdjs.dialogueTree.commandCalls;\n const clipTextEnd = gdjs.dialogueTree.clipTextEnd;\n const dialogueText = gdjs.dialogueTree.dialogueText;\n if (this.pauseScrolling || !commandCalls) {\n return false;\n }\n return this.commandCalls.some(function (call, index) {\n if (clipTextEnd !== 0 && clipTextEnd < call.time) {\n return false;\n }\n if (\n call.cmd === 'wait' &&\n (clipTextEnd === 0 || clipTextEnd !== dialogueText.length)\n ) {\n gdjs.dialogueTree.pauseScrolling = true;\n setTimeout(function () {\n gdjs.dialogueTree.pauseScrolling = false;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n }, parseInt(call.params[1], 10));\n }\n if (call.cmd === command) {\n gdjs.dialogueTree.commandParameters = call.params;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n return true;\n }\n });\n };\n\n /**\n * Internal method to allow for capping option selection.\n */\n gdjs.dialogueTree._normalizedOptionIndex = function (optionIndex) {\n if (optionIndex >= this.options.length) {\n optionIndex = this.options.length - 1;\n }\n if (optionIndex < 0) {\n optionIndex = 0;\n }\n return optionIndex;\n };\n\n /**\n * Internal method to allow for cycling option selection.\n */\n gdjs.dialogueTree._cycledOptionIndex = function (optionIndex) {\n if (optionIndex >= this.options.length) {\n optionIndex = 0;\n }\n if (optionIndex < 0) {\n optionIndex = this.options.length - 1;\n }\n return optionIndex;\n };\n\n /**\n * Get the text of an option the player can select.\n * Used with getLineOptionsCount to render options for the player when a line of the Options type is parsed\n * @param optionIndex The index of the option you want to get\n */\n gdjs.dialogueTree.getLineOption = function (optionIndex: float) {\n if (!this.dialogueIsRunning || !this.options.length) {\n return [];\n }\n optionIndex = gdjs.dialogueTree._normalizedOptionIndex(optionIndex);\n return this.options[optionIndex];\n };\n\n /**\n * Get the text of the options the player can select, along with the selection cursor.\n * @param optionSelectionCursor The string used to draw the currently selected option's cursor\n * @param addNewLine when true each option is rendered on a new line.\n */\n gdjs.dialogueTree.getLineOptionsText = function (\n optionSelectionCursor: string,\n addNewLine: boolean\n ) {\n if (!this.dialogueIsRunning || !this.options.length) {\n return '';\n }\n let textResult = '';\n this.options.forEach(function (optionText, index) {\n if (index === gdjs.dialogueTree.selectedOption) {\n textResult += optionSelectionCursor;\n } else {\n textResult += optionSelectionCursor.replace(/.*/g, ' ');\n }\n textResult += optionText;\n if (addNewLine) {\n textResult += '\\n';\n }\n });\n return textResult;\n };\n gdjs.dialogueTree.getLineOptionsTextHorizontal = function (\n optionSelectionCursor\n ) {\n return this.getLineOptionsText(optionSelectionCursor, false);\n };\n gdjs.dialogueTree.getLineOptionsTextVertical = function (\n optionSelectionCursor\n ) {\n return this.getLineOptionsText(optionSelectionCursor, true);\n };\n\n /**\n * Get the number of options that are presented to the player, during the parsing of an Options type line.\n * @returns The number of options\n */\n gdjs.dialogueTree.getLineOptionsCount = function (): number {\n if (this.dialogueIsRunning && this.options.length) {\n return this.optionsCount;\n }\n return 0;\n };\n\n /**\n * Confirm the currently selected option, during the parsing of an Options type line.\n *\n * This will advance the dialogue tree to the dialogue branch was selected by the player.\n */\n gdjs.dialogueTree.confirmSelectOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (\n this.dialogueData.select &&\n !this.selectedOptionUpdated &&\n this.selectedOption !== -1\n ) {\n this.commandCalls = [];\n try {\n this.dialogueData.select(this.selectedOption);\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while confirming in the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n gdjs.dialogueTree.goToNextDialogueLine();\n } catch (error) {\n logger.error(\n `An error happened when trying to access the dialogue branch!`,\n error\n );\n }\n }\n };\n\n /**\n * Select next option during Options type line parsing. Hook this to your game input.\n */\n gdjs.dialogueTree.selectNextOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption += 1;\n this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(\n this.selectedOption\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Select previous option during Options type line parsing. Hook this to your game input.\n */\n gdjs.dialogueTree.selectPreviousOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption -= 1;\n this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(\n this.selectedOption\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Select option by index during Options type line parsing.\n * @param optionIndex The index of the option to select\n */\n gdjs.dialogueTree.selectOption = function (optionIndex: float) {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption = gdjs.dialogueTree._normalizedOptionIndex(\n optionIndex\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Get the currently selected option\n * @returns The index of the currently selected option\n */\n gdjs.dialogueTree.getSelectedOption = function (): number {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n return this.selectedOption;\n }\n return 0;\n };\n\n /**\n * Check when the player has changed option selection since the last call to this function.\n *\n * Can be used to re-render your displayed dialogue options when needed.\n *\n * @returns true if the selected option was updated since the last call to this function\n */\n gdjs.dialogueTree.hasSelectedOptionChanged = function (): boolean {\n if (this.selectedOptionUpdated) {\n this.selectedOptionUpdated = false;\n if (this.selectedOption === -1) {\n this.selectedOption = 0;\n }\n return true;\n }\n return false;\n };\n\n /**\n * Check the type of the Dialogue Line that is being displayed to the player at the moment.\n *\n * There are three types:\n * - text - regular dialogue text is being parsed at the moment\n * - options - the player has reached a branching choice moment where they must select one of multiple options\n * - command - a <<command>> was called in the background, that can be used to trigger game events, but will not be displayed in the dialogue box.\n *\n * @param type The type you want to check for ( one of the three above )\n */\n gdjs.dialogueTree.isDialogueLineType = function (type: string) {\n if (!this.dialogueIsRunning) {\n return false;\n }\n if (this.commandCalls && type === 'command') {\n if (\n this.commandCalls.some(function (call) {\n return (\n gdjs.dialogueTree.clipTextEnd > call.time && call.cmd === 'wait'\n );\n })\n ) {\n return !this.pauseScrolling;\n }\n if (this.commandCalls.length > 0 && this.commandParameters.length > 0) {\n return true;\n }\n }\n return this.dialogueDataType === type;\n };\n\n /**\n * Check if a branch exists. It is also used internally whenever you use the start from action.\n * @param branchName The Dialogue Branch name you want to check.\n */\n gdjs.dialogueTree.hasDialogueBranch = function (branchName: string) {\n return (\n this.runner &&\n this.runner.yarnNodes &&\n Object.keys(this.runner.yarnNodes).some(function (node) {\n return node === branchName;\n })\n );\n };\n\n /**\n * Start parsing dialogue from a specified Dialogue tree branch.\n * Can be used if you want to store multiple dialogues inside a single Dialogue tree data set.\n * @param startDialogueNode The Dialogue Branch name you want to start parsing from.\n */\n gdjs.dialogueTree.startFrom = function (startDialogueNode: string) {\n this.runner = gdjs.dialogueTree.runner;\n if (!this.hasDialogueBranch(startDialogueNode)) {\n return;\n }\n this.optionsCount = 0;\n this.options = [];\n this.tagParameters = [];\n try {\n this.dialogue = this.runner.run(startDialogueNode);\n } catch (error) {\n logger.error(\n 'Error while setting up the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n this.dialogueText = '';\n this.clipTextEnd = 0;\n this.commandCalls = [];\n this.commandParameters = [];\n this.pauseScrolling = false;\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while starting the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n this.dialogueBranchTags = this.dialogueData.data.tags;\n this.dialogueBranchTitle = this.dialogueData.data.title;\n this.dialogueBranchBody = this.dialogueData.data.body;\n this.lineNum = this.dialogueData.lineNum;\n if (gdjs.dialogueTree._isLineTypeText()) {\n this.dialogueDataType = 'text';\n } else {\n if (gdjs.dialogueTree._isLineTypeOptions()) {\n this.dialogueDataType = 'options';\n } else {\n this.dialogueDataType = 'command';\n }\n }\n this.dialogueIsRunning = true;\n gdjs.dialogueTree.goToNextDialogueLine();\n };\n\n /**\n * Internal methods to check the type of a Dialogue Line\n */\n gdjs.dialogueTree._isLineTypeText = function () {\n return this.dialogueData instanceof bondage.TextResult;\n };\n gdjs.dialogueTree._isLineTypeOptions = function () {\n return this.dialogueData instanceof bondage.OptionsResult;\n };\n gdjs.dialogueTree._isLineTypeCommand = function () {\n return this.dialogueData instanceof bondage.CommandResult;\n };\n\n /**\n * This is the main lifecycle function.It runs once only when the user is advancing the dialogue to the next line.\n * Progress Dialogue to the next line. Hook it to your game input.\n * Note that this action can be influenced by any <<wait>> commands, but they work only if you have at least one isCommandCalled condition.\n */\n gdjs.dialogueTree.goToNextDialogueLine = function () {\n if (this.pauseScrolling || !this.dialogueIsRunning) {\n return;\n }\n this.optionsCount = 0;\n this.selectedOption = -1;\n this.selectedOptionUpdated = false;\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('Parsing:', this.dialogueData);\n }\n if (!this.dialogueData) {\n gdjs.dialogueTree.stopRunningDialogue();\n } else {\n if (gdjs.dialogueTree._isLineTypeText()) {\n if (\n this.lineNum === this.dialogueData.lineNum &&\n this.dialogueBranchTitle === this.dialogueData.data.title\n ) {\n this.clipTextEnd = this.dialogueText.length - 1;\n this.dialogueText +=\n (this.dialogueText === '' ? '' : ' ') + this.dialogueData.text;\n } else {\n this.clipTextEnd = 0;\n this.dialogueText = this.dialogueData.text;\n }\n this.dialogueBranchTags = this.dialogueData.data.tags;\n this.dialogueBranchTitle = this.dialogueData.data.title;\n this.dialogueBranchBody = this.dialogueData.data.body;\n this.lineNum = this.dialogueData.lineNum;\n this.dialogueDataType = 'text';\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n } else {\n if (gdjs.dialogueTree._isLineTypeOptions()) {\n this.commandCalls = [];\n this.dialogueDataType = 'options';\n this.dialogueText = '';\n this.clipTextEnd = 0;\n this.optionsCount = this.dialogueData.options.length;\n this.options = this.dialogueData.options;\n this.selectedOptionUpdated = true;\n } else {\n if (gdjs.dialogueTree._isLineTypeCommand()) {\n this.dialogueDataType = 'command';\n const command = this.dialogueData.text.split(' ');\n\n // If last command was to wait, increase time by one\n const offsetTime =\n this.commandCalls.length &&\n this.commandCalls[this.commandCalls.length - 1].cmd === 'wait'\n ? 1\n : 0;\n this.commandCalls.push({\n cmd: command[0],\n params: command,\n time: this.dialogueText.length + offsetTime,\n });\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n gdjs.dialogueTree.goToNextDialogueLine();\n } else {\n this.dialogueDataType = 'unknown';\n }\n }\n }\n }\n };\n\n /**\n * Get the current Dialogue Tree branch title.\n * @returns The current branch title.\n */\n gdjs.dialogueTree.getBranchTitle = function (): string {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTitle;\n }\n return '';\n };\n\n /**\n * Check if the currently parsed Dialogue branch title is a query.\n * @param title The Dialogue Branch name you want to check for.\n */\n gdjs.dialogueTree.branchTitleIs = function (title: string) {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTitle === title;\n }\n return false;\n };\n\n /**\n * Get all the branch tags from the current Dialogue branch as a string. Useful for debugging.\n * @returns The current branch tags, separated by a comma.\n */\n gdjs.dialogueTree.getBranchTags = function (): string {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTags.join(',');\n }\n return '';\n };\n\n /**\n * Get one of the current Dialogue branch tags via index.\n * @param index The index of the Dialogue Branch tag you want to get.\n * @returns The branch tag at the specified index, or an empty string if not found.\n */\n gdjs.dialogueTree.getBranchTag = function (index: float): string {\n if (this.dialogueIsRunning && this.dialogueBranchTags.length) {\n if (index > this.dialogueBranchTags.length - 1) {\n index = this.dialogueBranchTags.length - 1;\n }\n return this.dialogueBranchTags[index];\n }\n return '';\n };\n\n /**\n * Check if the current Dialogue branch contains a specific tag.\n * @param query The name of the Dialogue Branch tag you want to check.\n */\n gdjs.dialogueTree.branchContainsTag = function (query: string) {\n this.tagParameters = [];\n if (this.dialogueIsRunning && this.dialogueBranchTags.length) {\n return this.dialogueBranchTags.some(function (tag) {\n const splitTag = tag.match(/([^\\(]+)\\(([^\\)]+)\\)/i);\n gdjs.dialogueTree.tagParameters = splitTag\n ? splitTag[2].split(',')\n : [];\n return splitTag ? splitTag[1] === query : tag === query;\n });\n }\n return false;\n };\n\n /**\n * Get any tag(parameter,anotherParameter) from a tag captured by the branchContainsTag Condition\n * @param paramIndex The index of the tag parameter you want to get.\n * Leaving this empty will result in retrieving the first parameter.\n */\n gdjs.dialogueTree.getTagParameter = function (paramIndex: float) {\n if (this.dialogueIsRunning && this.tagParameters.length >= paramIndex) {\n const returnedParam = this.tagParameters[paramIndex];\n return returnedParam ? returnedParam : '';\n }\n return '';\n };\n\n /**\n * Get a list of all the titles of visited by the player Branches. Useful for debugging.\n */\n gdjs.dialogueTree.getVisitedBranchTitles = function () {\n if (this.dialogueIsRunning) {\n return Object.keys(this.runner.visited).join(',');\n }\n return '';\n };\n\n /**\n * Check if a player has visited a Dialogue Branch in the past.\n * @param title The title of the branch to check for.\n * Leaving this empty will check if the current branch title has been visited in the past.\n */\n gdjs.dialogueTree.branchTitleHasBeenVisited = function (title: string) {\n if (!title) {\n title = this.dialogueBranchTitle;\n }\n return (\n Object.keys(this.runner.visited).includes(title) &&\n this.runner.visited[title]\n );\n };\n\n /**\n * Get the entire unparsed text of the current Dialogue Branch\n */\n gdjs.dialogueTree.getBranchText = function () {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchBody;\n }\n return '';\n };\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n gdjs.dialogueTree.getVariable = function (\n key: string\n ): string | float | boolean {\n if (this.runner.variables && key in this.runner.variables.data) {\n return this.runner.variables.get(key);\n }\n return '';\n };\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n gdjs.dialogueTree.getVariableAsNumber = function (key: string): float {\n if (this.runner.variables && key in this.runner.variables.data) {\n const value = this.runner.variables.get(key);\n if (typeof value !== 'number') {\n return parseFloat(value) || 0;\n }\n\n return isFinite(value) ? value : 0;\n }\n return 0;\n };\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n gdjs.dialogueTree.getVariableAsString = function (key: string): string {\n if (this.runner.variables && key in this.runner.variables.data) {\n return '' + this.runner.variables.get(key);\n }\n return '';\n };\n\n /**\n * Check if a specific variable created by the Dialogue parses exists and is equal to a specific value.\n * @param key The name of the variable you want to check the value of\n * @param value The value you want to check against\n */\n gdjs.dialogueTree.compareVariable = function (\n key: string,\n value: string | boolean | number\n ) {\n if (this.runner.variables && key in this.runner.variables.data) {\n return this.runner.variables.get(key) === value;\n }\n return false;\n };\n\n /**\n * Set a specific variable created by the Dialogue parser to a specific value.\n * @param key The name of the variable you want to set the value of\n * @param value The value you want to set\n */\n gdjs.dialogueTree.setVariable = function (\n key: string,\n value: string | boolean | number\n ) {\n if (this.runner.variables) {\n this.runner.variables.set(key, value);\n }\n };\n\n /**\n * Store the current State of the Dialogue Parser in a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param outputVariable The variable where to store the State\n */\n gdjs.dialogueTree.saveState = function (outputVariable: gdjs.Variable) {\n const dialogueState = {\n variables: gdjs.dialogueTree.runner.variables.data,\n visited: gdjs.dialogueTree.runner.visited,\n };\n outputVariable.fromJSObject(dialogueState);\n };\n\n /**\n * Load the current State of the Dialogue Parser from a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param inputVariable The structured variable where to load the State from.\n */\n gdjs.dialogueTree.loadState = function (inputVariable: gdjs.Variable) {\n const loadedState = inputVariable.toJSObject();\n if (!loadedState) {\n logger.error('Load state variable is empty:', inputVariable);\n return;\n }\n try {\n gdjs.dialogueTree.runner.visited = loadedState.visited;\n gdjs.dialogueTree.runner.variables.data = {};\n Object.keys(loadedState.variables).forEach(function (key) {\n const value = loadedState.variables[key];\n gdjs.dialogueTree.runner.variables.set(key, value);\n });\n } catch (e) {\n logger.error('Failed to load state from variable:', inputVariable, e);\n }\n };\n\n /**\n * Clear the current State of the Dialogue Parser.\n */\n gdjs.dialogueTree.clearState = function () {\n gdjs.dialogueTree.runner.visited = {};\n gdjs.dialogueTree.runner.variables.data = {};\n };\n}\n"],
5
+ "mappings": "AAEA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAE/B,EAAK,aAAe,GACpB,EAAK,aAAa,OAAS,GAAI,SAAQ,OAOvC,EAAK,aAAa,sBAAwB,SACxC,EACA,EACA,CACA,KAAK,OAAS,EAAK,aAAa,OAChC,GAAI,CACF,KAAK,SAAW,KAAK,MAAM,EAAS,eACpC,KAAK,OAAO,KAAK,KAAK,UAClB,GAAqB,EAAkB,OAAS,GAClD,EAAK,aAAa,UAAU,SAEvB,EAAP,CACA,EAAO,MAAM,4CAA6C,KAW9D,EAAK,aAAa,iBAAmB,SACnC,EACA,EACA,EACA,CACA,EACG,UACA,iBACA,SAAS,EAAkB,SAAU,EAAO,EAAS,CACpD,GAAI,EACF,EAAO,MAAM,iDAAkD,OAC1D,CACL,GAAI,CAAC,EACH,OAEF,EAAK,aAAa,SAAW,EAC7B,GAAI,CACF,EAAK,aAAa,OAAO,KAAK,EAAK,aAAa,gBACzC,EAAP,CACA,EAAO,MACL,kEACA,GAGJ,AAAI,GAAqB,EAAkB,OAAS,GAClD,EAAK,aAAa,UAAU,OAStC,EAAK,aAAa,oBAAsB,UAAY,CAClD,AAAI,KAAK,mBACP,MAAK,k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d,KAAK,OAAO,UAAU,IAAI,EAAK,IAUnC,EAAK,aAAa,UAAY,SAAU,EAA+B,CACrE,KAAM,GAAgB,CACpB,UAAW,EAAK,aAAa,OAAO,UAAU,KAC9C,QAAS,EAAK,aAAa,OAAO,SAEpC,EAAe,aAAa,IAS9B,EAAK,aAAa,UAAY,SAAU,EAA8B,CACpE,KAAM,GAAc,EAAc,aAClC,GAAI,CAAC,EAAa,CAChB,EAAO,MAAM,gCAAiC,GAC9C,OAEF,GAAI,CACF,EAAK,aAAa,OAAO,QAAU,EAAY,QAC/C,EAAK,aAAa,OAAO,UAAU,KAAO,GAC1C,OAAO,KAAK,EAAY,WAAW,QAAQ,SAAU,EAAK,CACxD,KAAM,GAAQ,EAAY,UAAU,GACpC,EAAK,aAAa,OAAO,UAAU,IAAI,EAAK,WAEvC,EAAP,CACA,EAAO,MAAM,sCAAuC,EAAe,KAOvE,EAAK,aAAa,WAAa,UAAY,CACzC,EAAK,aAAa,OAAO,QAAU,GACnC,EAAK,aAAa,OAAO,UAAU,KAAO,MAr3BpC",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- This is the firebase js sdk, downloadable from https://firebase.google.com/docs/web/setup/#expandable-8.
2
- The file and sourcemaps names have been modified to be loaded properly by GDevelop.
3
- The source can be found on https://github.com/firebase/firebase-js-sdk.
4
- Type definitions can be found at https://www.unpkg.com/firebase/index.d.ts.
5
- They have been modified to remove the exports at the bottom in order to work with GDevelop.
6
- The version of the Firebase SDK used is 8.3.3.
1
+ This is the firebase js sdk, downloadable from https://firebase.google.com/docs/web/setup/#expandable-8.
2
+ The file and sourcemaps names have been modified to be loaded properly by GDevelop.
3
+ The source can be found on https://github.com/firebase/firebase-js-sdk.
4
+ Type definitions can be found at https://www.unpkg.com/firebase/index.d.ts.
5
+ They have been modified to remove the exports at the bottom in order to work with GDevelop.
6
+ The version of the Firebase SDK used is 8.3.3.
@@ -1,2 +1,2 @@
1
- var gdjs;(function(s){const k=new s.Logger("Multiplayer"),g=new s.Logger("Multiplayer - Debug");s.Logger.getDefaultConsoleLoggerOutput().discardGroup("Multiplayer - Debug");class je{constructor(S){this.clear=()=>{this.cache.clear(),this.keys=[]};this.maxSize=S,this.cache=new Set,this.keys=[]}has(S){return this.cache.has(S)}add(S){if(this.cache.size>=this.maxSize){const D=this.keys.shift();D&&this.cache.delete(D)}this.cache.add(S),this.keys.push(S)}}class ue{constructor(){this._updates=[]}store(S){this._updates.push(S),this._updates.length>10&&this._updates.shift()}getUpdates(){return this._updates}remove(S){const D=this._updates.indexOf(S);D!==-1&&this._updates.splice(D,1)}clear(){this._updates=[]}}const Te=({target:C,source:S})=>{for(const D in S)S.hasOwnProperty(D)&&!C.hasOwnProperty(D)&&(C[D]=S[D]);for(const D in C)C.hasOwnProperty(D)&&!S.hasOwnProperty(D)&&delete C[D]};s.makeMultiplayerMessageManager=()=>{const C=0,S=0,D=0,Je=0,v=window.performance&&typeof window.performance.now=="function"?window.performance.now.bind(window.performance):Date.now,_e=200,Le=4,W=new je(500);let O={},H={};const xe=1;let me=0,Q=null,V=0,F=new ue;const Ge=1;let de=0,J=null,B=0,K=new ue;const Ee=1;let E=0,U={},pe={},M={},A=[],$=[],Y={};const x=({originalMessageName:e,originalData:t,expectedMessageName:n,otherPeerIds:r,shouldCancelMessageIfTimesOut:a,maxNumberOfRetries:o,messageRetryTime:l})=>{!s.multiplayer.isLobbyGameRunning()||(O[n]||(O[n]={}),g.info(`Adding expected message ${n} from ${r.join(", ")}.`),r.forEach(c=>{O[n][c]={acknowledged:!1,lastMessageSentAt:v(),originalMessageName:e,originalData:t,shouldCancelMessageIfTimesOut:a,numberOfRetries:0,maxNumberOfRetries:o||Le,messageRetryTime:l||_e}}))},fe=({sceneNetworkId:e,instanceNetworkId:t})=>(H[e]||(H[e]={}),H[e][t]||0),ye=({sceneNetworkId:e,instanceNetworkId:t,clock:n})=>{H[e]||(H[e]={}),H[e][t]=n},w=(e,t,n)=>{if(!(S>0&&Math.random()<S)){if(D>0&&Math.random()<D){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},Je);return}if(C>0){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},C);return}s.multiplayerPeerJsHelper.sendDataTo(e,t,n)}},Ue=(e,t,n)=>{if(!e.length)return null;let r=null,a=1/0;for(let o=0;o<e.length;++o){if(e[o].networkId)continue;const l=e[o],c=Math.pow(l.getX()-t,2)+Math.pow(l.getY()-n,2);c<a&&(r=l,a=c)}return r},Z=({runtimeScene:e,objectName:t,instanceNetworkId:n,instanceX:r,instanceY:a,shouldCreateIfNotFound:o})=>{const l=e.getInstancesOf(t);if(!l)return null;let c=l.find(i=>i.networkId===n)||null;if(!c&&r!==void 0&&a!==void 0){g.info(`instance ${t} ${n} not found with network ID, trying to find it with position ${r}/${a}.`);const i=Ue(l,r,a);i&&(g.info(`Found closest instance for object ${t} ${n} with no network ID.`),c=i,c.networkId=n)}if(!c&&o){g.info(`Instance ${n} still not found, Creating instance ${t}.`);const i=e.createObject(t);if(!i)return null;i.networkId=n,c=i}return c},q="#changeInstanceOwner",he=/#changeInstanceOwner#owner_(\d+)#object_(.+)#instance_(.+)/,We=({objectOwner:e,objectName:t,instanceNetworkId:n,newObjectOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l})=>({messageName:`${q}#owner_${e}#object_${t}#instance_${n}`,messageData:{previousOwner:e,newOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l}}),ee="#instanceOwnerChanged",Ve=/#instanceOwnerChanged#owner_(\d+)#object_(.+)#instance_(.+)/,be=e=>e.replace(q,ee),Fe=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(q)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),m=c.getSender(),p=he.exec(a);if(!p)return;const f=p[2],u=p[3],d=i.previousOwner,y=i.newOwner,I=i.sceneNetworkId;if(I!==e.networkId){g.info(`Object ${f} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=Z({runtimeScene:e,objectName:f,instanceNetworkId:u,instanceX:i.instanceX,instanceY:i.instanceY});if(!P){g.info(`Instance ${u} not found, it must have been destroyed.`);return}const h=P.getBehavior("MultiplayerObject");if(!h){g.info(`Object ${f} does not have the MultiplayerObjectBehavior, cannot change ownership.`);return}const b=h.getPlayerObjectOwnership(),N=b===d||b===y;if(s.multiplayer.isCurrentPlayerHost()&&!N){g.info(`Object ${f} with instance network ID ${u} does not have the expected owner. Wanted to change from ${d} to ${y}, but object has owner ${b}.`);return}g.info(`Changing ownership of object ${f} to ${y}.`),h.playerNumber=y;const _=be(a);if(g.info(`Sending acknowledgment of ownership change of object ${f} from ${d} to ${y} with instance network ID ${u} to ${m}.`),w([m],_,{}),s.multiplayer.isCurrentPlayerHost()){const j=s.multiplayerPeerJsHelper.getAllPeers().filter(R=>R!==m);if(!j.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:_,otherPeerIds:j,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of object ${f} with instance network ID ${u} to ${j.join(", ")}.`),w(j,a,i)}})})},Me="#updateInstance",Be=/#updateInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,Ke=({objectOwner:e,objectName:t,instanceNetworkId:n,objectNetworkSyncData:r,sceneNetworkId:a})=>({messageName:`${Me}#owner_${e}#object_${t}#instance_${n}#scene_${a}`,messageData:r}),Ye=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Me)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();if(!l.length)return;l.slice().reverse().forEach(i=>{const m=i.getData(),p=i.getSender(),f=Be.exec(a);if(!f)return;const u=parseInt(f[1],10);if(u===s.multiplayer.playerNumber)return;const d=f[2],y=f[3],I=f[4];if(I!==e.networkId){g.info(`Object ${d} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=m._clock,h=fe({sceneNetworkId:I,instanceNetworkId:y});if(P<=h)return;const b=Z({runtimeScene:e,objectName:d,instanceNetworkId:y,shouldCreateIfNotFound:!0,instanceX:m.x,instanceY:m.y});if(!b){k.error("Instance could not be found or created.");return}const N=b.getBehavior("MultiplayerObject");if(!N){k.error(`Object ${d} does not have the MultiplayerObjectBehavior, cannot update it.`);return}if(N.getPlayerObjectOwnership()===s.multiplayer.playerNumber){g.info(`Object ${d} with instance network ID ${y} is owned by us ${s.multiplayer.playerNumber}, ignoring update message from ${u}.`);return}if(N.getPlayerObjectOwnership()!==u&&(g.info(`Object ${d} with instance network ID ${y} is owned by ${N.getPlayerObjectOwnership()} on our game, changing ownership to ${u} as part of the update event.`),N.playerNumber=u),b.updateFromNetworkSyncData(m),ye({sceneNetworkId:I,instanceNetworkId:y,clock:P}),N._clock=P,s.multiplayer.isCurrentPlayerHost()){const T=s.multiplayerPeerJsHelper.getAllPeers().filter(j=>j!==p);if(!T.length)return;w(T,a,m)}})})},X="#changeVariableOwner",we=/#changeVariableOwner#owner_(\d+)#variable_(.+)/,qe=({variableOwner:e,variableNetworkId:t,newVariableOwner:n})=>({messageName:`${X}#owner_${e}#variable_${t}`,messageData:{previousOwner:e,newOwner:n}}),te="#variableOwnerChanged",Xe=/#variableOwnerChanged#owner_(\d+)#variable_(.+)/,Ie=e=>e.replace(X,te),ze=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(X)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),m=c.getSender(),p=we.exec(a);if(!p)return;const f=p[2],u=i.previousOwner,d=i.newOwner,{type:y,name:I,containerId:P}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(f);if(y==="scene"&&P!==e.networkId){g.info(`Variable ${I} is in scene ${P}, but we are on ${e.networkId}. Skipping.`);return}const h=P==="game"?e.getGame().getVariables():e.getVariables();if(!h.has(I)){k.error(`Variable with ID ${f} not found whilst syncing. This should not happen.`);return}const b=h.get(I),N=b.getPlayerOwnership(),_=N===u||N===d;if(s.multiplayer.isCurrentPlayerHost()&&!_){g.info(`Variable with ID ${f} does not have the expected owner. Wanted to change from ${u} to ${d}, but variable has owner ${N}.`);return}g.info(`Changing ownership of variable ${I} to ${d}.`),b.setPlayerOwnership(d);const T=Ie(a);if(g.info(`Sending acknowledgment of ownership change of variable with ID ${f} from ${u} to ${d} to ${m}.`),w([m],T,{}),s.multiplayer.isCurrentPlayerHost()){const R=s.multiplayerPeerJsHelper.getAllPeers().filter(G=>G!==m);if(!R.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:T,otherPeerIds:R,shouldCancelMessageIfTimesOut:!1});for(const G of R)g.info(`Relaying ownership change of variable with Id ${f} to ${G}.`),w(R,a,i)}})})},Qe=e=>e.startsWith(ne)?at:e.startsWith(ee)?Ve:e.startsWith(te)?Xe:e.startsWith(re)?ct:null,Ze=e=>e.startsWith(ne)||e.startsWith(ee)||e.startsWith(te)||e.startsWith(re),et=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(Ze).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender();g.info(`Received acknowledgment for message ${r}.`);const m=Qe(r);if(!m){k.error(`Invalid acknowledgment message ${r}.`);return}const p=m.exec(r);if(!p){k.error(`Invalid acknowledgment message ${r}.`);return}if(!O[r]||!O[r][i])return;const f=c._clock;if(f!==void 0){const u=p[3],d=p[4],y=fe({sceneNetworkId:d,instanceNetworkId:u});if(f<=y)return;ye({sceneNetworkId:d,instanceNetworkId:u,clock:f})}g.info(`Marking message ${r} as acknowledged from ${i}.`),O[r][i].acknowledged=!0})})},tt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;Object.keys(O).forEach(n=>{const r=O[n],a=Object.keys(r).filter(o=>!r[o].acknowledged);if(!a.length)g.info(`All peers have acknowledged message ${n}.`),delete O[n];else for(const o of a){const{lastMessageSentAt:l,originalMessageName:c,originalData:i,numberOfRetries:m,maxNumberOfRetries:p,messageRetryTime:f}=r[o];if(v()-l>f){if(m>=p){if(g.info(`Giving up on message ${n} for ${o}.`),r[o].shouldCancelMessageIfTimesOut){if(c.startsWith(q)){const u=he.exec(c);if(!u){delete O[n];return}const d=u[2],y=u[3],I=e.getInstancesOf(d);if(!I){delete O[n];return}let P=I.find(N=>N.networkId===y);if(!P){delete O[n];return}const h=P.getBehavior("MultiplayerObject");if(!h){k.error(`Object ${d} does not have the MultiplayerObjectBehavior, cannot revert ownership.`),delete O[n];return}const b=i.previousOwner;if(b===void 0){delete O[n];return}h.playerNumber=b||0}if(c.startsWith(X)){const u=we.exec(c);if(!u){delete O[n];return}const d=u[2],y=i.previousOwner,{type:I,name:P,containerId:h}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(d);if(I==="scene"&&h!==e.networkId){g.info(`Variable ${P} is in scene ${h}, but we are on ${e.networkId}. Skipping ownership revert.`),delete O[n];return}const b=h==="game"?e.getGame().getVariables():e.getVariables();if(!b.has(P)){k.error(`Variable with ID ${d} not found while reverting ownership. This should not happen.`),delete O[n];return}const N=b.get(P);if(y===void 0){delete O[n];return}N.setPlayerOwnership(y||0)}}delete O[n];continue}w([o],c,i),r[o].lastMessageSentAt=v(),r[o].numberOfRetries=m+1}}})},se="#destroyInstance",st=/#destroyInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,nt=({objectOwner:e,objectName:t,instanceNetworkId:n,sceneNetworkId:r})=>({messageName:`${se}#owner_${e}#object_${t}#instance_${n}#scene_${r}`,messageData:{}}),ne="#instanceDestroyed",at=/#instanceDestroyed#owner_(\d+)#object_(.+)#instance_(.+)/,Pe=e=>e.replace(se,ne),rt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(se)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),m=c.getSender();g.info(`Received message ${a} with data ${JSON.stringify(i)}.`);const p=st.exec(a);if(!p||parseInt(p[1],10)===s.multiplayer.playerNumber)return;const u=p[2],d=p[3],y=p[4];if(y!==e.networkId){g.info(`Object ${u} is in scene ${y}, but we are on ${e.networkId}. Skipping.`);return}const I=Z({runtimeScene:e,objectName:u,instanceNetworkId:d}),P=Pe(a);if(!I){g.info("Instance was not found in the scene, sending acknowledgment anyway."),w([m],P,{});return}if(g.info(`Destroying object ${u} with instance network ID ${d}.`),I.deleteFromScene(e),g.info(`Sending acknowledgment of destruction of object ${u} with instance network ID ${d} to ${m}.`),w([m],P,{}),s.multiplayer.isCurrentPlayerHost()){const b=s.multiplayerPeerJsHelper.getAllPeers().filter(N=>N!==m);if(!b.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:P,otherPeerIds:b,shouldCancelMessageIfTimesOut:!1}),w(b,a,i)}})})},ae="#customMessage",ot=/#customMessage#(.+)/,z=e=>`${ae}#${e}`,it=({userMessageName:e,userMessageData:t,senderPlayerNumber:n})=>{const r=s.makeUuid();return{messageName:z(e),messageData:{data:t,uniqueId:r,senderPlayerNumber:n}}},re="#ackCustomMessage",ct=/#ackCustomMessage#(.+)/,Ne=e=>e.replace(ae,re),Oe=(e,t)=>{const n=s.multiplayerPeerJsHelper.getAllPeers(),r=s.multiplayer.getCurrentPlayerNumber(),{messageName:a,messageData:o}=it({userMessageName:e,userMessageData:t,senderPlayerNumber:r}),l=Ne(a);x({originalMessageName:a,originalData:o,expectedMessageName:l,otherPeerIds:n,shouldCancelMessageIfTimesOut:!1}),g.info(`Sending custom message ${e} with data ${JSON.stringify(t)}.`),w(n,a,o),s.multiplayer.isCurrentPlayerHost()&&s.multiplayerPeerJsHelper.getOrCreateMessagesList(a).pushMessage(o,s.multiplayerPeerJsHelper.getCurrentId())},lt=(e,t)=>{const n=t.toJSObject();g.info(`Sending custom message ${e} with data ${JSON.stringify(n)}.`),Oe(e,n)},gt=e=>{const t=z(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();if(!a.length)return;g.info(`custom message ${e} has been received.`);let o=!1;return a.forEach(l=>{const i=l.getData().uniqueId,m=`${t}#${i}`;W.has(m)||(W.add(m),o=!0)}),o},Se=e=>{const t=z(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();return a.length?a[a.length-1].getData().data:void 0},ut=(e,t)=>{const n=Se(e);!n||(g.info(`Received custom message ${e} with data ${JSON.stringify(n)}.`),t.fromJSObject(n))},mt=e=>{const t=z(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return 0;const a=r.getMessages();return a.length?a[a.length-1].getData().senderPlayerNumber:0},dt=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(ae)).forEach(r=>{const a=e.get(r);if(!a){k.error(`No messages list found for ${r}.`);return}const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),m=c.uniqueId;if(g.info(`Received custom message ${r} with data ${JSON.stringify(c)}.`),!ot.exec(r)){k.error(`Invalid custom message ${r}.`);return}const f=`${r}#${m}`;if(W.has(f)){g.info(`Message ${r} has already been processed, skipping.`);return}const u=Ne(r);if(g.info(`Sending acknowledgment of custom message ${r} to ${i}.`),w([i],u,{}),s.multiplayer.isCurrentPlayerHost()){const d=s.multiplayerPeerJsHelper.getAllPeers();if(!d.length)return;x({originalMessageName:r,originalData:c,expectedMessageName:u,otherPeerIds:d,shouldCancelMessageIfTimesOut:!1}),w(d,r,c)}})})},De="#updateScene",ke=({sceneNetworkSyncData:e})=>({messageName:`${De}`,messageData:e}),pt=e=>e.var?Q?JSON.stringify(e.var)!==JSON.stringify(Q.var):!0:!1,ft=()=>v()-me<1e3/xe,yt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=pt(t),r=!ft()||n||V>0;if(n&&(V=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=ke({sceneNetworkSyncData:t});w(a,o,l),me=v(),Q=t,V=Math.max(V-1,0)},ht=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(De)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),m=c.getSender(),p=i.id;if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages()){if(p!==e.networkId){g.info(`Received update of scene ${p}, but we are on ${e.networkId}. Skipping.`);return}e.updateFromNetworkSyncData(i)}else{g.info(`Saving scene ${p} update message for later use.`),F.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const u=s.multiplayerPeerJsHelper.getAllPeers().filter(d=>d!==m);w(u,a,i)}})})},ve="#updateGame",$e=({gameNetworkSyncData:e})=>({messageName:`${ve}`,messageData:e}),bt=e=>{const t=e.var,n=e.ss;if(!t&&!n)return!1;if(!J||!J.var||!J.ss||t&&JSON.stringify(t)!==JSON.stringify(J.var))return!0;if(n){if(n.length!==J.ss.length)return!0;for(let r=0;r<n.length;++r){const a=n[r],o=J.ss[r];if(a.name!==o.name||a.networkId!==o.networkId)return!0}}return!1},Mt=()=>v()-de<1e3/Ge,wt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getGame().getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=bt(t),r=!Mt()||n||B>0;if(n&&(B=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=$e({gameNetworkSyncData:t});w(a,o,l),de=v(),J=t,B=Math.max(B-1,0)},It=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(ve)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),m=c.getSender();if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())e.getGame().updateFromNetworkSyncData(i);else{g.info("Saving game update message for later use."),K.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const f=s.multiplayerPeerJsHelper.getAllPeers().filter(u=>u!==m);w(f,a,i)}})})},Pt=e=>{K.getUpdates().forEach(t=>{g.info("Reapplying saved update of game."),e.getGame().updateFromNetworkSyncData(t)}),K.clear(),F.getUpdates().forEach(t=>{const n=t.id;if(n!==e.networkId){g.info(`Trying to apply saved update of scene ${n}, but we are on ${e.networkId}. Skipping.`);return}g.info(`Reapplying saved update of scene ${n}.`),e.updateFromNetworkSyncData(t),F.remove(t)})},oe="#heartbeat",Nt=/#heartbeat#(.+)/,ie=()=>{M[s.multiplayer.getCurrentPlayerNumber()]={ping:0,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()};for(const e in M)M[e]={...M[e],ping:ce(parseInt(e,10))};return{messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{now:v(),playersInfo:M}}},Ot=({heartbeatSentAt:e})=>({messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{sentAt:e,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()}}),St=()=>!!E&&v()-E<1e3/Ee,Dt=()=>{if(!s.multiplayer.isCurrentPlayerHost()||!!St())return;const t=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:n,messageData:r}=ie();w(t,n,r),E=v()},kt=()=>{const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(oe)).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),m=Nt.exec(r);if(!m)return;const p=parseInt(m[1],10);if(pe[i]=p,!s.multiplayer.isCurrentPlayerHost()){const h=s.multiplayer.getCurrentPlayerNumber(),b=Object.keys(M).map(R=>parseInt(R,10)),N=Object.keys(c.playersInfo).map(R=>parseInt(R,10)),_=M[h]&&M[h].ping;if(b.length){const R=N.filter(L=>!b.includes(L)&&L!==h);$.push(...R);const G=b.filter(L=>!N.includes(L));A.push(...G);for(const L of G)Y[L]=le(L)}Te({source:c.playersInfo,target:M});const{messageName:T,messageData:j}=Ot({heartbeatSentAt:c.now});w([i],T,j),M[h]!==void 0&&M[h].ping!==void 0&&(s.multiplayer.markConnectionAsConnected(),_===void 0&&$.push(h));return}M[p]||$.push(p);const f=v(),u=c.sentAt,d=Math.round(f-u),y=U[p]||[];y.push(d),y.length>5&&y.shift(),U[p]=y;let I=0;for(const h of y)I+=h;const P=Math.round(I/y.length/2);if(M[p]={ping:P,playerId:c.playerId,username:c.username},$.length){const h=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:b,messageData:N}=ie();w(h,b,N),E=v()}})})},vt=e=>(U[e]||[]).length>0,ce=e=>{const t=M[e];return t&&t.ping||0},$t=()=>{const e=s.multiplayer.getCurrentPlayerNumber();return ce(e)},Re=({runtimeScene:e,playerNumber:t,peerId:n})=>{if(k.info(`Marking player ${t} as disconnected.`),A.push(t),Y[t]=le(t),Qt(t),n&&n===s.multiplayer.hostPeerId)if(s.multiplayer.shouldEndLobbyWhenHostLeaves())k.info("Host has disconnected, ending the game."),ge(),s.multiplayer.handleLobbyGameEnded();else{k.info("Host has disconnected, switching host."),s.multiplayer.handleHostDisconnected({runtimeScene:e});return}if(s.multiplayer.isCurrentPlayerHost()){const r=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:a,messageData:o}=ie();w(r,a,o),E=v()}},le=e=>(M[e]||{}).username||Y[e]||`Player ${e}`,Rt=e=>(M[e]||{}).playerId||"",Ct=e=>{if(!s.multiplayer.isLobbyGameRunning())return;const t=[],n=s.multiplayerPeerJsHelper.getJustDisconnectedPeers();if(n.length)for(const r of n){const a=pe[r];if(!a)return;k.info(`Player ${a} has disconnected.`),t.push({playerNumber:a,peerId:r})}for(const{playerNumber:r,peerId:a}of t){if(s.multiplayer.isCurrentPlayerHost()){const o=e.getAdhocListOfAllInstances();for(const l of o){const c=l.getBehavior("MultiplayerObject");if(c&&c.getPlayerObjectOwnership()===r){const i=c.getActionOnPlayerDisconnect();i==="DestroyObject"?l.deleteFromScene(e):i==="GiveOwnershipToHost"&&c.removeObjectOwnership()}}}Re({runtimeScene:e,playerNumber:r,peerId:a})}},At=()=>A.length>0,jt=e=>A.includes(e),Tt=()=>A,Ht=()=>A[0]||0,Jt=()=>{const e=A[0];e!==void 0&&(A=A.slice(1),delete Y[e])},_t=()=>$.length>0,Lt=e=>$.includes(e),xt=()=>$,Gt=()=>$[0]||0,Et=()=>{$[0]!==void 0&&($=$.slice(1))},Ut=()=>Object.keys(M).map(e=>({playerNumber:parseInt(e,10),playerId:M[e].playerId})),Wt=()=>Object.keys(M).length,Vt=e=>M[e]!==void 0,Ft=()=>M,Ce="#endGame",Bt=()=>({messageName:Ce,messageData:{}}),Kt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending endgame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=Bt();w(e,t,n)},Yt=()=>{if(s.multiplayer.isCurrentPlayerHost())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ce);!t||!t.getMessages().length||(k.info("Received endgame message."),ge(),s.multiplayer.handleLobbyGameEnded())},Ae="#resumeGame",qt=()=>({messageName:Ae,messageData:{}}),Xt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending resumeGame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=qt();w(e,t,n)},zt=e=>{if(s.multiplayer.isCurrentPlayerHost())return;const n=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ae);!n||!n.getMessages().length||(k.info("Received resumeGame message."),s.multiplayer.resumeGame(e))},ge=()=>{U={},M={},K.clear(),F.clear(),W.clear(),A=[],$=[],O={},H={}},Qt=e=>{delete U[e],delete M[e]};return{sendDataTo:w,addExpectedMessageAcknowledgement:x,handleAcknowledgeMessagesReceived:et,resendClearOrCancelAcknowledgedMessages:tt,createChangeInstanceOwnerMessage:We,createInstanceOwnerChangedMessageNameFromChangeInstanceOwnerMessage:be,handleChangeInstanceOwnerMessagesReceived:Fe,createUpdateInstanceMessage:Ke,handleUpdateInstanceMessagesReceived:Ye,createDestroyInstanceMessage:nt,createInstanceDestroyedMessageNameFromDestroyInstanceMessage:Pe,handleDestroyInstanceMessagesReceived:rt,createChangeVariableOwnerMessage:qe,createVariableOwnerChangedMessageNameFromChangeVariableOwnerMessage:Ie,handleChangeVariableOwnerMessagesReceived:ze,sendCustomMessage:Oe,getCustomMessageData:Se,sendVariableCustomMessage:lt,getVariableCustomMessageData:ut,hasCustomMessageBeenReceived:gt,handleCustomMessagesReceived:dt,getCustomMessageSender:mt,createUpdateSceneMessage:ke,handleUpdateSceneMessagesToSend:yt,handleUpdateSceneMessagesReceived:ht,createUpdateGameMessage:$e,handleUpdateGameMessagesToSend:wt,handleUpdateGameMessagesReceived:It,handleSavedUpdateMessages:Pt,handleHeartbeatsToSend:Dt,handleHeartbeatsReceived:kt,hasReceivedHeartbeatFromPlayer:vt,getPlayerPing:ce,getCurrentPlayerPing:$t,getPlayerUsername:le,getPlayerId:Rt,handleJustDisconnectedPeers:Ct,getConnectedPlayers:Ut,getNumberOfConnectedPlayers:Wt,isPlayerConnected:Vt,getPlayersInfo:Ft,hasAnyPlayerJustLeft:At,hasPlayerJustLeft:jt,getPlayersWhoJustLeft:Tt,getLatestPlayerWhoJustLeft:Ht,removePlayerWhoJustLeft:Jt,markPlayerAsDisconnected:Re,hasAnyPlayerJustJoined:_t,hasPlayerJustJoined:Lt,getPlayersWhoJustJoined:xt,getLatestPlayerWhoJustJoined:Gt,removePlayerWhoJustJoined:Et,sendEndGameMessage:Kt,handleEndGameMessagesReceived:Yt,clearAllMessagesTempData:ge,sendResumeGameMessage:Xt,handleResumeGameMessagesReceived:zt}},s.multiplayerMessageManager=s.makeMultiplayerMessageManager()})(gdjs||(gdjs={}));
1
+ var gdjs;(function(s){const k=new s.Logger("Multiplayer"),g=new s.Logger("Multiplayer - Debug");s.Logger.getDefaultConsoleLoggerOutput().discardGroup("Multiplayer - Debug");class je{constructor(S){this.clear=()=>{this.cache.clear(),this.keys=[]};this.maxSize=S,this.cache=new Set,this.keys=[]}has(S){return this.cache.has(S)}add(S){if(this.cache.size>=this.maxSize){const D=this.keys.shift();D&&this.cache.delete(D)}this.cache.add(S),this.keys.push(S)}}class ue{constructor(){this._updates=[]}store(S){this._updates.push(S),this._updates.length>10&&this._updates.shift()}getUpdates(){return this._updates}remove(S){const D=this._updates.indexOf(S);D!==-1&&this._updates.splice(D,1)}clear(){this._updates=[]}}const Te=({target:C,source:S})=>{for(const D in S)S.hasOwnProperty(D)&&!C.hasOwnProperty(D)&&(C[D]=S[D]);for(const D in C)C.hasOwnProperty(D)&&!S.hasOwnProperty(D)&&delete C[D]};s.makeMultiplayerMessageManager=()=>{const C=0,S=0,D=0,Je=0,v=window.performance&&typeof window.performance.now=="function"?window.performance.now.bind(window.performance):Date.now,_e=200,Le=4,U=new je(500);let O={},H={};const xe=1;let me=0,Q=null,W=0,V=new ue;const Ge=1;let de=0,J=null,F=0,B=new ue;const Ee=1;let G=0,E={},pe={},M={},A=[],$=[],K={};const x=({originalMessageName:e,originalData:t,expectedMessageName:n,otherPeerIds:r,shouldCancelMessageIfTimesOut:a,maxNumberOfRetries:o,messageRetryTime:l})=>{!s.multiplayer.isLobbyGameRunning()||(O[n]||(O[n]={}),g.info(`Adding expected message ${n} from ${r.join(", ")}.`),r.forEach(c=>{O[n][c]={acknowledged:!1,lastMessageSentAt:v(),originalMessageName:e,originalData:t,shouldCancelMessageIfTimesOut:a,numberOfRetries:0,maxNumberOfRetries:o||Le,messageRetryTime:l||_e}}))},fe=({sceneNetworkId:e,instanceNetworkId:t})=>(H[e]||(H[e]={}),H[e][t]||0),ye=({sceneNetworkId:e,instanceNetworkId:t,clock:n})=>{H[e]||(H[e]={}),H[e][t]=n},w=(e,t,n)=>{if(!(S>0&&Math.random()<S)){if(D>0&&Math.random()<D){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},Je);return}if(C>0){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},C);return}s.multiplayerPeerJsHelper.sendDataTo(e,t,n)}},Ue=(e,t,n)=>{if(!e.length)return null;let r=null,a=1/0;for(let o=0;o<e.length;++o){if(e[o].networkId)continue;const l=e[o],c=Math.pow(l.getX()-t,2)+Math.pow(l.getY()-n,2);c<a&&(r=l,a=c)}return r},Z=({runtimeScene:e,objectName:t,instanceNetworkId:n,instanceX:r,instanceY:a,shouldCreateIfNotFound:o})=>{const l=e.getInstancesOf(t);if(!l)return null;let c=l.find(i=>i.networkId===n)||null;if(!c&&r!==void 0&&a!==void 0){g.info(`instance ${t} ${n} not found with network ID, trying to find it with position ${r}/${a}.`);const i=Ue(l,r,a);i&&(g.info(`Found closest instance for object ${t} ${n} with no network ID.`),c=i,c.networkId=n)}if(!c&&o){g.info(`Instance ${n} still not found, Creating instance ${t}.`);const i=e.createObject(t);if(!i)return null;i.networkId=n,c=i}return c},Y="#changeInstanceOwner",he=/#changeInstanceOwner#owner_(\d+)#object_(.+)#instance_(.+)/,We=({objectOwner:e,objectName:t,instanceNetworkId:n,newObjectOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l})=>({messageName:`${Y}#owner_${e}#object_${t}#instance_${n}`,messageData:{previousOwner:e,newOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l}}),ee="#instanceOwnerChanged",Ve=/#instanceOwnerChanged#owner_(\d+)#object_(.+)#instance_(.+)/,be=e=>e.replace(Y,ee),Fe=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Y)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=he.exec(a);if(!p)return;const f=p[2],u=p[3],m=i.previousOwner,y=i.newOwner,I=i.sceneNetworkId;if(I!==e.networkId){g.info(`Object ${f} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=Z({runtimeScene:e,objectName:f,instanceNetworkId:u,instanceX:i.instanceX,instanceY:i.instanceY});if(!P){g.info(`Instance ${u} not found, it must have been destroyed.`);return}const h=P.getBehavior("MultiplayerObject");if(!h){g.info(`Object ${f} does not have the MultiplayerObjectBehavior, cannot change ownership.`);return}const b=h.getPlayerObjectOwnership(),N=b===m||b===y;if(s.multiplayer.isCurrentPlayerHost()&&!N){g.info(`Object ${f} with instance network ID ${u} does not have the expected owner. Wanted to change from ${m} to ${y}, but object has owner ${b}.`);return}g.info(`Changing ownership of object ${f} to ${y}.`),h.playerNumber=y;const _=be(a);if(g.info(`Sending acknowledgment of ownership change of object ${f} from ${m} to ${y} with instance network ID ${u} to ${d}.`),w([d],_,{}),s.multiplayer.isCurrentPlayerHost()){const j=s.multiplayerPeerJsHelper.getAllPeers().filter(R=>R!==d);if(!j.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:_,otherPeerIds:j,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of object ${f} with instance network ID ${u} to ${j.join(", ")}.`),w(j,a,i)}})})},Me="#updateInstance",Be=/#updateInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,Ke=({objectOwner:e,objectName:t,instanceNetworkId:n,objectNetworkSyncData:r,sceneNetworkId:a})=>({messageName:`${Me}#owner_${e}#object_${t}#instance_${n}#scene_${a}`,messageData:r}),Ye=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Me)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();if(!l.length)return;l.slice().reverse().forEach(i=>{const d=i.getData(),p=i.getSender(),f=Be.exec(a);if(!f)return;const u=parseInt(f[1],10);if(u===s.multiplayer.playerNumber)return;const m=f[2],y=f[3],I=f[4];if(I!==e.networkId){g.info(`Object ${m} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=d._clock,h=fe({sceneNetworkId:I,instanceNetworkId:y});if(P<=h)return;const b=Z({runtimeScene:e,objectName:m,instanceNetworkId:y,shouldCreateIfNotFound:!0,instanceX:d.x,instanceY:d.y});if(!b){k.error("Instance could not be found or created.");return}const N=b.getBehavior("MultiplayerObject");if(!N){k.error(`Object ${m} does not have the MultiplayerObjectBehavior, cannot update it.`);return}if(N.getPlayerObjectOwnership()===s.multiplayer.playerNumber){g.info(`Object ${m} with instance network ID ${y} is owned by us ${s.multiplayer.playerNumber}, ignoring update message from ${u}.`);return}if(N.getPlayerObjectOwnership()!==u&&(g.info(`Object ${m} with instance network ID ${y} is owned by ${N.getPlayerObjectOwnership()} on our game, changing ownership to ${u} as part of the update event.`),N.playerNumber=u),b.updateFromNetworkSyncData(d),ye({sceneNetworkId:I,instanceNetworkId:y,clock:P}),N._clock=P,s.multiplayer.isCurrentPlayerHost()){const T=s.multiplayerPeerJsHelper.getAllPeers().filter(j=>j!==p);if(!T.length)return;w(T,a,d)}})})},q="#changeVariableOwner",we=/#changeVariableOwner#owner_(\d+)#variable_(.+)/,qe=({variableOwner:e,variableNetworkId:t,newVariableOwner:n})=>({messageName:`${q}#owner_${e}#variable_${t}`,messageData:{previousOwner:e,newOwner:n}}),te="#variableOwnerChanged",Xe=/#variableOwnerChanged#owner_(\d+)#variable_(.+)/,Ie=e=>e.replace(q,te),ze=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(q)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=we.exec(a);if(!p)return;const f=p[2],u=i.previousOwner,m=i.newOwner,{type:y,name:I,containerId:P}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(f);if(y==="scene"&&P!==e.networkId){g.info(`Variable ${I} is in scene ${P}, but we are on ${e.networkId}. Skipping.`);return}const h=P==="game"?e.getGame().getVariables():e.getVariables();if(!h.has(I)){k.error(`Variable with ID ${f} not found whilst syncing. This should not happen.`);return}const b=h.get(I),N=b.getPlayerOwnership(),_=N===u||N===m;if(s.multiplayer.isCurrentPlayerHost()&&!_){g.info(`Variable with ID ${f} does not have the expected owner. Wanted to change from ${u} to ${m}, but variable has owner ${N}.`);return}g.info(`Changing ownership of variable ${I} to ${m}.`),b.setPlayerOwnership(m);const T=Ie(a);if(g.info(`Sending acknowledgment of ownership change of variable with ID ${f} from ${u} to ${m} to ${d}.`),w([d],T,{}),s.multiplayer.isCurrentPlayerHost()){const R=s.multiplayerPeerJsHelper.getAllPeers().filter(z=>z!==d);if(!R.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:T,otherPeerIds:R,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of variable with Id ${f} to ${R.join(", ")}.`),w(R,a,i)}})})},Qe=e=>e.startsWith(ne)?at:e.startsWith(ee)?Ve:e.startsWith(te)?Xe:e.startsWith(re)?ct:null,Ze=e=>e.startsWith(ne)||e.startsWith(ee)||e.startsWith(te)||e.startsWith(re),et=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(Ze).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender();g.info(`Received acknowledgment for message ${r}.`);const d=Qe(r);if(!d){k.error(`Invalid acknowledgment message ${r}.`);return}const p=d.exec(r);if(!p){k.error(`Invalid acknowledgment message ${r}.`);return}if(!O[r]||!O[r][i])return;const f=c._clock;if(f!==void 0){const u=p[3],m=p[4],y=fe({sceneNetworkId:m,instanceNetworkId:u});if(f<=y)return;ye({sceneNetworkId:m,instanceNetworkId:u,clock:f})}g.info(`Marking message ${r} as acknowledged from ${i}.`),O[r][i].acknowledged=!0})})},tt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;Object.keys(O).forEach(n=>{const r=O[n],a=Object.keys(r).filter(o=>!r[o].acknowledged);if(!a.length)g.info(`All peers have acknowledged message ${n}.`),delete O[n];else for(const o of a){const{lastMessageSentAt:l,originalMessageName:c,originalData:i,numberOfRetries:d,maxNumberOfRetries:p,messageRetryTime:f}=r[o];if(v()-l>f){if(d>=p){if(g.info(`Giving up on message ${n} for ${o}.`),r[o].shouldCancelMessageIfTimesOut){if(c.startsWith(Y)){const u=he.exec(c);if(!u){delete O[n];return}const m=u[2],y=u[3],I=e.getInstancesOf(m);if(!I){delete O[n];return}let P=I.find(N=>N.networkId===y);if(!P){delete O[n];return}const h=P.getBehavior("MultiplayerObject");if(!h){k.error(`Object ${m} does not have the MultiplayerObjectBehavior, cannot revert ownership.`),delete O[n];return}const b=i.previousOwner;if(b===void 0){delete O[n];return}h.playerNumber=b||0}if(c.startsWith(q)){const u=we.exec(c);if(!u){delete O[n];return}const m=u[2],y=i.previousOwner,{type:I,name:P,containerId:h}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(m);if(I==="scene"&&h!==e.networkId){g.info(`Variable ${P} is in scene ${h}, but we are on ${e.networkId}. Skipping ownership revert.`),delete O[n];return}const b=h==="game"?e.getGame().getVariables():e.getVariables();if(!b.has(P)){k.error(`Variable with ID ${m} not found while reverting ownership. This should not happen.`),delete O[n];return}const N=b.get(P);if(y===void 0){delete O[n];return}N.setPlayerOwnership(y||0)}}delete O[n];continue}w([o],c,i),r[o].lastMessageSentAt=v(),r[o].numberOfRetries=d+1}}})},se="#destroyInstance",st=/#destroyInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,nt=({objectOwner:e,objectName:t,instanceNetworkId:n,sceneNetworkId:r})=>({messageName:`${se}#owner_${e}#object_${t}#instance_${n}#scene_${r}`,messageData:{}}),ne="#instanceDestroyed",at=/#instanceDestroyed#owner_(\d+)#object_(.+)#instance_(.+)/,Pe=e=>e.replace(se,ne),rt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(se)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender();g.info(`Received message ${a} with data ${JSON.stringify(i)}.`);const p=st.exec(a);if(!p||parseInt(p[1],10)===s.multiplayer.playerNumber)return;const u=p[2],m=p[3],y=p[4];if(y!==e.networkId){g.info(`Object ${u} is in scene ${y}, but we are on ${e.networkId}. Skipping.`);return}const I=Z({runtimeScene:e,objectName:u,instanceNetworkId:m}),P=Pe(a);if(!I){g.info("Instance was not found in the scene, sending acknowledgment anyway."),w([d],P,{});return}if(g.info(`Destroying object ${u} with instance network ID ${m}.`),I.deleteFromScene(e),g.info(`Sending acknowledgment of destruction of object ${u} with instance network ID ${m} to ${d}.`),w([d],P,{}),s.multiplayer.isCurrentPlayerHost()){const b=s.multiplayerPeerJsHelper.getAllPeers().filter(N=>N!==d);if(!b.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:P,otherPeerIds:b,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying instance destroyed message for object ${u} with instance network ID ${m} to ${b.join(", ")}.`),w(b,a,i)}})})},ae="#customMessage",ot=/#customMessage#(.+)/,X=e=>`${ae}#${e}`,it=({userMessageName:e,userMessageData:t,senderPlayerNumber:n})=>{const r=s.makeUuid();return{messageName:X(e),messageData:{data:t,uniqueId:r,senderPlayerNumber:n}}},re="#ackCustomMessage",ct=/#ackCustomMessage#(.+)/,Ne=e=>e.replace(ae,re),Oe=(e,t)=>{const n=s.multiplayerPeerJsHelper.getAllPeers(),r=s.multiplayer.getCurrentPlayerNumber(),{messageName:a,messageData:o}=it({userMessageName:e,userMessageData:t,senderPlayerNumber:r}),l=Ne(a);x({originalMessageName:a,originalData:o,expectedMessageName:l,otherPeerIds:n,shouldCancelMessageIfTimesOut:!1}),g.info(`Sending custom message ${e} with data ${JSON.stringify(t)}.`),w(n,a,o),s.multiplayer.isCurrentPlayerHost()&&s.multiplayerPeerJsHelper.getOrCreateMessagesList(a).pushMessage(o,s.multiplayerPeerJsHelper.getCurrentId())},lt=(e,t)=>{const n=t.toJSObject();g.info(`Sending custom message ${e} with data ${JSON.stringify(n)}.`),Oe(e,n)},gt=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();if(!a.length)return;g.info(`custom message ${e} has been received.`);let o=!1;return a.forEach(l=>{const i=l.getData().uniqueId,d=`${t}#${i}`;U.has(d)||(U.add(d),o=!0)}),o},Se=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();return a.length?a[a.length-1].getData().data:void 0},ut=(e,t)=>{const n=Se(e);!n||(g.info(`Received custom message ${e} with data ${JSON.stringify(n)}.`),t.fromJSObject(n))},mt=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return 0;const a=r.getMessages();return a.length?a[a.length-1].getData().senderPlayerNumber:0},dt=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(ae)).forEach(r=>{const a=e.get(r);if(!a){k.error(`No messages list found for ${r}.`);return}const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),d=c.uniqueId;if(g.info(`Received custom message ${r} with data ${JSON.stringify(c)}.`),!ot.exec(r)){k.error(`Invalid custom message ${r}.`);return}const f=`${r}#${d}`;if(U.has(f)){g.info(`Message ${r} has already been processed, skipping.`);return}const u=Ne(r);if(g.info(`Sending acknowledgment of custom message ${r} to ${i}.`),w([i],u,{}),s.multiplayer.isCurrentPlayerHost()){const m=s.multiplayerPeerJsHelper.getAllPeers();if(!m.length)return;x({originalMessageName:r,originalData:c,expectedMessageName:u,otherPeerIds:m,shouldCancelMessageIfTimesOut:!1}),w(m,r,c)}})})},De="#updateScene",ke=({sceneNetworkSyncData:e})=>({messageName:`${De}`,messageData:e}),pt=e=>e.var?Q?JSON.stringify(e.var)!==JSON.stringify(Q.var):!0:!1,ft=()=>v()-me<1e3/xe,yt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=pt(t),r=!ft()||n||W>0;if(n&&(W=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=ke({sceneNetworkSyncData:t});w(a,o,l),me=v(),Q=t,W=Math.max(W-1,0)},ht=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(De)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=i.id;if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages()){if(p!==e.networkId){g.info(`Received update of scene ${p}, but we are on ${e.networkId}. Skipping.`);return}e.updateFromNetworkSyncData(i)}else{g.info(`Saving scene ${p} update message for later use.`),V.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const u=s.multiplayerPeerJsHelper.getAllPeers().filter(m=>m!==d);w(u,a,i)}})})},ve="#updateGame",$e=({gameNetworkSyncData:e})=>({messageName:`${ve}`,messageData:e}),bt=e=>{const t=e.var,n=e.ss;if(!t&&!n)return!1;if(!J||!J.var||!J.ss||t&&JSON.stringify(t)!==JSON.stringify(J.var))return!0;if(n){if(n.length!==J.ss.length)return!0;for(let r=0;r<n.length;++r){const a=n[r],o=J.ss[r];if(a.name!==o.name||a.networkId!==o.networkId)return!0}}return!1},Mt=()=>v()-de<1e3/Ge,wt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getGame().getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=bt(t),r=!Mt()||n||F>0;if(n&&(F=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=$e({gameNetworkSyncData:t});w(a,o,l),de=v(),J=t,F=Math.max(F-1,0)},It=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(ve)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender();if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())e.getGame().updateFromNetworkSyncData(i);else{g.info("Saving game update message for later use."),B.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const f=s.multiplayerPeerJsHelper.getAllPeers().filter(u=>u!==d);w(f,a,i)}})})},Pt=e=>{B.getUpdates().forEach(t=>{g.info("Reapplying saved update of game."),e.getGame().updateFromNetworkSyncData(t)}),B.clear(),V.getUpdates().forEach(t=>{const n=t.id;if(n!==e.networkId){g.info(`Trying to apply saved update of scene ${n}, but we are on ${e.networkId}. Skipping.`);return}g.info(`Reapplying saved update of scene ${n}.`),e.updateFromNetworkSyncData(t),V.remove(t)})},oe="#heartbeat",Nt=/#heartbeat#(.+)/,ie=()=>{M[s.multiplayer.getCurrentPlayerNumber()]={ping:0,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()};for(const e in M)M[e]={...M[e],ping:ce(parseInt(e,10))};return{messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{now:v(),playersInfo:M}}},Ot=({heartbeatSentAt:e})=>({messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{sentAt:e,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()}}),St=()=>!!G&&v()-G<1e3/Ee,Dt=()=>{if(!s.multiplayer.isCurrentPlayerHost()||!!St())return;const t=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:n,messageData:r}=ie();w(t,n,r),G=v()},kt=()=>{const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(oe)).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),d=Nt.exec(r);if(!d)return;const p=parseInt(d[1],10);if(pe[i]=p,!s.multiplayer.isCurrentPlayerHost()){const h=s.multiplayer.getCurrentPlayerNumber(),b=Object.keys(M).map(R=>parseInt(R,10)),N=Object.keys(c.playersInfo).map(R=>parseInt(R,10)),_=M[h]&&M[h].ping;if(b.length){const R=N.filter(L=>!b.includes(L)&&L!==h);$.push(...R);const z=b.filter(L=>!N.includes(L));A.push(...z);for(const L of z)K[L]=le(L)}Te({source:c.playersInfo,target:M});const{messageName:T,messageData:j}=Ot({heartbeatSentAt:c.now});w([i],T,j),M[h]!==void 0&&M[h].ping!==void 0&&(s.multiplayer.markConnectionAsConnected(),_===void 0&&$.push(h));return}M[p]||$.push(p);const f=v(),u=c.sentAt,m=Math.round(f-u),y=E[p]||[];y.push(m),y.length>5&&y.shift(),E[p]=y;let I=0;for(const h of y)I+=h;const P=Math.round(I/y.length/2);if(M[p]={ping:P,playerId:c.playerId,username:c.username},$.length){const h=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:b,messageData:N}=ie();w(h,b,N),G=v()}})})},vt=e=>(E[e]||[]).length>0,ce=e=>{const t=M[e];return t&&t.ping||0},$t=()=>{const e=s.multiplayer.getCurrentPlayerNumber();return ce(e)},Re=({runtimeScene:e,playerNumber:t,peerId:n})=>{if(k.info(`Marking player ${t} as disconnected.`),A.push(t),K[t]=le(t),Qt(t),n&&n===s.multiplayer.hostPeerId)if(s.multiplayer.shouldEndLobbyWhenHostLeaves())k.info("Host has disconnected, ending the game."),ge(),s.multiplayer.handleLobbyGameEnded();else{k.info("Host has disconnected, switching host."),s.multiplayer.handleHostDisconnected({runtimeScene:e});return}if(s.multiplayer.isCurrentPlayerHost()){const r=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:a,messageData:o}=ie();w(r,a,o),G=v()}},le=e=>(M[e]||{}).username||K[e]||`Player ${e}`,Rt=e=>(M[e]||{}).playerId||"",Ct=e=>{if(!s.multiplayer.isLobbyGameRunning())return;const t=[],n=s.multiplayerPeerJsHelper.getJustDisconnectedPeers();if(n.length)for(const r of n){const a=pe[r];if(!a)return;k.info(`Player ${a} has disconnected.`),t.push({playerNumber:a,peerId:r})}for(const{playerNumber:r,peerId:a}of t){if(s.multiplayer.isCurrentPlayerHost()){const o=e.getAdhocListOfAllInstances();for(const l of o){const c=l.getBehavior("MultiplayerObject");if(c&&c.getPlayerObjectOwnership()===r){const i=c.getActionOnPlayerDisconnect();i==="DestroyObject"?l.deleteFromScene(e):i==="GiveOwnershipToHost"&&c.removeObjectOwnership()}}}Re({runtimeScene:e,playerNumber:r,peerId:a})}},At=()=>A.length>0,jt=e=>A.includes(e),Tt=()=>A,Ht=()=>A[0]||0,Jt=()=>{const e=A[0];e!==void 0&&(A=A.slice(1),delete K[e])},_t=()=>$.length>0,Lt=e=>$.includes(e),xt=()=>$,Gt=()=>$[0]||0,Et=()=>{$[0]!==void 0&&($=$.slice(1))},Ut=()=>Object.keys(M).map(e=>({playerNumber:parseInt(e,10),playerId:M[e].playerId})),Wt=()=>Object.keys(M).length,Vt=e=>M[e]!==void 0,Ft=()=>M,Ce="#endGame",Bt=()=>({messageName:Ce,messageData:{}}),Kt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending endgame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=Bt();w(e,t,n)},Yt=()=>{if(s.multiplayer.isCurrentPlayerHost())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ce);!t||!t.getMessages().length||(k.info("Received endgame message."),ge(),s.multiplayer.handleLobbyGameEnded())},Ae="#resumeGame",qt=()=>({messageName:Ae,messageData:{}}),Xt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending resumeGame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=qt();w(e,t,n)},zt=e=>{if(s.multiplayer.isCurrentPlayerHost())return;const n=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ae);!n||!n.getMessages().length||(k.info("Received resumeGame message."),s.multiplayer.resumeGame(e))},ge=()=>{E={},M={},B.clear(),V.clear(),U.clear(),A=[],$=[],O={},H={}},Qt=e=>{delete E[e],delete M[e]};return{sendDataTo:w,addExpectedMessageAcknowledgement:x,handleAcknowledgeMessagesReceived:et,resendClearOrCancelAcknowledgedMessages:tt,createChangeInstanceOwnerMessage:We,createInstanceOwnerChangedMessageNameFromChangeInstanceOwnerMessage:be,handleChangeInstanceOwnerMessagesReceived:Fe,createUpdateInstanceMessage:Ke,handleUpdateInstanceMessagesReceived:Ye,createDestroyInstanceMessage:nt,createInstanceDestroyedMessageNameFromDestroyInstanceMessage:Pe,handleDestroyInstanceMessagesReceived:rt,createChangeVariableOwnerMessage:qe,createVariableOwnerChangedMessageNameFromChangeVariableOwnerMessage:Ie,handleChangeVariableOwnerMessagesReceived:ze,sendCustomMessage:Oe,getCustomMessageData:Se,sendVariableCustomMessage:lt,getVariableCustomMessageData:ut,hasCustomMessageBeenReceived:gt,handleCustomMessagesReceived:dt,getCustomMessageSender:mt,createUpdateSceneMessage:ke,handleUpdateSceneMessagesToSend:yt,handleUpdateSceneMessagesReceived:ht,createUpdateGameMessage:$e,handleUpdateGameMessagesToSend:wt,handleUpdateGameMessagesReceived:It,handleSavedUpdateMessages:Pt,handleHeartbeatsToSend:Dt,handleHeartbeatsReceived:kt,hasReceivedHeartbeatFromPlayer:vt,getPlayerPing:ce,getCurrentPlayerPing:$t,getPlayerUsername:le,getPlayerId:Rt,handleJustDisconnectedPeers:Ct,getConnectedPlayers:Ut,getNumberOfConnectedPlayers:Wt,isPlayerConnected:Vt,getPlayersInfo:Ft,hasAnyPlayerJustLeft:At,hasPlayerJustLeft:jt,getPlayersWhoJustLeft:Tt,getLatestPlayerWhoJustLeft:Ht,removePlayerWhoJustLeft:Jt,markPlayerAsDisconnected:Re,hasAnyPlayerJustJoined:_t,hasPlayerJustJoined:Lt,getPlayersWhoJustJoined:xt,getLatestPlayerWhoJustJoined:Gt,removePlayerWhoJustJoined:Et,sendEndGameMessage:Kt,handleEndGameMessagesReceived:Yt,clearAllMessagesTempData:ge,sendResumeGameMessage:Xt,handleResumeGameMessagesReceived:zt}},s.multiplayerMessageManager=s.makeMultiplayerMessageManager()})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=messageManager.js.map