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.
- package/README.md +64 -64
- package/dist/Runtime/Extensions/3D/JsExtension.js +7 -3
- package/dist/Runtime/Extensions/DialogueTree/JsExtension.js +44 -32
- package/dist/Runtime/Extensions/DialogueTree/bondage.js/dist/bondage.min.js +10 -10
- package/dist/Runtime/Extensions/DialogueTree/bondage.js/version.txt +5 -5
- package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js +2 -2
- package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
- package/dist/Runtime/Extensions/Firebase/A_firebasejs/NOTICE.txt +6 -6
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/PhysicsBehavior/box2djs/box2d.js +804 -804
- package/dist/Runtime/Extensions/Shopify/shopify-buy.umd.polyfilled.min.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
- package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/example/anotherIsland.json +5768 -5768
- package/dist/Runtime/Extensions/TileMap/example/island.json +5822 -5822
- package/dist/Runtime/Model3DManager.js +1 -1
- package/dist/Runtime/Model3DManager.js.map +2 -2
- package/dist/Runtime/ResourceLoader.js +1 -1
- package/dist/Runtime/ResourceLoader.js.map +2 -2
- package/dist/Runtime/capturemanager.js +2 -0
- package/dist/Runtime/capturemanager.js.map +7 -0
- package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
- package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
- package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
- package/dist/Runtime/jsonmanager.js +1 -1
- package/dist/Runtime/jsonmanager.js.map +2 -2
- package/dist/Runtime/layer.js +1 -1
- package/dist/Runtime/layer.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/Runtime/runtimegame.js +1 -1
- package/dist/Runtime/runtimegame.js.map +2 -2
- package/dist/Runtime/runtimewatermark.js +2 -2
- package/dist/Runtime/runtimewatermark.js.map +2 -2
- package/dist/Runtime/scenestack.js +1 -1
- package/dist/Runtime/scenestack.js.map +2 -2
- package/dist/Runtime/spriteruntimeobject.js +1 -1
- package/dist/Runtime/spriteruntimeobject.js.map +2 -2
- package/dist/lib/libGD.cjs +21 -21
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +22 -6
- package/package.json +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/.package-lock.json +0 -19
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/@types/pako/index.d.ts +0 -165
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/@types/pako/package.json +0 -35
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.min.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.min.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.min.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.min.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.min.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.min.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/index.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/index.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/deflate.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/deflate.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/inflate.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/inflate.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/common.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/common.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/strings.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/strings.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/adler32.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/adler32.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/constants.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/constants.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/crc32.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/crc32.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/deflate.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/deflate.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/gzheader.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/gzheader.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inffast.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inffast.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inflate.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inflate.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inftrees.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inftrees.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/messages.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/messages.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/trees.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/trees.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/zstream.js +0 -2
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/zstream.js.map +0 -7
- package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/package.json +0 -64
- package/types/index.d.ts +0 -23
- package/types/open_project.d.ts +0 -25
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var gdjs;(function(n){let a;(function(
|
|
1
|
+
var gdjs;(function(n){let a;(function(r){class s{constructor(e,t,i){this._linkElement=null;this._containerElement=null;this._backgroundElement=null;this._svgElement=null;this._usernameTextElement=null;this._madeWithTextElement=null;this._resizeObserver=null;this._displayDuration=20;this._changeTextDelay=7;this._fadeInDelayAfterGameLoaded=1;this._fadeDuration=.3;this._fadeOutTimeout=null;this._hideTimeout=null;this._fadeOutFirstTextTimeout=null;this._fadeInSecondTextTimeout=null;this._textFontSize=14;this._logoWidth=56;this._logoHeight=45;this._backgroundHeight=150;this._margin=10;this._gameId=e._data.properties.projectUuid,this._gameRenderer=e.getRenderer(),this._authorUsername=t[0],this._placement=i.placement,this._showAtStartup=i.showWatermark,this._isDevEnvironment=e.isUsingGDevelopDevelopmentEnvironment(),i.showWatermark&&this.addStyle()}displayAtStartup(){this._showAtStartup&&this.display()}display(){const e=this._gameRenderer.getDomElementContainer();e&&(this.addWatermarkToGameContainer(e),this._resizeObserver=new ResizeObserver(()=>{const t=e.getBoundingClientRect();this.onResizeGameContainer(t.height)}),this._resizeObserver.observe(e))}updateFontSize(e){this._textFontSize=Math.max(.025*e,12)}updateLogoSize(e){this._logoWidth=Math.max(.06*e,25),this._logoHeight=Math.round(45/56*this._logoWidth)}updateBackgroundHeight(e){this._backgroundHeight=Math.max(.13*e,45)}updateMargin(e){this._margin=Math.max(.025*e,8)}onResizeGameContainer(e){this.updateFontSize(e),this._madeWithTextElement&&(this._madeWithTextElement.style.fontSize=`${this._textFontSize}px`),this._usernameTextElement&&(this._usernameTextElement.style.fontSize=`${this._textFontSize}px`),this.updateLogoSize(e),this._svgElement&&(this._svgElement.setAttribute("height",this._logoHeight.toString()),this._svgElement.setAttribute("width",this._logoWidth.toString())),this.updateBackgroundHeight(e),this._backgroundElement&&(this._backgroundElement.style.height=`${this._backgroundHeight}px`),this.updateMargin(e),this._linkElement&&this.updateElementMargins(this._linkElement)}addWatermarkToGameContainer(e){const t=e.getBoundingClientRect();this.updateFontSize(t.height),this.updateLogoSize(t.height),this.updateBackgroundHeight(t.height),this._containerElement=this.createDivContainer(),this.createBackground();const i=document.createElement("div");this.generateSVGLogo(t.height),this.createMadeWithTextElement(),this.createUsernameTextElement(),this._linkElement=this.createLinkElement(),this._svgElement&&this._containerElement.appendChild(this._svgElement),this._madeWithTextElement&&i.appendChild(this._madeWithTextElement),this._usernameTextElement&&i.appendChild(this._usernameTextElement),this._containerElement.appendChild(i),this._backgroundElement&&e.appendChild(this._backgroundElement),this._linkElement.append(this._containerElement),e.appendChild(this._linkElement),this.setupAnimations()}createBackground(){this._backgroundElement=document.createElement("div"),this._backgroundElement.setAttribute("id","watermark-background"),this._backgroundElement.style.height=`${this._backgroundHeight}px`,this._backgroundElement.style.opacity="0",this._placement.startsWith("top")?(this._backgroundElement.style.top="0",this._backgroundElement.style.backgroundImage="linear-gradient(180deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )"):(this._backgroundElement.style.bottom="0",this._backgroundElement.style.backgroundImage="linear-gradient(0deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )")}setupAnimations(){requestAnimationFrame(()=>{setTimeout(()=>{!this._containerElement||!this._backgroundElement||!this._linkElement||(this._containerElement.style.opacity="1",this._backgroundElement.style.opacity="1",this._linkElement.style.pointerEvents="all",this._svgElement&&this._svgElement.classList.add("spinning"))},this._fadeInDelayAfterGameLoaded*1e3)}),this._fadeOutTimeout=setTimeout(()=>{!this._containerElement||!this._backgroundElement||(this._containerElement.style.opacity="0",this._backgroundElement.style.opacity="0",this._hideTimeout=setTimeout(()=>{!this._containerElement||!this._backgroundElement||!this._linkElement||(this._linkElement.style.pointerEvents="none",this._containerElement.style.display="none",this._backgroundElement.style.display="none",this._resizeObserver&&this._resizeObserver.disconnect())},this._fadeDuration*1e3))},(this._fadeInDelayAfterGameLoaded+this._displayDuration)*1e3),this._fadeOutFirstTextTimeout=setTimeout(()=>{const{_madeWithTextElement:e,_usernameTextElement:t}=this;!e||t&&(e.style.opacity="0",this._fadeInSecondTextTimeout=setTimeout(()=>{t.style.lineHeight="normal",t.style.opacity="1",e.style.lineHeight="0"},this._fadeDuration*1e3))},(this._fadeInDelayAfterGameLoaded+this._changeTextDelay)*1e3)}createMadeWithTextElement(){this._madeWithTextElement=document.createElement("span"),this._madeWithTextElement.innerText="Made with GDevelop",this._madeWithTextElement.style.fontSize=`${this._textFontSize}px`}createUsernameTextElement(){!this._authorUsername||(this._usernameTextElement=document.createElement("span"),this._usernameTextElement.innerText=`@${this._authorUsername}`,this._usernameTextElement.style.fontSize=`${this._textFontSize}px`,this._usernameTextElement.style.opacity="0",this._usernameTextElement.style.lineHeight="0")}updateElementMargins(e){switch(this._placement){case"top-left":e.style.top=`${this._margin}px`,e.style.left=`${this._margin}px`;break;case"top-right":e.style.top=`${this._margin}px`,e.style.right=`${this._margin}px`;break;case"bottom-left":e.style.bottom=`${this._margin}px`,e.style.left=`${this._margin}px`;break;case"bottom-right":e.style.bottom=`${this._margin}px`,e.style.right=`${this._margin}px`;break;case"top":e.style.top=`${this._margin}px`,e.style.left="50%",e.style.transform="translate(-50%, 0)";break;case"bottom":default:e.style.bottom=`${this._margin}px`,e.style.left="50%",e.style.transform="translate(-50%, 0)";break}}createLinkElement(){const e=document.createElement("a");e.id="watermark-link";let t=this._authorUsername?new URL(`https://gd.games/${this._authorUsername}`):new URL("https://gd.games");return this._isDevEnvironment?t.searchParams.set("dev","true"):(t.searchParams.set("utm_source","gdevelop-game"),t.searchParams.set("utm_medium","game-watermark"),this._gameId&&t.searchParams.set("utm_campaign",this._gameId)),e.href=t.href,e.target="_blank",this.updateElementMargins(e),e}createDivContainer(){const e=document.createElement("div");return e.setAttribute("id","watermark"),e.style.opacity="0",e}generateSVGLogo(e){this._svgElement=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.updateLogoSize(e),this._svgElement.setAttribute("height",this._logoHeight.toString()),this._svgElement.setAttribute("width",this._logoWidth.toString()),this._svgElement.setAttribute("viewBox","-2 -2 59 48"),this._svgElement.setAttribute("fill","none");const t=document.createElementNS("http://www.w3.org/2000/svg","path"),i=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M29.3447 33C25.1061 33 21.0255 31.8475 17.4207 29.3381C14.9081 27.5897 12 23.6418 12 16.9488C12 4.53178 18.3074 0 30.9827 0H53.8027L56 7.07232H32.7217C24.3558 7.07232 19.3813 7.72835 19.3813 16.9488C19.3813 19.9944 20.2354 22.1618 21.9933 23.574C24.9642 25.9612 30.7388 26.0628 34.2673 25.7208C34.2673 25.7208 35.715 21.0394 35.9534 20.2794C36.2327 19.3888 36.1104 19.1763 35.2392 19.1763C33.9808 19.1763 31.7185 19.1763 29.3175 19.1763C27.6349 19.1763 25.9818 18.3247 25.9818 16.2793C25.9818 14.3039 27.5198 13.1573 29.6281 13.1573C33.2786 13.1573 40.7969 13.1573 42.2041 13.1573C44.0489 13.1573 45.9315 13.4233 44.971 16.3601L39.8842 31.8734C39.8845 31.8738 35.7287 33 29.3447 33Z"),i.setAttribute("d","M43.3039 35.3278C40.7894 37.1212 37.0648 38.1124 30.7449 38.1124C19.852 38.1124 11.8797 34.1251 8.62927 26.3952C7.0925 22.7415 7.24041 18.6005 7.24041 13H0.00129513C0.00129513 18.9056 -0.0984386 23.5361 1.45249 27.8011C5.51933 38.989 15.992 45 30.0606 45C43.6783 45 49.3213 41.0443 53 35.3278H43.3039Z"),this._svgElement.appendChild(t),this._svgElement.appendChild(i)}addStyle(){const e=document.createElement("style");e.innerHTML=`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% {
|
|
4
4
|
transform: rotate(0deg);
|
|
@@ -96,5 +96,5 @@ var gdjs;(function(n){let a;(function(s){class r{constructor(e,t,i){this._linkEl
|
|
|
96
96
|
-webkit-text-decoration-color: white;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
`,document.head.appendChild(e)}}
|
|
99
|
+
`,document.head.appendChild(e)}}r.RuntimeWatermark=s})(a=n.watermark||(n.watermark={}))})(gdjs||(gdjs={}));
|
|
100
100
|
//# sourceMappingURL=runtimewatermark.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/runtimewatermark.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n export namespace watermark {\n export class RuntimeWatermark {\n _gameRenderer: RuntimeGameRenderer;\n _isDevEnvironment: boolean;\n\n // Configuration\n _placement:\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom'\n | 'top';\n _showAtStartup: boolean;\n _authorUsername: string | undefined;\n _gameId: string | undefined;\n\n // Dom elements\n _linkElement: HTMLAnchorElement | null = null;\n _containerElement: HTMLDivElement | null = null;\n _backgroundElement: HTMLDivElement | null = null;\n _svgElement: SVGElement | null = null;\n _usernameTextElement: HTMLSpanElement | null = null;\n _madeWithTextElement: HTMLSpanElement | null = null;\n\n _resizeObserver: ResizeObserver | null = null;\n\n // Durations in seconds\n _displayDuration: number = 20;\n _changeTextDelay: number = 7;\n _fadeInDelayAfterGameLoaded: number = 1;\n _fadeDuration: number = 0.3;\n\n // Timeout registration\n _fadeOutTimeout: NodeJS.Timeout | null = null;\n _hideTimeout: NodeJS.Timeout | null = null;\n _fadeOutFirstTextTimeout: NodeJS.Timeout | null = null;\n _fadeInSecondTextTimeout: NodeJS.Timeout | null = null;\n\n // Sizes\n _textFontSize: number = 14;\n _logoWidth: number = 56;\n _logoHeight: number = 45;\n _backgroundHeight: number = 150;\n _margin: number = 10;\n\n constructor(\n game: RuntimeGame,\n authorUsernames: Array<string>,\n watermarkData: WatermarkData\n ) {\n this._gameId = game._data.properties.projectUuid;\n this._gameRenderer = game.getRenderer();\n this._authorUsername = authorUsernames[0];\n this._placement = watermarkData.placement;\n this._showAtStartup = watermarkData.showWatermark;\n this._isDevEnvironment = game.isUsingGDevelopDevelopmentEnvironment();\n this.addStyle();\n }\n\n displayAtStartup() {\n if (this._showAtStartup) {\n this.display();\n }\n }\n\n display() {\n const gameContainer = this._gameRenderer.getDomElementContainer();\n if (gameContainer) {\n this.addWatermarkToGameContainer(gameContainer);\n this._resizeObserver = new ResizeObserver(() => {\n const gameContainerRectangle = gameContainer.getBoundingClientRect();\n this.onResizeGameContainer(gameContainerRectangle.height);\n });\n this._resizeObserver.observe(gameContainer);\n }\n }\n\n private updateFontSize(height: number) {\n this._textFontSize = Math.max(0.025 * height, 12);\n }\n private updateLogoSize(height: number) {\n this._logoWidth = Math.max(0.06 * height, 25);\n this._logoHeight = Math.round((45 / 56) * this._logoWidth);\n }\n private updateBackgroundHeight(height: number) {\n this._backgroundHeight = Math.max(0.13 * height, 45);\n }\n private updateMargin(height: number) {\n this._margin = Math.max(0.025 * height, 8);\n }\n\n private onResizeGameContainer(height: number) {\n this.updateFontSize(height);\n if (this._madeWithTextElement) {\n this._madeWithTextElement.style.fontSize = `${this._textFontSize}px`;\n }\n if (this._usernameTextElement) {\n this._usernameTextElement.style.fontSize = `${this._textFontSize}px`;\n }\n this.updateLogoSize(height);\n if (this._svgElement) {\n this._svgElement.setAttribute('height', this._logoHeight.toString());\n this._svgElement.setAttribute('width', this._logoWidth.toString());\n }\n this.updateBackgroundHeight(height);\n if (this._backgroundElement) {\n this._backgroundElement.style.height = `${this._backgroundHeight}px`;\n }\n this.updateMargin(height);\n if (this._linkElement) {\n this.updateElementMargins(this._linkElement);\n }\n }\n\n private addWatermarkToGameContainer(container: HTMLElement) {\n const gameContainerRectangle = container.getBoundingClientRect();\n this.updateFontSize(gameContainerRectangle.height);\n this.updateLogoSize(gameContainerRectangle.height);\n this.updateBackgroundHeight(gameContainerRectangle.height);\n\n this._containerElement = this.createDivContainer();\n this.createBackground();\n const textContainer = document.createElement('div');\n\n this.generateSVGLogo(gameContainerRectangle.height);\n this.createMadeWithTextElement();\n this.createUsernameTextElement();\n\n this._linkElement = this.createLinkElement();\n\n if (this._svgElement)\n this._containerElement.appendChild(this._svgElement);\n if (this._madeWithTextElement)\n textContainer.appendChild(this._madeWithTextElement);\n if (this._usernameTextElement)\n textContainer.appendChild(this._usernameTextElement);\n this._containerElement.appendChild(textContainer);\n if (this._backgroundElement)\n container.appendChild(this._backgroundElement);\n\n this._linkElement.append(this._containerElement);\n container.appendChild(this._linkElement);\n\n this.setupAnimations();\n }\n\n private createBackground() {\n this._backgroundElement = document.createElement('div');\n this._backgroundElement.setAttribute('id', 'watermark-background');\n this._backgroundElement.style.height = `${this._backgroundHeight}px`;\n this._backgroundElement.style.opacity = '0';\n if (this._placement.startsWith('top')) {\n this._backgroundElement.style.top = '0';\n this._backgroundElement.style.backgroundImage =\n 'linear-gradient(180deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )';\n } else {\n this._backgroundElement.style.bottom = '0';\n this._backgroundElement.style.backgroundImage =\n 'linear-gradient(0deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )';\n }\n }\n\n private setupAnimations() {\n // Necessary to trigger fade in transition\n requestAnimationFrame(() => {\n // Display the watermark\n setTimeout(() => {\n if (\n !this._containerElement ||\n !this._backgroundElement ||\n !this._linkElement\n )\n return;\n this._containerElement.style.opacity = '1';\n this._backgroundElement.style.opacity = '1';\n this._linkElement.style.pointerEvents = 'all';\n if (this._svgElement) this._svgElement.classList.add('spinning');\n }, this._fadeInDelayAfterGameLoaded * 1000);\n });\n\n // Hide the watermark\n this._fadeOutTimeout = setTimeout(() => {\n if (!this._containerElement || !this._backgroundElement) {\n return;\n }\n this._containerElement.style.opacity = '0';\n this._backgroundElement.style.opacity = '0';\n\n // Completely remove the watermark once the fade out duration has ended.\n this._hideTimeout = setTimeout(\n () => {\n if (\n !this._containerElement ||\n !this._backgroundElement ||\n !this._linkElement\n )\n return;\n this._linkElement.style.pointerEvents = 'none';\n this._containerElement.style.display = 'none';\n this._backgroundElement.style.display = 'none';\n if (this._resizeObserver) this._resizeObserver.disconnect();\n },\n // Deactivate all interaction possibilities with watermark at\n // the end of the animation to make sure it doesn't deactivate too early\n this._fadeDuration * 1000\n );\n }, (this._fadeInDelayAfterGameLoaded + this._displayDuration) * 1000);\n\n // Change text below watermark\n this._fadeOutFirstTextTimeout = setTimeout(() => {\n const { _madeWithTextElement, _usernameTextElement } = this;\n if (!_madeWithTextElement) return;\n\n // Do not hide madeWith text if there is no author username to display.\n if (_usernameTextElement) {\n _madeWithTextElement.style.opacity = '0';\n this._fadeInSecondTextTimeout = setTimeout(() => {\n _usernameTextElement.style.lineHeight = 'normal';\n _usernameTextElement.style.opacity = '1';\n _madeWithTextElement.style.lineHeight = '0';\n }, this._fadeDuration * 1000);\n }\n }, (this._fadeInDelayAfterGameLoaded + this._changeTextDelay) * 1000);\n }\n\n private createMadeWithTextElement() {\n this._madeWithTextElement = document.createElement('span');\n this._madeWithTextElement.innerText = 'Made with GDevelop';\n this._madeWithTextElement.style.fontSize = `${this._textFontSize}px`;\n }\n\n private createUsernameTextElement() {\n if (!this._authorUsername) return;\n this._usernameTextElement = document.createElement('span');\n this._usernameTextElement.innerText = `@${this._authorUsername}`;\n this._usernameTextElement.style.fontSize = `${this._textFontSize}px`;\n this._usernameTextElement.style.opacity = '0';\n this._usernameTextElement.style.lineHeight = '0';\n }\n\n private updateElementMargins(element: HTMLElement) {\n switch (this._placement) {\n case 'top-left':\n element.style.top = `${this._margin}px`;\n element.style.left = `${this._margin}px`;\n break;\n case 'top-right':\n element.style.top = `${this._margin}px`;\n element.style.right = `${this._margin}px`;\n break;\n case 'bottom-left':\n element.style.bottom = `${this._margin}px`;\n element.style.left = `${this._margin}px`;\n break;\n case 'bottom-right':\n element.style.bottom = `${this._margin}px`;\n element.style.right = `${this._margin}px`;\n break;\n case 'top':\n element.style.top = `${this._margin}px`;\n element.style.left = '50%';\n element.style.transform = 'translate(-50%, 0)';\n break;\n case 'bottom':\n default:\n element.style.bottom = `${this._margin}px`;\n element.style.left = '50%';\n element.style.transform = 'translate(-50%, 0)';\n break;\n }\n }\n\n private createLinkElement(): HTMLAnchorElement {\n const linkElement = document.createElement('a');\n linkElement.id = 'watermark-link';\n\n let targetUrl = this._authorUsername\n ? new URL(`https://gd.games/${this._authorUsername}`)\n : new URL('https://gd.games');\n\n if (this._isDevEnvironment) {\n targetUrl.searchParams.set('dev', 'true');\n } else {\n targetUrl.searchParams.set('utm_source', 'gdevelop-game');\n targetUrl.searchParams.set('utm_medium', 'game-watermark');\n\n if (this._gameId) {\n targetUrl.searchParams.set('utm_campaign', this._gameId);\n }\n }\n linkElement.href = targetUrl.href;\n linkElement.target = '_blank';\n\n this.updateElementMargins(linkElement);\n\n return linkElement;\n }\n\n private createDivContainer(): HTMLDivElement {\n const divContainer = document.createElement('div');\n divContainer.setAttribute('id', 'watermark');\n\n divContainer.style.opacity = '0';\n return divContainer;\n }\n\n private generateSVGLogo(height: number) {\n this._svgElement = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'svg'\n );\n\n this.updateLogoSize(height);\n this._svgElement.setAttribute('height', this._logoHeight.toString());\n this._svgElement.setAttribute('width', this._logoWidth.toString());\n this._svgElement.setAttribute('viewBox', '-2 -2 59 48');\n this._svgElement.setAttribute('fill', 'none');\n const path1 = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'path'\n );\n const path2 = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'path'\n );\n path1.setAttribute(\n 'd',\n 'M29.3447 33C25.1061 33 21.0255 31.8475 17.4207 29.3381C14.9081 27.5897 12 23.6418 12 16.9488C12 4.53178 18.3074 0 30.9827 0H53.8027L56 7.07232H32.7217C24.3558 7.07232 19.3813 7.72835 19.3813 16.9488C19.3813 19.9944 20.2354 22.1618 21.9933 23.574C24.9642 25.9612 30.7388 26.0628 34.2673 25.7208C34.2673 25.7208 35.715 21.0394 35.9534 20.2794C36.2327 19.3888 36.1104 19.1763 35.2392 19.1763C33.9808 19.1763 31.7185 19.1763 29.3175 19.1763C27.6349 19.1763 25.9818 18.3247 25.9818 16.2793C25.9818 14.3039 27.5198 13.1573 29.6281 13.1573C33.2786 13.1573 40.7969 13.1573 42.2041 13.1573C44.0489 13.1573 45.9315 13.4233 44.971 16.3601L39.8842 31.8734C39.8845 31.8738 35.7287 33 29.3447 33Z'\n );\n path2.setAttribute(\n 'd',\n 'M43.3039 35.3278C40.7894 37.1212 37.0648 38.1124 30.7449 38.1124C19.852 38.1124 11.8797 34.1251 8.62927 26.3952C7.0925 22.7415 7.24041 18.6005 7.24041 13H0.00129513C0.00129513 18.9056 -0.0984386 23.5361 1.45249 27.8011C5.51933 38.989 15.992 45 30.0606 45C43.6783 45 49.3213 41.0443 53 35.3278H43.3039Z'\n );\n this._svgElement.appendChild(path1);\n this._svgElement.appendChild(path2);\n }\n\n private addStyle() {\n const styleElement = document.createElement('style');\n styleElement.innerHTML = `\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 5% {\n transform: rotate(-10deg);\n animation-timing-function: ease-out;\n }\n\n 17% {\n transform: rotate(370deg);\n animation-timing-function: ease-in-out;\n }\n\n 20% {\n transform: rotate(360deg);\n animation-timing-function: ease-in-out;\n }\n\n 100% {\n transform: rotate(360deg);\n }\n }\n\n #watermark-background {\n position: absolute;\n pointer-events: none;\n width: 100%;\n transition-property: opacity;\n transition-duration: ${this._fadeDuration}s;\n }\n\n #watermark-link {\n all: unset;\n position: absolute;\n cursor: pointer;\n pointer-events: none;\n user-select: none;\n\n /* For Safari */\n -webkit-user-select: none;\n }\n\n #watermark {\n display: flex;\n flex-direction: row;\n align-items: center;\n transition-property: opacity;\n transition-duration: ${this._fadeDuration}s;\n transition-timing-function: ease-out;\n }\n\n #watermark > div {\n display: flex;\n flex-direction: column;\n margin-left: 5px;\n }\n\n #watermark span {\n color: white;\n font-family: 'Tahoma', 'Gill sans', 'Helvetica', 'Arial';\n font-size: ${this._textFontSize}px;\n transition: opacity;\n transition-duration: ${this._fadeDuration}s;\n\n /* For Safari */\n -webkit-transition: opacity;\n -webkit-transition-duration: ${this._fadeDuration}s;\n }\n\n #watermark svg.spinning {\n animation-name: spin;\n animation-direction: normal;\n animation-duration: 5s;\n animation-iteration-count: 3;\n animation-delay: 1.5s;\n }\n\n #watermark svg path {\n fill: white;\n }\n\n @media (hover: hover) {\n #watermark span {\n text-decoration: underline;\n text-decoration-style: solid;\n text-decoration-color: transparent;\n }\n\n #watermark:hover span {\n text-decoration-color: white;\n\n /* For Safari */\n -webkit-text-decoration-color: white;\n }\n }\n `;\n document.head.appendChild(styleElement);\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,OAAuB,CA6C5B,YACE,EACA,EACA,EACA,CAhCF,kBAAyC,KACzC,uBAA2C,KAC3C,wBAA4C,KAC5C,iBAAiC,KACjC,0BAA+C,KAC/C,0BAA+C,KAE/C,qBAAyC,KAGzC,sBAA2B,GAC3B,sBAA2B,EAC3B,iCAAsC,EACtC,mBAAwB,GAGxB,qBAAyC,KACzC,kBAAsC,KACtC,8BAAkD,KAClD,8BAAkD,KAGlD,mBAAwB,GACxB,gBAAqB,GACrB,iBAAsB,GACtB,uBAA4B,IAC5B,aAAkB,GAOhB,KAAK,QAAU,EAAK,MAAM,WAAW,YACrC,KAAK,cAAgB,EAAK,cAC1B,KAAK,gBAAkB,EAAgB,GACvC,KAAK,WAAa,EAAc,UAChC,KAAK,eAAiB,EAAc,cACpC,KAAK,kBAAoB,EAAK,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n export namespace watermark {\n export class RuntimeWatermark {\n _gameRenderer: RuntimeGameRenderer;\n _isDevEnvironment: boolean;\n\n // Configuration\n _placement:\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom'\n | 'top';\n _showAtStartup: boolean;\n _authorUsername: string | undefined;\n _gameId: string | undefined;\n\n // Dom elements\n _linkElement: HTMLAnchorElement | null = null;\n _containerElement: HTMLDivElement | null = null;\n _backgroundElement: HTMLDivElement | null = null;\n _svgElement: SVGElement | null = null;\n _usernameTextElement: HTMLSpanElement | null = null;\n _madeWithTextElement: HTMLSpanElement | null = null;\n\n _resizeObserver: ResizeObserver | null = null;\n\n // Durations in seconds\n _displayDuration: number = 20;\n _changeTextDelay: number = 7;\n _fadeInDelayAfterGameLoaded: number = 1;\n _fadeDuration: number = 0.3;\n\n // Timeout registration\n _fadeOutTimeout: NodeJS.Timeout | null = null;\n _hideTimeout: NodeJS.Timeout | null = null;\n _fadeOutFirstTextTimeout: NodeJS.Timeout | null = null;\n _fadeInSecondTextTimeout: NodeJS.Timeout | null = null;\n\n // Sizes\n _textFontSize: number = 14;\n _logoWidth: number = 56;\n _logoHeight: number = 45;\n _backgroundHeight: number = 150;\n _margin: number = 10;\n\n constructor(\n game: RuntimeGame,\n authorUsernames: Array<string>,\n watermarkData: WatermarkData\n ) {\n this._gameId = game._data.properties.projectUuid;\n this._gameRenderer = game.getRenderer();\n this._authorUsername = authorUsernames[0];\n this._placement = watermarkData.placement;\n this._showAtStartup = watermarkData.showWatermark;\n this._isDevEnvironment = game.isUsingGDevelopDevelopmentEnvironment();\n if (watermarkData.showWatermark) {\n this.addStyle();\n }\n }\n\n displayAtStartup() {\n if (this._showAtStartup) {\n this.display();\n }\n }\n\n display() {\n const gameContainer = this._gameRenderer.getDomElementContainer();\n if (gameContainer) {\n this.addWatermarkToGameContainer(gameContainer);\n this._resizeObserver = new ResizeObserver(() => {\n const gameContainerRectangle = gameContainer.getBoundingClientRect();\n this.onResizeGameContainer(gameContainerRectangle.height);\n });\n this._resizeObserver.observe(gameContainer);\n }\n }\n\n private updateFontSize(height: number) {\n this._textFontSize = Math.max(0.025 * height, 12);\n }\n private updateLogoSize(height: number) {\n this._logoWidth = Math.max(0.06 * height, 25);\n this._logoHeight = Math.round((45 / 56) * this._logoWidth);\n }\n private updateBackgroundHeight(height: number) {\n this._backgroundHeight = Math.max(0.13 * height, 45);\n }\n private updateMargin(height: number) {\n this._margin = Math.max(0.025 * height, 8);\n }\n\n private onResizeGameContainer(height: number) {\n this.updateFontSize(height);\n if (this._madeWithTextElement) {\n this._madeWithTextElement.style.fontSize = `${this._textFontSize}px`;\n }\n if (this._usernameTextElement) {\n this._usernameTextElement.style.fontSize = `${this._textFontSize}px`;\n }\n this.updateLogoSize(height);\n if (this._svgElement) {\n this._svgElement.setAttribute('height', this._logoHeight.toString());\n this._svgElement.setAttribute('width', this._logoWidth.toString());\n }\n this.updateBackgroundHeight(height);\n if (this._backgroundElement) {\n this._backgroundElement.style.height = `${this._backgroundHeight}px`;\n }\n this.updateMargin(height);\n if (this._linkElement) {\n this.updateElementMargins(this._linkElement);\n }\n }\n\n private addWatermarkToGameContainer(container: HTMLElement) {\n const gameContainerRectangle = container.getBoundingClientRect();\n this.updateFontSize(gameContainerRectangle.height);\n this.updateLogoSize(gameContainerRectangle.height);\n this.updateBackgroundHeight(gameContainerRectangle.height);\n\n this._containerElement = this.createDivContainer();\n this.createBackground();\n const textContainer = document.createElement('div');\n\n this.generateSVGLogo(gameContainerRectangle.height);\n this.createMadeWithTextElement();\n this.createUsernameTextElement();\n\n this._linkElement = this.createLinkElement();\n\n if (this._svgElement)\n this._containerElement.appendChild(this._svgElement);\n if (this._madeWithTextElement)\n textContainer.appendChild(this._madeWithTextElement);\n if (this._usernameTextElement)\n textContainer.appendChild(this._usernameTextElement);\n this._containerElement.appendChild(textContainer);\n if (this._backgroundElement)\n container.appendChild(this._backgroundElement);\n\n this._linkElement.append(this._containerElement);\n container.appendChild(this._linkElement);\n\n this.setupAnimations();\n }\n\n private createBackground() {\n this._backgroundElement = document.createElement('div');\n this._backgroundElement.setAttribute('id', 'watermark-background');\n this._backgroundElement.style.height = `${this._backgroundHeight}px`;\n this._backgroundElement.style.opacity = '0';\n if (this._placement.startsWith('top')) {\n this._backgroundElement.style.top = '0';\n this._backgroundElement.style.backgroundImage =\n 'linear-gradient(180deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )';\n } else {\n this._backgroundElement.style.bottom = '0';\n this._backgroundElement.style.backgroundImage =\n 'linear-gradient(0deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )';\n }\n }\n\n private setupAnimations() {\n // Necessary to trigger fade in transition\n requestAnimationFrame(() => {\n // Display the watermark\n setTimeout(() => {\n if (\n !this._containerElement ||\n !this._backgroundElement ||\n !this._linkElement\n )\n return;\n this._containerElement.style.opacity = '1';\n this._backgroundElement.style.opacity = '1';\n this._linkElement.style.pointerEvents = 'all';\n if (this._svgElement) this._svgElement.classList.add('spinning');\n }, this._fadeInDelayAfterGameLoaded * 1000);\n });\n\n // Hide the watermark\n this._fadeOutTimeout = setTimeout(() => {\n if (!this._containerElement || !this._backgroundElement) {\n return;\n }\n this._containerElement.style.opacity = '0';\n this._backgroundElement.style.opacity = '0';\n\n // Completely remove the watermark once the fade out duration has ended.\n this._hideTimeout = setTimeout(\n () => {\n if (\n !this._containerElement ||\n !this._backgroundElement ||\n !this._linkElement\n )\n return;\n this._linkElement.style.pointerEvents = 'none';\n this._containerElement.style.display = 'none';\n this._backgroundElement.style.display = 'none';\n if (this._resizeObserver) this._resizeObserver.disconnect();\n },\n // Deactivate all interaction possibilities with watermark at\n // the end of the animation to make sure it doesn't deactivate too early\n this._fadeDuration * 1000\n );\n }, (this._fadeInDelayAfterGameLoaded + this._displayDuration) * 1000);\n\n // Change text below watermark\n this._fadeOutFirstTextTimeout = setTimeout(() => {\n const { _madeWithTextElement, _usernameTextElement } = this;\n if (!_madeWithTextElement) return;\n\n // Do not hide madeWith text if there is no author username to display.\n if (_usernameTextElement) {\n _madeWithTextElement.style.opacity = '0';\n this._fadeInSecondTextTimeout = setTimeout(() => {\n _usernameTextElement.style.lineHeight = 'normal';\n _usernameTextElement.style.opacity = '1';\n _madeWithTextElement.style.lineHeight = '0';\n }, this._fadeDuration * 1000);\n }\n }, (this._fadeInDelayAfterGameLoaded + this._changeTextDelay) * 1000);\n }\n\n private createMadeWithTextElement() {\n this._madeWithTextElement = document.createElement('span');\n this._madeWithTextElement.innerText = 'Made with GDevelop';\n this._madeWithTextElement.style.fontSize = `${this._textFontSize}px`;\n }\n\n private createUsernameTextElement() {\n if (!this._authorUsername) return;\n this._usernameTextElement = document.createElement('span');\n this._usernameTextElement.innerText = `@${this._authorUsername}`;\n this._usernameTextElement.style.fontSize = `${this._textFontSize}px`;\n this._usernameTextElement.style.opacity = '0';\n this._usernameTextElement.style.lineHeight = '0';\n }\n\n private updateElementMargins(element: HTMLElement) {\n switch (this._placement) {\n case 'top-left':\n element.style.top = `${this._margin}px`;\n element.style.left = `${this._margin}px`;\n break;\n case 'top-right':\n element.style.top = `${this._margin}px`;\n element.style.right = `${this._margin}px`;\n break;\n case 'bottom-left':\n element.style.bottom = `${this._margin}px`;\n element.style.left = `${this._margin}px`;\n break;\n case 'bottom-right':\n element.style.bottom = `${this._margin}px`;\n element.style.right = `${this._margin}px`;\n break;\n case 'top':\n element.style.top = `${this._margin}px`;\n element.style.left = '50%';\n element.style.transform = 'translate(-50%, 0)';\n break;\n case 'bottom':\n default:\n element.style.bottom = `${this._margin}px`;\n element.style.left = '50%';\n element.style.transform = 'translate(-50%, 0)';\n break;\n }\n }\n\n private createLinkElement(): HTMLAnchorElement {\n const linkElement = document.createElement('a');\n linkElement.id = 'watermark-link';\n\n let targetUrl = this._authorUsername\n ? new URL(`https://gd.games/${this._authorUsername}`)\n : new URL('https://gd.games');\n\n if (this._isDevEnvironment) {\n targetUrl.searchParams.set('dev', 'true');\n } else {\n targetUrl.searchParams.set('utm_source', 'gdevelop-game');\n targetUrl.searchParams.set('utm_medium', 'game-watermark');\n\n if (this._gameId) {\n targetUrl.searchParams.set('utm_campaign', this._gameId);\n }\n }\n linkElement.href = targetUrl.href;\n linkElement.target = '_blank';\n\n this.updateElementMargins(linkElement);\n\n return linkElement;\n }\n\n private createDivContainer(): HTMLDivElement {\n const divContainer = document.createElement('div');\n divContainer.setAttribute('id', 'watermark');\n\n divContainer.style.opacity = '0';\n return divContainer;\n }\n\n private generateSVGLogo(height: number) {\n this._svgElement = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'svg'\n );\n\n this.updateLogoSize(height);\n this._svgElement.setAttribute('height', this._logoHeight.toString());\n this._svgElement.setAttribute('width', this._logoWidth.toString());\n this._svgElement.setAttribute('viewBox', '-2 -2 59 48');\n this._svgElement.setAttribute('fill', 'none');\n const path1 = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'path'\n );\n const path2 = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'path'\n );\n path1.setAttribute(\n 'd',\n 'M29.3447 33C25.1061 33 21.0255 31.8475 17.4207 29.3381C14.9081 27.5897 12 23.6418 12 16.9488C12 4.53178 18.3074 0 30.9827 0H53.8027L56 7.07232H32.7217C24.3558 7.07232 19.3813 7.72835 19.3813 16.9488C19.3813 19.9944 20.2354 22.1618 21.9933 23.574C24.9642 25.9612 30.7388 26.0628 34.2673 25.7208C34.2673 25.7208 35.715 21.0394 35.9534 20.2794C36.2327 19.3888 36.1104 19.1763 35.2392 19.1763C33.9808 19.1763 31.7185 19.1763 29.3175 19.1763C27.6349 19.1763 25.9818 18.3247 25.9818 16.2793C25.9818 14.3039 27.5198 13.1573 29.6281 13.1573C33.2786 13.1573 40.7969 13.1573 42.2041 13.1573C44.0489 13.1573 45.9315 13.4233 44.971 16.3601L39.8842 31.8734C39.8845 31.8738 35.7287 33 29.3447 33Z'\n );\n path2.setAttribute(\n 'd',\n 'M43.3039 35.3278C40.7894 37.1212 37.0648 38.1124 30.7449 38.1124C19.852 38.1124 11.8797 34.1251 8.62927 26.3952C7.0925 22.7415 7.24041 18.6005 7.24041 13H0.00129513C0.00129513 18.9056 -0.0984386 23.5361 1.45249 27.8011C5.51933 38.989 15.992 45 30.0606 45C43.6783 45 49.3213 41.0443 53 35.3278H43.3039Z'\n );\n this._svgElement.appendChild(path1);\n this._svgElement.appendChild(path2);\n }\n\n private addStyle() {\n const styleElement = document.createElement('style');\n styleElement.innerHTML = `\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 5% {\n transform: rotate(-10deg);\n animation-timing-function: ease-out;\n }\n\n 17% {\n transform: rotate(370deg);\n animation-timing-function: ease-in-out;\n }\n\n 20% {\n transform: rotate(360deg);\n animation-timing-function: ease-in-out;\n }\n\n 100% {\n transform: rotate(360deg);\n }\n }\n\n #watermark-background {\n position: absolute;\n pointer-events: none;\n width: 100%;\n transition-property: opacity;\n transition-duration: ${this._fadeDuration}s;\n }\n\n #watermark-link {\n all: unset;\n position: absolute;\n cursor: pointer;\n pointer-events: none;\n user-select: none;\n\n /* For Safari */\n -webkit-user-select: none;\n }\n\n #watermark {\n display: flex;\n flex-direction: row;\n align-items: center;\n transition-property: opacity;\n transition-duration: ${this._fadeDuration}s;\n transition-timing-function: ease-out;\n }\n\n #watermark > div {\n display: flex;\n flex-direction: column;\n margin-left: 5px;\n }\n\n #watermark span {\n color: white;\n font-family: 'Tahoma', 'Gill sans', 'Helvetica', 'Arial';\n font-size: ${this._textFontSize}px;\n transition: opacity;\n transition-duration: ${this._fadeDuration}s;\n\n /* For Safari */\n -webkit-transition: opacity;\n -webkit-transition-duration: ${this._fadeDuration}s;\n }\n\n #watermark svg.spinning {\n animation-name: spin;\n animation-direction: normal;\n animation-duration: 5s;\n animation-iteration-count: 3;\n animation-delay: 1.5s;\n }\n\n #watermark svg path {\n fill: white;\n }\n\n @media (hover: hover) {\n #watermark span {\n text-decoration: underline;\n text-decoration-style: solid;\n text-decoration-color: transparent;\n }\n\n #watermark:hover span {\n text-decoration-color: white;\n\n /* For Safari */\n -webkit-text-decoration-color: white;\n }\n }\n `;\n document.head.appendChild(styleElement);\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,OAAuB,CA6C5B,YACE,EACA,EACA,EACA,CAhCF,kBAAyC,KACzC,uBAA2C,KAC3C,wBAA4C,KAC5C,iBAAiC,KACjC,0BAA+C,KAC/C,0BAA+C,KAE/C,qBAAyC,KAGzC,sBAA2B,GAC3B,sBAA2B,EAC3B,iCAAsC,EACtC,mBAAwB,GAGxB,qBAAyC,KACzC,kBAAsC,KACtC,8BAAkD,KAClD,8BAAkD,KAGlD,mBAAwB,GACxB,gBAAqB,GACrB,iBAAsB,GACtB,uBAA4B,IAC5B,aAAkB,GAOhB,KAAK,QAAU,EAAK,MAAM,WAAW,YACrC,KAAK,cAAgB,EAAK,cAC1B,KAAK,gBAAkB,EAAgB,GACvC,KAAK,WAAa,EAAc,UAChC,KAAK,eAAiB,EAAc,cACpC,KAAK,kBAAoB,EAAK,wCAC1B,EAAc,eAChB,KAAK,WAIT,kBAAmB,CACjB,AAAI,KAAK,gBACP,KAAK,UAIT,SAAU,CACR,KAAM,GAAgB,KAAK,cAAc,yBACzC,AAAI,GACF,MAAK,4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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAaf,KAAK;AAAA;AAAA,iCAEK,KAAK;AAAA;AAAA;AAAA;AAAA,yCAIG,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UA8BtC,SAAS,KAAK,YAAY,IAxbvB,EAAM,qBADE,mCADT",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
1
|
+
var gdjs;(function(o){const r=new o.Logger("Scene stack"),c=new o.Logger("Multiplayer - Debug");class h{constructor(t){this._stack=[];this._wasFirstSceneLoaded=!1;this._isNextLayoutLoading=!1;this._sceneStackSyncDataToApply=null;this._wasDisposed=!1;if(!t)throw"SceneStack must be constructed with a gdjs.RuntimeGame.";this._runtimeGame=t}onGameResolutionResized(){for(let t=0;t<this._stack.length;++t)this._stack[t].onGameResolutionResized()}step(t){if(this._throwIfDisposed(),this._isNextLayoutLoading||this._stack.length===0)return!1;if(this.applyUpdateFromNetworkSyncDataIfAny())return c.info("Scene stack has been updated from network sync data, skipping step."),!0;const e=this._stack[this._stack.length-1];if(e.renderAndStep(t)){const n=e.getRequestedChange();if(n===o.SceneChangeRequest.STOP_GAME)return this._runtimeGame.getRenderer().stopGame(),!0;n===o.SceneChangeRequest.POP_SCENE?this.pop():n===o.SceneChangeRequest.PUSH_SCENE?this.push(e.getRequestedScene()):n===o.SceneChangeRequest.REPLACE_SCENE?this.replace(e.getRequestedScene()):n===o.SceneChangeRequest.CLEAR_SCENES?this.replace(e.getRequestedScene(),!0):r.error("Unrecognized change in scene stack: "+n)}return!0}renderWithoutStep(){return this._throwIfDisposed(),this._stack.length===0?!1:(this._stack[this._stack.length-1].render(),!0)}pop(t=1){this._throwIfDisposed();let s=!1;for(let e=0;e<t&&!(this._stack.length<=1);++e){s=!0;const n=this._stack.pop();if(!n)return;n.unloadScene()}if(s){const e=this._stack[this._stack.length-1];e&&e.onResume()}}push(t,s){this._throwIfDisposed();const e=this._stack[this._stack.length-1];return e&&e.onPause(),this._runtimeGame.areSceneAssetsReady(t)?this._loadNewScene(t,s):(this._isNextLayoutLoading=!0,this._runtimeGame.loadSceneAssets(t).then(()=>{this._loadNewScene(t),this._isNextLayoutLoading=!1}),null)}_loadNewScene(t,s){this._throwIfDisposed();const e=new o.RuntimeScene(this._runtimeGame);if(e.loadFromScene(this._runtimeGame.getSceneAndExtensionsData(t)),this._wasFirstSceneLoaded=!0,s){const n=this._runtimeGame.getExternalLayoutData(s);n&&e.createObjectsFrom(n.instances,0,0,0,!0)}return this._stack.push(e),e}replace(t,s){if(this._throwIfDisposed(),s)for(;this._stack.length!==0;){let e=this._stack.pop();e&&e.unloadScene()}else if(this._stack.length!==0){let e=this._stack.pop();e&&e.unloadScene()}return this.push(t)}getCurrentScene(){return this._throwIfDisposed(),this._stack.length===0?null:this._stack[this._stack.length-1]}wasFirstSceneLoaded(){return this._wasFirstSceneLoaded}getAllSceneNames(){return this._throwIfDisposed(),this._stack.map(t=>t.getName())}getNetworkSyncData(t){const s=t.playerNumber,e=t.isHost;if(s!==void 0&&!e)return null;const n=[];for(let a=0;a<this._stack.length;++a){const i=this._stack[a];n.push({name:i.getName(),networkId:i.getOrCreateNetworkId()})}return n}updateFromNetworkSyncData(t){this._sceneStackSyncDataToApply=t}applyUpdateFromNetworkSyncDataIfAny(){this._throwIfDisposed();const t=this._sceneStackSyncDataToApply;let s=!1;if(!t)return s;this._sceneStackSyncDataToApply=null;for(let e=0;e<t.length;++e){const n=t[e],a=this._stack[e];if(!a){c.info(`Scene at position ${e} with name ${n.name} is missing from the stack, adding it.`);const i=this.push(n.name);i&&(i.networkId=n.networkId),s=!0;continue}if(a.getName()!==n.name){c.info(`Scene at position ${e} and name ${a.getName()} is not the same as the expected ${n.name}, replacing.`);const i=this.replace(n.name,!0);i&&(i.networkId=n.networkId),s=!0;continue}if(!a.networkId&&n.networkId&&n.name===a.getName()){c.info(`Scene at position ${e} and name ${a.getName()} has no networkId, let's assume it's the right one and reconcile it with the id ${n.networkId}.`),a.networkId=n.networkId;continue}if(a.networkId!==n.networkId){c.info(`Scene at position ${e} and name ${a.getName()} has a different networkId ${a.networkId} than the expected ${n.networkId}, replacing.`);const i=this.replace(n.name,!1);i&&(i.networkId=n.networkId),s=!0;continue}}if(this._stack.length>t.length){const e=this._stack.length-t.length;this.pop(e),s=!0}return s}dispose(){for(const t of this._stack)t.unloadScene();this._stack.length=0,this._wasDisposed=!0}_throwIfDisposed(){if(this._wasDisposed)throw"The scene stack has been disposed and should not be used anymore."}}o.SceneStack=h})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=scenestack.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/scenestack.ts"],
|
|
4
|
-
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Scene stack');\n const debugLogger = new gdjs.Logger('Multiplayer - Debug');\n\n /**\n * Hold the stack of scenes ({@link gdjs.RuntimeScene}) being played.\n */\n export class SceneStack {\n _runtimeGame: gdjs.RuntimeGame;\n _stack: gdjs.RuntimeScene[] = [];\n _wasFirstSceneLoaded: boolean = false;\n _isNextLayoutLoading: boolean = false;\n _sceneStackSyncDataToApply: SceneStackNetworkSyncData | null = null;\n\n /**\n * @param runtimeGame The runtime game that is using the scene stack\n */\n constructor(runtimeGame: gdjs.RuntimeGame) {\n if (!runtimeGame) {\n throw 'SceneStack must be constructed with a gdjs.RuntimeGame.';\n }\n this._runtimeGame = runtimeGame;\n }\n\n /**\n * Called by the RuntimeGame when the game resolution is changed.\n * Useful to notify scene and layers that resolution is changed, as they\n * might be caching it.\n */\n onGameResolutionResized(): void {\n for (let i = 0; i < this._stack.length; ++i) {\n this._stack[i].onGameResolutionResized();\n }\n }\n\n step(elapsedTime: float): boolean {\n if (this._isNextLayoutLoading || this._stack.length === 0) {\n return false;\n }\n\n const hasMadeChangeToStack = this.applyUpdateFromNetworkSyncDataIfAny();\n if (hasMadeChangeToStack) {\n debugLogger.info(\n 'Scene stack has been updated from network sync data, skipping step.'\n );\n // If we have made changes to the stack as part of the network sync,\n // we trust the network to be the source of truth for the scene stack,\n // and skip the scene rendering (and so any other request to change the scene stack from it)\n return true;\n }\n\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene.renderAndStep(elapsedTime)) {\n const request = currentScene.getRequestedChange();\n\n // A scene change was requested by the current scene.\n if (request === gdjs.SceneChangeRequest.STOP_GAME) {\n this._runtimeGame.getRenderer().stopGame();\n return true;\n } else if (request === gdjs.SceneChangeRequest.POP_SCENE) {\n this.pop();\n } else if (request === gdjs.SceneChangeRequest.PUSH_SCENE) {\n this.push(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.REPLACE_SCENE) {\n this.replace(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.CLEAR_SCENES) {\n this.replace(currentScene.getRequestedScene(), true);\n } else {\n logger.error('Unrecognized change in scene stack: ' + request);\n }\n }\n\n return true;\n }\n\n renderWithoutStep(): boolean {\n if (this._stack.length === 0) {\n return false;\n }\n const currentScene = this._stack[this._stack.length - 1];\n currentScene.render();\n return true;\n }\n\n pop(popCount = 1): void {\n let hasDoneAnyChanges = false;\n for (let i = 0; i < popCount; ++i) {\n if (this._stack.length <= 1) {\n break;\n }\n\n // Unload the current scene\n hasDoneAnyChanges = true;\n const scene = this._stack.pop();\n if (!scene) {\n return;\n }\n scene.unloadScene();\n }\n\n // Tell the new current scene it's being resumed\n if (hasDoneAnyChanges) {\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onResume();\n }\n }\n }\n\n /**\n * Pause the scene currently being played and start the new scene that is specified.\n * If `externalLayoutName` is set, also instantiate the objects from this external layout.\n */\n push(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene | null {\n // Tell the scene it's being paused\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onPause();\n }\n\n // Avoid a risk of displaying an intermediate loading screen\n // during 1 frame.\n if (this._runtimeGame.areSceneAssetsReady(newSceneName)) {\n return this._loadNewScene(newSceneName, externalLayoutName);\n }\n\n this._isNextLayoutLoading = true;\n this._runtimeGame.loadSceneAssets(newSceneName).then(() => {\n this._loadNewScene(newSceneName);\n this._isNextLayoutLoading = false;\n });\n return null;\n }\n\n private _loadNewScene(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene {\n // Load the new one\n const newScene = new gdjs.RuntimeScene(this._runtimeGame);\n newScene.loadFromScene(\n this._runtimeGame.getSceneAndExtensionsData(newSceneName)\n );\n this._wasFirstSceneLoaded = true;\n\n // Optionally create the objects from an external layout.\n if (externalLayoutName) {\n const externalLayoutData = this._runtimeGame.getExternalLayoutData(\n externalLayoutName\n );\n if (externalLayoutData) {\n newScene.createObjectsFrom(\n externalLayoutData.instances,\n 0,\n 0,\n 0,\n /*trackByPersistentUuid=*/\n true\n );\n }\n }\n this._stack.push(newScene);\n return newScene;\n }\n\n /**\n * Start the specified scene, replacing the one currently being played.\n * If `clear` is set to true, all running scenes are also removed from the stack of scenes.\n */\n replace(newSceneName: string, clear?: boolean): gdjs.RuntimeScene | null {\n if (!!clear) {\n // Unload all the scenes\n while (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n } else {\n // Unload the current scene\n if (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n }\n return this.push(newSceneName);\n }\n\n /**\n * Return the current gdjs.RuntimeScene being played, or null if none is run.\n */\n getCurrentScene(): gdjs.RuntimeScene | null {\n if (this._stack.length === 0) {\n return null;\n }\n return this._stack[this._stack.length - 1];\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._wasFirstSceneLoaded;\n }\n\n getAllSceneNames(): Array<string> {\n return this._stack.map((scene) => scene.getName());\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): SceneStackNetworkSyncData | null {\n const syncedPlayerNumber = syncOptions.playerNumber;\n const isHost = syncOptions.isHost;\n if (syncedPlayerNumber !== undefined && !isHost) {\n // If we are getting sync data of a specific player,\n // and they are not the host, we don't sync the scene stack.\n return null;\n }\n\n // If we are the host, we can take charge of\n // generating a networkId for each scene if they don't have one.\n // They will be reconciled on the other players' games.\n const sceneStackSyncData: SceneStackSceneNetworkSyncData[] = [];\n for (let i = 0; i < this._stack.length; ++i) {\n const scene = this._stack[i];\n sceneStackSyncData.push({\n name: scene.getName(),\n networkId: scene.getOrCreateNetworkId(),\n });\n }\n return sceneStackSyncData;\n }\n\n updateFromNetworkSyncData(\n sceneStackSyncData: SceneStackNetworkSyncData\n ): void {\n // Don't directly apply changes to the scene stack. Store them and they will be applied\n // in `step` (i.e: at the end of a frame). Otherwise, we would risk doing operations on the scene\n // stack, like creating a new scene or unloading a scene, while being inside the `renderAndStep` method\n // of the current scene.\n this._sceneStackSyncDataToApply = sceneStackSyncData;\n }\n\n applyUpdateFromNetworkSyncDataIfAny(): boolean {\n const sceneStackSyncData = this._sceneStackSyncDataToApply;\n let hasMadeChangeToStack = false;\n if (!sceneStackSyncData) return hasMadeChangeToStack;\n\n this._sceneStackSyncDataToApply = null;\n\n // If this method is called, we are a client.\n // We trust the host to be the source of truth for the scene stack.\n // So we loop through the scenes in the stack given by the host and either:\n // - Set the networkId of the scene if it's already in the stack at the right place\n // - Add the scene to the stack if it's not there, and set its networkId\n // - Remove any scenes that are in the stack but not in the data given by the host\n for (let i = 0; i < sceneStackSyncData.length; ++i) {\n const sceneSyncData = sceneStackSyncData[i];\n const sceneAtThisPositionInOurStack = this._stack[i];\n if (!sceneAtThisPositionInOurStack) {\n debugLogger.info(\n `Scene at position ${i} with name ${sceneSyncData.name} is missing from the stack, adding it.`\n );\n // We have fewer scenes in the stack than the host, let's add the scene.\n const newScene = this.push(sceneSyncData.name);\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (sceneAtThisPositionInOurStack.getName() !== sceneSyncData.name) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} is not the same as the expected ${\n sceneSyncData.name\n }, replacing.`\n );\n // The scene does not correspond to the scene at this position in our stack\n // Let's unload everything after this position to recreate the stack.\n const newScene = this.replace(\n sceneSyncData.name,\n true // Clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n !sceneAtThisPositionInOurStack.networkId &&\n sceneSyncData.networkId &&\n sceneSyncData.name === sceneAtThisPositionInOurStack.getName()\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has no networkId, let's assume it's the right one and reconcile it with the id ${\n sceneSyncData.networkId\n }.`\n );\n // The scene is in the stack but has no networkId,\n // this can happen at the start of the game on a player that is not the host,\n // or if a player switch to another scene before the host has sent the scene stack.\n // Let's set the networkId of the scene.\n sceneAtThisPositionInOurStack.networkId = sceneSyncData.networkId;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n sceneAtThisPositionInOurStack.networkId !== sceneSyncData.networkId\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has a different networkId ${\n sceneAtThisPositionInOurStack.networkId\n } than the expected ${sceneSyncData.networkId}, replacing.`\n );\n // The scene is in the stack but has a different networkId\n // This can happen if the host has restarted the scene\n // We can't just update the networkId of the scene in the stack\n // We need to replace it with a new scene\n const newScene = this.replace(\n sceneSyncData.name,\n false // Don't clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n // The scene is in the stack and has the right networkId.\n // Nothing to do, just continue to the next scene in the stack received from the host.\n }\n\n // Pop any scene not on the host.\n // In the future, we could avoid to pop scenes if they are not set to be synchronized.\n if (this._stack.length > sceneStackSyncData.length) {\n const popCount = this._stack.length - sceneStackSyncData.length;\n this.pop(popCount);\n hasMadeChangeToStack = true;\n }\n\n return hasMadeChangeToStack;\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,eACzB,EAAc,GAAI,GAAK,OAAO,uBAK7B,OAAiB,
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Scene stack');\n const debugLogger = new gdjs.Logger('Multiplayer - Debug');\n\n /**\n * Hold the stack of scenes ({@link gdjs.RuntimeScene}) being played.\n */\n export class SceneStack {\n _runtimeGame: gdjs.RuntimeGame;\n _stack: gdjs.RuntimeScene[] = [];\n _wasFirstSceneLoaded: boolean = false;\n _isNextLayoutLoading: boolean = false;\n _sceneStackSyncDataToApply: SceneStackNetworkSyncData | null = null;\n _wasDisposed: boolean = false;\n\n /**\n * @param runtimeGame The runtime game that is using the scene stack\n */\n constructor(runtimeGame: gdjs.RuntimeGame) {\n if (!runtimeGame) {\n throw 'SceneStack must be constructed with a gdjs.RuntimeGame.';\n }\n this._runtimeGame = runtimeGame;\n }\n\n /**\n * Called by the RuntimeGame when the game resolution is changed.\n * Useful to notify scene and layers that resolution is changed, as they\n * might be caching it.\n */\n onGameResolutionResized(): void {\n for (let i = 0; i < this._stack.length; ++i) {\n this._stack[i].onGameResolutionResized();\n }\n }\n\n step(elapsedTime: float): boolean {\n this._throwIfDisposed();\n if (this._isNextLayoutLoading || this._stack.length === 0) {\n return false;\n }\n\n const hasMadeChangeToStack = this.applyUpdateFromNetworkSyncDataIfAny();\n if (hasMadeChangeToStack) {\n debugLogger.info(\n 'Scene stack has been updated from network sync data, skipping step.'\n );\n // If we have made changes to the stack as part of the network sync,\n // we trust the network to be the source of truth for the scene stack,\n // and skip the scene rendering (and so any other request to change the scene stack from it)\n return true;\n }\n\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene.renderAndStep(elapsedTime)) {\n const request = currentScene.getRequestedChange();\n\n // A scene change was requested by the current scene.\n if (request === gdjs.SceneChangeRequest.STOP_GAME) {\n this._runtimeGame.getRenderer().stopGame();\n return true;\n } else if (request === gdjs.SceneChangeRequest.POP_SCENE) {\n this.pop();\n } else if (request === gdjs.SceneChangeRequest.PUSH_SCENE) {\n this.push(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.REPLACE_SCENE) {\n this.replace(currentScene.getRequestedScene());\n } else if (request === gdjs.SceneChangeRequest.CLEAR_SCENES) {\n this.replace(currentScene.getRequestedScene(), true);\n } else {\n logger.error('Unrecognized change in scene stack: ' + request);\n }\n }\n\n return true;\n }\n\n renderWithoutStep(): boolean {\n this._throwIfDisposed();\n\n if (this._stack.length === 0) {\n return false;\n }\n const currentScene = this._stack[this._stack.length - 1];\n currentScene.render();\n return true;\n }\n\n pop(popCount = 1): void {\n this._throwIfDisposed();\n\n let hasDoneAnyChanges = false;\n for (let i = 0; i < popCount; ++i) {\n if (this._stack.length <= 1) {\n break;\n }\n\n // Unload the current scene\n hasDoneAnyChanges = true;\n const scene = this._stack.pop();\n if (!scene) {\n return;\n }\n scene.unloadScene();\n }\n\n // Tell the new current scene it's being resumed\n if (hasDoneAnyChanges) {\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onResume();\n }\n }\n }\n\n /**\n * Pause the scene currently being played and start the new scene that is specified.\n * If `externalLayoutName` is set, also instantiate the objects from this external layout.\n */\n push(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene | null {\n this._throwIfDisposed();\n\n // Tell the scene it's being paused\n const currentScene = this._stack[this._stack.length - 1];\n if (currentScene) {\n currentScene.onPause();\n }\n\n // Avoid a risk of displaying an intermediate loading screen\n // during 1 frame.\n if (this._runtimeGame.areSceneAssetsReady(newSceneName)) {\n return this._loadNewScene(newSceneName, externalLayoutName);\n }\n\n this._isNextLayoutLoading = true;\n this._runtimeGame.loadSceneAssets(newSceneName).then(() => {\n this._loadNewScene(newSceneName);\n this._isNextLayoutLoading = false;\n });\n return null;\n }\n\n private _loadNewScene(\n newSceneName: string,\n externalLayoutName?: string\n ): gdjs.RuntimeScene {\n this._throwIfDisposed();\n\n // Load the new one\n const newScene = new gdjs.RuntimeScene(this._runtimeGame);\n newScene.loadFromScene(\n this._runtimeGame.getSceneAndExtensionsData(newSceneName)\n );\n this._wasFirstSceneLoaded = true;\n\n // Optionally create the objects from an external layout.\n if (externalLayoutName) {\n const externalLayoutData = this._runtimeGame.getExternalLayoutData(\n externalLayoutName\n );\n if (externalLayoutData) {\n newScene.createObjectsFrom(\n externalLayoutData.instances,\n 0,\n 0,\n 0,\n /*trackByPersistentUuid=*/\n true\n );\n }\n }\n this._stack.push(newScene);\n return newScene;\n }\n\n /**\n * Start the specified scene, replacing the one currently being played.\n * If `clear` is set to true, all running scenes are also removed from the stack of scenes.\n */\n replace(newSceneName: string, clear?: boolean): gdjs.RuntimeScene | null {\n this._throwIfDisposed();\n if (!!clear) {\n // Unload all the scenes\n while (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n } else {\n // Unload the current scene\n if (this._stack.length !== 0) {\n let scene = this._stack.pop();\n if (scene) {\n scene.unloadScene();\n }\n }\n }\n return this.push(newSceneName);\n }\n\n /**\n * Return the current gdjs.RuntimeScene being played, or null if none is run.\n */\n getCurrentScene(): gdjs.RuntimeScene | null {\n this._throwIfDisposed();\n if (this._stack.length === 0) {\n return null;\n }\n return this._stack[this._stack.length - 1];\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._wasFirstSceneLoaded;\n }\n\n getAllSceneNames(): Array<string> {\n this._throwIfDisposed();\n return this._stack.map((scene) => scene.getName());\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): SceneStackNetworkSyncData | null {\n const syncedPlayerNumber = syncOptions.playerNumber;\n const isHost = syncOptions.isHost;\n if (syncedPlayerNumber !== undefined && !isHost) {\n // If we are getting sync data of a specific player,\n // and they are not the host, we don't sync the scene stack.\n return null;\n }\n\n // If we are the host, we can take charge of\n // generating a networkId for each scene if they don't have one.\n // They will be reconciled on the other players' games.\n const sceneStackSyncData: SceneStackSceneNetworkSyncData[] = [];\n for (let i = 0; i < this._stack.length; ++i) {\n const scene = this._stack[i];\n sceneStackSyncData.push({\n name: scene.getName(),\n networkId: scene.getOrCreateNetworkId(),\n });\n }\n return sceneStackSyncData;\n }\n\n updateFromNetworkSyncData(\n sceneStackSyncData: SceneStackNetworkSyncData\n ): void {\n // Don't directly apply changes to the scene stack. Store them and they will be applied\n // in `step` (i.e: at the end of a frame). Otherwise, we would risk doing operations on the scene\n // stack, like creating a new scene or unloading a scene, while being inside the `renderAndStep` method\n // of the current scene.\n this._sceneStackSyncDataToApply = sceneStackSyncData;\n }\n\n applyUpdateFromNetworkSyncDataIfAny(): boolean {\n this._throwIfDisposed();\n const sceneStackSyncData = this._sceneStackSyncDataToApply;\n let hasMadeChangeToStack = false;\n if (!sceneStackSyncData) return hasMadeChangeToStack;\n\n this._sceneStackSyncDataToApply = null;\n\n // If this method is called, we are a client.\n // We trust the host to be the source of truth for the scene stack.\n // So we loop through the scenes in the stack given by the host and either:\n // - Set the networkId of the scene if it's already in the stack at the right place\n // - Add the scene to the stack if it's not there, and set its networkId\n // - Remove any scenes that are in the stack but not in the data given by the host\n for (let i = 0; i < sceneStackSyncData.length; ++i) {\n const sceneSyncData = sceneStackSyncData[i];\n const sceneAtThisPositionInOurStack = this._stack[i];\n if (!sceneAtThisPositionInOurStack) {\n debugLogger.info(\n `Scene at position ${i} with name ${sceneSyncData.name} is missing from the stack, adding it.`\n );\n // We have fewer scenes in the stack than the host, let's add the scene.\n const newScene = this.push(sceneSyncData.name);\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (sceneAtThisPositionInOurStack.getName() !== sceneSyncData.name) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} is not the same as the expected ${\n sceneSyncData.name\n }, replacing.`\n );\n // The scene does not correspond to the scene at this position in our stack\n // Let's unload everything after this position to recreate the stack.\n const newScene = this.replace(\n sceneSyncData.name,\n true // Clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n !sceneAtThisPositionInOurStack.networkId &&\n sceneSyncData.networkId &&\n sceneSyncData.name === sceneAtThisPositionInOurStack.getName()\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has no networkId, let's assume it's the right one and reconcile it with the id ${\n sceneSyncData.networkId\n }.`\n );\n // The scene is in the stack but has no networkId,\n // this can happen at the start of the game on a player that is not the host,\n // or if a player switch to another scene before the host has sent the scene stack.\n // Let's set the networkId of the scene.\n sceneAtThisPositionInOurStack.networkId = sceneSyncData.networkId;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n if (\n sceneAtThisPositionInOurStack.networkId !== sceneSyncData.networkId\n ) {\n debugLogger.info(\n `Scene at position ${i} and name ${sceneAtThisPositionInOurStack.getName()} has a different networkId ${\n sceneAtThisPositionInOurStack.networkId\n } than the expected ${sceneSyncData.networkId}, replacing.`\n );\n // The scene is in the stack but has a different networkId\n // This can happen if the host has restarted the scene\n // We can't just update the networkId of the scene in the stack\n // We need to replace it with a new scene\n const newScene = this.replace(\n sceneSyncData.name,\n false // Don't clear the stack\n );\n if (newScene) {\n newScene.networkId = sceneSyncData.networkId;\n }\n hasMadeChangeToStack = true;\n // Continue to the next scene in the stack received from the host.\n continue;\n }\n\n // The scene is in the stack and has the right networkId.\n // Nothing to do, just continue to the next scene in the stack received from the host.\n }\n\n // Pop any scene not on the host.\n // In the future, we could avoid to pop scenes if they are not set to be synchronized.\n if (this._stack.length > sceneStackSyncData.length) {\n const popCount = this._stack.length - sceneStackSyncData.length;\n this.pop(popCount);\n hasMadeChangeToStack = true;\n }\n\n return hasMadeChangeToStack;\n }\n\n /**\n * Unload all the scenes and clear the stack.\n */\n dispose(): void {\n for (const item of this._stack) {\n item.unloadScene();\n }\n\n this._stack.length = 0;\n this._wasDisposed = true;\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw 'The scene stack has been disposed and should not be used anymore.';\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,eACzB,EAAc,GAAI,GAAK,OAAO,uBAK7B,OAAiB,CAWtB,YAAY,EAA+B,CAT3C,YAA8B,GAC9B,0BAAgC,GAChC,0BAAgC,GAChC,gCAA+D,KAC/D,kBAAwB,GAMtB,GAAI,CAAC,EACH,KAAM,0DAER,KAAK,aAAe,EAQtB,yBAAgC,CAC9B,OAAS,GAAI,EAAG,EAAI,KAAK,OAAO,OAAQ,EAAE,EACxC,KAAK,OAAO,GAAG,0BAInB,KAAK,EAA6B,CAEhC,GADA,KAAK,mBACD,KAAK,sBAAwB,KAAK,OAAO,SAAW,EACtD,MAAO,GAIT,GAD6B,KAAK,sCAEhC,SAAY,KACV,uEAKK,GAGT,KAAM,GAAe,KAAK,OAAO,KAAK,OAAO,OAAS,GACtD,GAAI,EAAa,cAAc,GAAc,CAC3C,KAAM,GAAU,EAAa,qBAG7B,GAAI,IAAY,EAA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vB,SAGF,GAAI,EAA8B,YAAc,EAAc,KAAM,CAClE,EAAY,KACV,qBAAqB,cAAc,EAA8B,6CAC/D,EAAc,oBAKlB,KAAM,GAAW,KAAK,QACpB,EAAc,KACd,IAEF,AAAI,GACF,GAAS,UAAY,EAAc,WAErC,EAAuB,GAEvB,SAGF,GACE,CAAC,EAA8B,WAC/B,EAAc,WACd,EAAc,OAAS,EAA8B,UACrD,CACA,EAAY,KACV,qBAAqB,cAAc,EAA8B,4FAC/D,EAAc,cAOlB,EAA8B,UAAY,EAAc,UAExD,SAGF,GACE,EAA8B,YAAc,EAAc,UAC1D,CACA,EAAY,KACV,qBAAqB,cAAc,EAA8B,uCAC/D,EAA8B,+BACV,EAAc,yBAMtC,KAAM,GAAW,KAAK,QACpB,EAAc,KACd,IAEF,AAAI,GACF,GAAS,UAAY,EAAc,WAErC,EAAuB,GAEvB,UASJ,GAAI,KAAK,OAAO,OAAS,EAAmB,OAAQ,CAClD,KAAM,GAAW,KAAK,OAAO,OAAS,EAAmB,OACzD,KAAK,IAAI,GACT,EAAuB,GAGzB,MAAO,GAMT,SAAgB,CACd,SAAW,KAAQ,MAAK,OACtB,EAAK,cAGP,KAAK,OAAO,OAAS,EACrB,KAAK,aAAe,GAGd,kBAAyB,CAC/B,GAAI,KAAK,aACP,KAAM,qEA1XL,EAAM,eAPL",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var gdjs;(function(n){class s extends n.RuntimeObject{constructor(t,e){super(t,e);this._scaleX=1;this._scaleY=1;this._blendMode=0;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._preScale=1;this._animationFrameDirty=!0;this._updateIfNotVisible=!!e.updateIfNotVisible,this._preScale=e.preScale||1,this._renderer=new n.SpriteRuntimeObjectRenderer(this,t),this._animator=new n.SpriteAnimator(e.animations,n.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(t.getGame().getImageManager())),this._updateAnimationFrame(),this.onCreated()}reinitialize(t){super.reinitialize(t);const e=this.getInstanceContainer();this._animator.reinitialize(t.animations),this._scaleX=1,this._scaleY=1,this._blendMode=0,this._flippedX=!1,this._flippedY=!1,this.opacity=255,this._updateIfNotVisible=!!t.updateIfNotVisible,this._preScale=t.preScale||1,this._renderer.reinitialize(this,e),this._updateAnimationFrame(),this.onCreated()}updateFromObjectData(t,e){return this._preScale=e.preScale||1,this._animator.updateFromObjectData(t.animations,e.animations),this._updateIfNotVisible=!!e.updateIfNotVisible,this._updateAnimationFrame(),this.invalidateHitboxes(),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),anim:this._animator.getNetworkSyncData(),ifx:this.isFlippedX(),ify:this.isFlippedY(),sx:this._scaleX,sy:this._scaleY,op:this.opacity,color:this.getColor()}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),t.ifx!==void 0&&this.flipX(t.ifx),t.ify!==void 0&&this.flipY(t.ify),t.sx!==void 0&&this.setScaleX(Math.abs(t.sx)),t.sy!==void 0&&this.setScaleY(Math.abs(t.sy)),t.op!==void 0&&this.setOpacity(t.op),t.anim&&(this._animator.updateFromNetworkSyncData(t.anim),this._updateAnimationFrame()),(t.ifx!==void 0||t.ify!==void 0||t.sx!==void 0||t.sy!==void 0||t.anim!==void 0)&&this.invalidateHitboxes(),t.color!==void 0&&this.setColor(t.color)}extraInitializationFromInitialInstance(t){if(t.numberProperties)for(let e=0,i=t.numberProperties.length;e<i;++e){const a=t.numberProperties[e];a.name==="animation"&&this.setAnimationIndex(a.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height)),t.opacity!==void 0&&this.setOpacity(t.opacity),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY)}update(t){if(!this._updateIfNotVisible&&!this._renderer.getRendererObject().visible)return;this._animator.step(this.getElapsedTime()/1e3)&&(this._updateAnimationFrame(),this.invalidateHitboxes()),this._renderer.ensureUpToDate()}updatePreRender(t){this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.ensureUpToDate()}_updateAnimationFrame(){this._animationFrameDirty=!1;const t=this._animator.getCurrentFrame();t&&this._renderer.updateFrame(t)}getRendererObject(){return this._renderer.getRendererObject()}updateHitBoxes(){const t=this._animator.getCurrentFrame();if(!!t){if(!t.hasCustomHitBoxes)return super.updateHitBoxes();for(let e=0;e<t.customHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new n.Polygon);for(let i=0;i<t.customHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),this._transformToGlobal(t.customHitBoxes[e].vertices[i][0],t.customHitBoxes[e].vertices[i][1],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=t.customHitBoxes[e].vertices.length}this.hitBoxes.length=t.customHitBoxes.length}}setAnimation(t){this.setAnimationIndex(t)}setAnimationIndex(t){this._animator.setAnimationIndex(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}setAnimationName(t){this._animator.setAnimationName(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimation(){return this.getAnimationIndex()}getAnimationIndex(){return this._animator.getAnimationIndex()}getAnimationName(){return this._animator.getAnimationName()}isCurrentAnimationName(t){return this.getAnimationName()===t}setDirectionOrAngle(t){const e=this._animator.setDirectionOrAngle(this.angle,t);e!==null&&(this.angle=e,this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes(),this._renderer.updateAngle())}getDirectionOrAngle(){return this._animator.getDirectionOrAngle(this.angle)}setAnimationFrame(t){this._animator.setAnimationFrameIndex(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationFrame(){return this._animator.getAnimationFrameIndex()}getAnimationElapsedTime(){return this._animator.getAnimationElapsedTime()}setAnimationElapsedTime(t){this._animator.setAnimationElapsedTime(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationDuration(){return this._animator.getAnimationDuration()}getAnimationFrameCount(){return this._animator.getAnimationFrameCount()}hasAnimationEndedLegacy(){return this._animator.hasAnimationEndedLegacy()}hasAnimationEnded2(){return this._animator.hasAnimationEnded()}hasAnimationEnded(){return this._animator.hasAnimationEnded()}animationPaused(){return this._animator.isAnimationPaused()}isAnimationPaused(){return this._animator.isAnimationPaused()}pauseAnimation(){this._animator.pauseAnimation()}playAnimation(){this._animator.resumeAnimation()}resumeAnimation(){this._animator.resumeAnimation()}getAnimationSpeedScale(){return this._animator.getAnimationSpeedScale()}setAnimationSpeedScale(t){this._animator.setAnimationSpeedScale(t)}getPointX(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getX();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),a[0]}getPointY(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getY();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointY);return this._transformToGlobal(i.x,i.y,a),a[1]}getPointPosition(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return[this.getX(),this.getY()];const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),[a[0],a[1]]}_transformToGlobal(t,e,i){const a=this._animator.getCurrentFrame();let r=a.center.x,o=a.center.y;this._flippedX&&(t=t+(r-t)*2),this._flippedY&&(e=e+(o-e)*2);const h=Math.abs(this._scaleX*this._preScale),l=Math.abs(this._scaleY*this._preScale);t*=h,e*=l,r*=h,o*=l;const d=this.angle/180*Math.PI,m=Math.cos(d),p=Math.sin(d),u=t-r,f=e-o;t=r+m*u-p*f,e=o+p*u+m*f,i.length=2,i[0]=t+(this.x-a.origin.x*h),i[1]=e+(this.y-a.origin.y*l)}getDrawableX(){const t=this._animator.getCurrentFrame();if(t===null)return this.x;const e=Math.abs(this._scaleX*this._preScale);return this._flippedX?this.x+(-t.origin.x-this._renderer.getUnscaledWidth()+2*t.center.x)*e:this.x-t.origin.x*e}getDrawableY(){const t=this._animator.getCurrentFrame();if(t===null)return this.y;const e=Math.abs(this._scaleY*this._preScale);return this._flippedY?this.y+(-t.origin.y-this._renderer.getUnscaledHeight()+2*t.center.y)*e:this.y-t.origin.y*e}getCenterX(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedX?(this._renderer.getUnscaledWidth()-t.center.x)*Math.abs(this._scaleX*this._preScale):t.center.x*Math.abs(this._scaleX*this._preScale)}getCenterY(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedY?(this._renderer.getUnscaledHeight()-t.center.y)*Math.abs(this._scaleY*this._preScale):t.center.y*Math.abs(this._scaleY*this._preScale)}setX(t){if(t===this.x)return;this.x=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateX())}setY(t){if(t===this.y)return;this.y=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateY())}setAngle(t){const e=this._animator.setAngle(this.angle,t);e!==null&&(this.angle=e,this.invalidateHitboxes(),this._renderer.updateAngle())}getAngle(){return this._animator.getAngle(this.angle)}setBlendMode(t){this._blendMode!==t&&(this._blendMode=t,this._renderer.update())}getBlendMode(){return this._blendMode}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this._renderer.updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this._renderer.updateVisibility()}setColor(t){this._renderer.setColor(t)}getColor(){return this._renderer.getColor()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this._renderer.update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this._renderer.update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getWidth(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getWidth()}getHeight(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getHeight()}setWidth(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledWidth();e!==0&&this.setScaleX(t/e)}setHeight(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledHeight();e!==0&&this.setScaleY(t/e)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setScale(t){t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleX(t){t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}turnTowardObject(t,e){t!==null&&this.rotateTowardPosition(t.getDrawableX()+t.getCenterX(),t.getDrawableY()+t.getCenterY(),0,e)}}n.SpriteRuntimeObject=s,n.registerObject("Sprite",n.SpriteRuntimeObject),s.supportsReinitialization=!0})(gdjs||(gdjs={}));
|
|
1
|
+
var gdjs;(function(n){class s extends n.RuntimeObject{constructor(t,e){super(t,e);this._scaleX=1;this._scaleY=1;this._blendMode=0;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._preScale=1;this._animationFrameDirty=!0;this._updateIfNotVisible=!!e.updateIfNotVisible,this._preScale=e.preScale||1,this._renderer=new n.SpriteRuntimeObjectRenderer(this,t),this._animator=new n.SpriteAnimator(e.animations,n.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(t.getGame().getImageManager())),this._updateAnimationFrame(),this.onCreated()}reinitialize(t){super.reinitialize(t);const e=this.getInstanceContainer();this._animator.reinitialize(t.animations),this._scaleX=1,this._scaleY=1,this._blendMode=0,this._flippedX=!1,this._flippedY=!1,this.opacity=255,this._updateIfNotVisible=!!t.updateIfNotVisible,this._preScale=t.preScale||1,this._renderer.reinitialize(this,e),this._updateAnimationFrame(),this.onCreated()}updateFromObjectData(t,e){return this._preScale=e.preScale||1,this._animator.updateFromObjectData(t.animations,e.animations),this._updateIfNotVisible=!!e.updateIfNotVisible,this._updateAnimationFrame(),this.invalidateHitboxes(),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),anim:this._animator.getNetworkSyncData(),ifx:this.isFlippedX(),ify:this.isFlippedY(),sx:this._scaleX,sy:this._scaleY,op:this.opacity,color:this.getColor()}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),t.ifx!==void 0&&this.flipX(t.ifx),t.ify!==void 0&&this.flipY(t.ify),t.sx!==void 0&&this.setScaleX(Math.abs(t.sx)),t.sy!==void 0&&this.setScaleY(Math.abs(t.sy)),t.op!==void 0&&this.setOpacity(t.op),t.anim&&(this._animator.updateFromNetworkSyncData(t.anim),this._updateAnimationFrame()),(t.ifx!==void 0||t.ify!==void 0||t.sx!==void 0||t.sy!==void 0||t.anim!==void 0)&&this.invalidateHitboxes(),t.color!==void 0&&this.setColor(t.color)}extraInitializationFromInitialInstance(t){if(t.numberProperties)for(let e=0,i=t.numberProperties.length;e<i;++e){const a=t.numberProperties[e];a.name==="animation"&&this.setAnimationIndex(a.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height)),t.opacity!==void 0&&this.setOpacity(t.opacity),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY)}update(t){if(!this._updateIfNotVisible&&!this._renderer.getRendererObject().visible)return;this._animator.step(this.getElapsedTime()/1e3)&&(this._updateAnimationFrame(),this.invalidateHitboxes()),this._renderer.ensureUpToDate()}updatePreRender(t){this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.ensureUpToDate()}_updateAnimationFrame(){this._animationFrameDirty=!1;const t=this._animator.getCurrentFrame();t&&this._renderer.updateFrame(t)}getRendererObject(){return this._renderer.getRendererObject()}updateHitBoxes(){const t=this._animator.getCurrentFrame();if(!!t){if(!t.hasCustomHitBoxes)return super.updateHitBoxes();for(let e=0;e<t.customHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new n.Polygon);for(let i=0;i<t.customHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),this._transformToGlobal(t.customHitBoxes[e].vertices[i][0],t.customHitBoxes[e].vertices[i][1],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=t.customHitBoxes[e].vertices.length}this.hitBoxes.length=t.customHitBoxes.length}}setAnimation(t){this.setAnimationIndex(t)}setAnimationIndex(t){this._animator.setAnimationIndex(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}setAnimationName(t){this._animator.setAnimationName(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimation(){return this.getAnimationIndex()}getAnimationIndex(){return this._animator.getAnimationIndex()}getAnimationName(){return this._animator.getAnimationName()}isCurrentAnimationName(t){return this.getAnimationName()===t}setDirectionOrAngle(t){const e=this._animator.setDirectionOrAngle(this.angle,t);e!==null&&(this.angle=e,this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes(),this._renderer.updateAngle())}getDirectionOrAngle(){return this._animator.getDirectionOrAngle(this.angle)}setAnimationFrame(t){this._animator.setAnimationFrameIndex(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationFrame(){return this._animator.getAnimationFrameIndex()}getAnimationElapsedTime(){return this._animator.getAnimationElapsedTime()}setAnimationElapsedTime(t){this._animator.setAnimationElapsedTime(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationDuration(){return this._animator.getAnimationDuration()}getAnimationFrameCount(){return this._animator.getAnimationFrameCount()}hasAnimationEndedLegacy(){return this._animator.hasAnimationEndedLegacy()}hasAnimationEnded2(){return this._animator.hasAnimationEnded()}hasAnimationEnded(){return this._animator.hasAnimationEnded()}animationPaused(){return this._animator.isAnimationPaused()}isAnimationPaused(){return this._animator.isAnimationPaused()}pauseAnimation(){this._animator.pauseAnimation()}playAnimation(){this._animator.resumeAnimation()}resumeAnimation(){this._animator.resumeAnimation()}getAnimationSpeedScale(){return this._animator.getAnimationSpeedScale()}setAnimationSpeedScale(t){this._animator.setAnimationSpeedScale(t)}getPointX(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getX();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),a[0]}getPointY(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getY();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointY);return this._transformToGlobal(i.x,i.y,a),a[1]}getPointPosition(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return[this.getX(),this.getY()];const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),[a[0],a[1]]}_transformToGlobal(t,e,i){const a=this._animator.getCurrentFrame();let r=a.center.x,o=a.center.y;this._flippedX&&(t=t+(r-t)*2),this._flippedY&&(e=e+(o-e)*2);const h=Math.abs(this._scaleX*this._preScale),l=Math.abs(this._scaleY*this._preScale);t*=h,e*=l,r*=h,o*=l;const d=this.angle/180*Math.PI,m=Math.cos(d),p=Math.sin(d),u=t-r,f=e-o;t=r+m*u-p*f,e=o+p*u+m*f,i.length=2,i[0]=t+(this.x-a.origin.x*h),i[1]=e+(this.y-a.origin.y*l)}getDrawableX(){const t=this._animator.getCurrentFrame();if(t===null)return this.x;const e=Math.abs(this._scaleX*this._preScale);return this._flippedX?this.x+(-t.origin.x-this._renderer.getUnscaledWidth()+2*t.center.x)*e:this.x-t.origin.x*e}getDrawableY(){const t=this._animator.getCurrentFrame();if(t===null)return this.y;const e=Math.abs(this._scaleY*this._preScale);return this._flippedY?this.y+(-t.origin.y-this._renderer.getUnscaledHeight()+2*t.center.y)*e:this.y-t.origin.y*e}getCenterX(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedX?(this._renderer.getUnscaledWidth()-t.center.x)*Math.abs(this._scaleX*this._preScale):t.center.x*Math.abs(this._scaleX*this._preScale)}getCenterY(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedY?(this._renderer.getUnscaledHeight()-t.center.y)*Math.abs(this._scaleY*this._preScale):t.center.y*Math.abs(this._scaleY*this._preScale)}setX(t){if(t===this.x)return;this.x=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateX())}setY(t){if(t===this.y)return;this.y=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateY())}setAngle(t){const e=this._animator.setAngle(this.angle,t);e!==null&&(this.angle=e,this.invalidateHitboxes(),this._renderer.updateAngle())}getAngle(){return this._animator.getAngle(this.angle)}setBlendMode(t){this._blendMode!==t&&(this._blendMode=t,this._renderer.update())}getBlendMode(){return this._blendMode}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this._renderer.updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this._renderer.updateVisibility()}setColor(t){this._renderer.setColor(t)}getColor(){return this._renderer.getColor()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this._renderer.update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this._renderer.update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getWidth(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getWidth()}getHeight(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getHeight()}setWidth(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledWidth();e!==0&&this.setScaleX(t/(e*this._preScale))}setHeight(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledHeight();e!==0&&this.setScaleY(t/(e*this._preScale))}setSize(t,e){this.setWidth(t),this.setHeight(e)}setScale(t){t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleX(t){t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}turnTowardObject(t,e){t!==null&&this.rotateTowardPosition(t.getDrawableX()+t.getCenterX(),t.getDrawableY()+t.getCenterY(),0,e)}}n.SpriteRuntimeObject=s,n.registerObject("Sprite",n.SpriteRuntimeObject),s.supportsReinitialization=!0})(gdjs||(gdjs={}));
|
|
2
2
|
//# sourceMappingURL=spriteruntimeobject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../GDevelop/GDJS/Runtime/spriteruntimeobject.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /** Represents the data of a {@link gdjs.SpriteRuntimeObject}. */\n export type SpriteObjectDataType = {\n /** Update the object even if he is not visible?. */\n updateIfNotVisible: boolean;\n /** The scale applied to object to evaluate the default dimensions */\n preScale?: float;\n /** The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances. */\n animations: Array<SpriteAnimationData>;\n };\n\n export type SpriteObjectData = ObjectData & SpriteObjectDataType;\n\n export type SpriteNetworkSyncDataType = {\n anim: SpriteAnimatorNetworkSyncData;\n ifx: boolean;\n ify: boolean;\n sx: float;\n sy: float;\n op: float;\n color: string;\n };\n\n export type SpriteNetworkSyncData = ObjectNetworkSyncData &\n SpriteNetworkSyncDataType;\n\n /**\n * The SpriteRuntimeObject represents an object that can display images.\n */\n export class SpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.Animatable,\n gdjs.OpacityHandler {\n _animator: gdjs.SpriteAnimator<any>;\n _scaleX: float = 1;\n _scaleY: float = 1;\n _blendMode: integer = 0;\n _flippedX: boolean = false;\n _flippedY: boolean = false;\n opacity: float = 255;\n _updateIfNotVisible: boolean;\n _preScale: float = 1;\n\n _renderer: gdjs.SpriteRuntimeObjectRenderer;\n _animationFrameDirty = true;\n\n /**\n * @param instanceContainer The container the object belongs to\n * @param spriteObjectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n spriteObjectData: ObjectData & SpriteObjectDataType\n ) {\n super(instanceContainer, spriteObjectData);\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer = new gdjs.SpriteRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._animator = new gdjs.SpriteAnimator(\n spriteObjectData.animations,\n gdjs.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(\n instanceContainer.getGame().getImageManager()\n )\n );\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n reinitialize(spriteObjectData: SpriteObjectData) {\n super.reinitialize(spriteObjectData);\n const instanceContainer = this.getInstanceContainer();\n this._animator.reinitialize(spriteObjectData.animations);\n this._scaleX = 1;\n this._scaleY = 1;\n this._blendMode = 0;\n this._flippedX = false;\n this._flippedY = false;\n this.opacity = 255;\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer.reinitialize(this, instanceContainer);\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object reinitialize method.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: SpriteObjectData,\n newObjectData: SpriteObjectData\n ): boolean {\n this._preScale = newObjectData.preScale || 1;\n this._animator.updateFromObjectData(\n oldObjectData.animations,\n newObjectData.animations\n );\n this._updateIfNotVisible = !!newObjectData.updateIfNotVisible;\n this._updateAnimationFrame();\n this.invalidateHitboxes();\n return true;\n }\n\n getNetworkSyncData(): SpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n anim: this._animator.getNetworkSyncData(),\n ifx: this.isFlippedX(),\n ify: this.isFlippedY(),\n sx: this._scaleX,\n sy: this._scaleY,\n op: this.opacity,\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(newNetworkSyncData: SpriteNetworkSyncData) {\n super.updateFromNetworkSyncData(newNetworkSyncData);\n if (newNetworkSyncData.ifx !== undefined) {\n this.flipX(newNetworkSyncData.ifx);\n }\n if (newNetworkSyncData.ify !== undefined) {\n this.flipY(newNetworkSyncData.ify);\n }\n if (newNetworkSyncData.sx !== undefined) {\n this.setScaleX(Math.abs(newNetworkSyncData.sx));\n }\n if (newNetworkSyncData.sy !== undefined) {\n this.setScaleY(Math.abs(newNetworkSyncData.sy));\n }\n if (newNetworkSyncData.op !== undefined) {\n this.setOpacity(newNetworkSyncData.op);\n }\n if (newNetworkSyncData.anim) {\n this._animator.updateFromNetworkSyncData(newNetworkSyncData.anim);\n // TODO: optimize updating the animation frame only if needed.\n this._updateAnimationFrame();\n }\n if (\n newNetworkSyncData.ifx !== undefined ||\n newNetworkSyncData.ify !== undefined ||\n newNetworkSyncData.sx !== undefined ||\n newNetworkSyncData.sy !== undefined ||\n newNetworkSyncData.anim !== undefined\n ) {\n this.invalidateHitboxes();\n }\n if (newNetworkSyncData.color !== undefined) {\n this.setColor(newNetworkSyncData.color);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The extra parameters\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (extraData.name === 'animation') {\n this.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n */\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n //Playing the animation of all objects including the ones outside the screen can be\n //costly when the scene is big with a lot of animated objects. By default, we skip\n //updating the object if it is not visible.\n if (\n !this._updateIfNotVisible &&\n !this._renderer.getRendererObject().visible\n ) {\n return;\n }\n const hasFrameChanged = this._animator.step(this.getElapsedTime() / 1000);\n if (hasFrameChanged) {\n this._updateAnimationFrame();\n // TODO: Hitboxes may not need an update if every frames has the same ones.\n this.invalidateHitboxes();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Ensure the sprite is ready to be displayed: the proper animation frame\n * is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).\n */\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Update `this._animationFrame` according to the current animation/direction/frame values\n * (`this._currentAnimation`, `this._currentDirection`, `this._currentFrame`) and set\n * `this._animationFrameDirty` back to false.\n *\n * Trigger a call to the renderer to change the texture being shown (if the animation/direction/frame\n * is valid).\n * If invalid, `this._animationFrame` will be `null` after calling this function.\n */\n _updateAnimationFrame() {\n this._animationFrameDirty = false;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame) {\n this._renderer.updateFrame(animationFrame);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n /**\n * Update the hit boxes for the object.\n * Fallback to the default implementation (rotated bounding box) if there is no custom\n * hitboxes defined for the current animation frame.\n */\n updateHitBoxes(): void {\n const animationFrame = this._animator.getCurrentFrame();\n if (!animationFrame) {\n return;\n }\n\n if (!animationFrame.hasCustomHitBoxes) {\n return super.updateHitBoxes();\n }\n\n //logger.log(\"Update for \"+this.name); //Uncomment to track updates\n //(and in particular be sure that unnecessary update are avoided).\n\n //Update the current hitboxes with the frame custom hit boxes\n //and apply transformations.\n for (let i = 0; i < animationFrame.customHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < animationFrame.customHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n this._transformToGlobal(\n animationFrame.customHitBoxes[i].vertices[j][0],\n animationFrame.customHitBoxes[i].vertices[j][1],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n animationFrame.customHitBoxes[i].vertices.length;\n }\n this.hitBoxes.length = animationFrame.customHitBoxes.length;\n }\n\n //Rotate and scale and flipping have already been applied to the point by _transformToGlobal.\n //Animations :\n /**\n * Change the animation being played.\n * @param newAnimation The index of the new animation to be played\n * @deprecated Use `setAnimationIndex` instead\n */\n setAnimation(newAnimation: integer): void {\n this.setAnimationIndex(newAnimation);\n }\n\n setAnimationIndex(newAnimation: integer): void {\n const hasAnimationChanged = this._animator.setAnimationIndex(\n newAnimation\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n setAnimationName(newAnimationName: string): void {\n const hasAnimationChanged = this._animator.setAnimationName(\n newAnimationName\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n * @deprecated Use `getAnimationIndex` instead\n */\n getAnimation(): integer {\n return this.getAnimationIndex();\n }\n\n getAnimationIndex(): integer {\n return this._animator.getAnimationIndex();\n }\n\n getAnimationName(): string {\n return this._animator.getAnimationName();\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param The new angle (or direction index) to be applied\n */\n setDirectionOrAngle(newValue: float): void {\n const actualValue = this._animator.setDirectionOrAngle(\n this.angle,\n newValue\n );\n if (actualValue !== null) {\n this.angle = actualValue;\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n getDirectionOrAngle(): float {\n return this._animator.getDirectionOrAngle(this.angle);\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrame The index of the frame to be displayed\n */\n setAnimationFrame(newFrame: integer): void {\n const hasFrameChanged = this._animator.setAnimationFrameIndex(newFrame);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the current frame displayed by the animation\n * @return newFrame The index of the frame being displayed\n */\n getAnimationFrame(): integer {\n return this._animator.getAnimationFrameIndex();\n }\n\n getAnimationElapsedTime(): float {\n return this._animator.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n const hasFrameChanged = this._animator.setAnimationElapsedTime(time);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n getAnimationDuration(): float {\n return this._animator.getAnimationDuration();\n }\n\n getAnimationFrameCount(): integer {\n return this._animator.getAnimationFrameCount();\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using `hasAnimationEnded2`. This method returns true as soon as\n * the animation enters the last frame, not at the end of the last frame.\n */\n hasAnimationEndedLegacy(): boolean {\n return this._animator.hasAnimationEndedLegacy();\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n *\n * @deprecated Use `hasAnimationEnded` instead.\n */\n hasAnimationEnded2(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n hasAnimationEnded(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n /**\n * @deprecated Use `isAnimationPaused` instead.\n */\n animationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n isAnimationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n pauseAnimation(): void {\n this._animator.pauseAnimation();\n }\n\n /**\n * @deprecated Use `resumeAnimation` instead.\n */\n playAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n resumeAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n getAnimationSpeedScale(): float {\n return this._animator.getAnimationSpeedScale();\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animator.setAnimationSpeedScale(ratio);\n }\n\n //Position :\n /**\n * Get the position on X axis on the scene of the given point.\n * @param name The point name\n * @return the position on X axis on the scene of the given point.\n */\n getPointX(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getX();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[0];\n }\n\n /**\n * Get the position on Y axis on the scene of the given point.\n * @param name The point name\n * @return the position on Y axis on the scene of the given point.\n */\n getPointY(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getY();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointY);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[1];\n }\n /**\n * Get the positions on X and Y axis on the scene of the given point.\n * @param name The point name\n * @return An array of the position on X and Y axis on the scene of the given point.\n */\n getPointPosition(name: string): [x: float, y: float] {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return [this.getX(), this.getY()];\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return [pos[0], pos[1]];\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in world coordinates (as opposed to the object local coordinates).\n *\n * Beware: this._animationFrame and this._sprite must *not* be null!\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in global coordinates).\n */\n private _transformToGlobal(x: float, y: float, result: float[]) {\n const animationFrame = this._animator.getCurrentFrame() as SpriteAnimationFrame<\n any\n >;\n let cx = animationFrame.center.x;\n let cy = animationFrame.center.y;\n\n //Flipping\n if (this._flippedX) {\n x = x + (cx - x) * 2;\n }\n if (this._flippedY) {\n y = y + (cy - y) * 2;\n }\n\n //Scale\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n x *= absScaleX;\n y *= absScaleY;\n cx *= absScaleX;\n cy *= absScaleY;\n\n //Rotation\n const angleInRadians = (this.angle / 180) * Math.PI;\n const cosValue = Math.cos(\n // Only compute cos and sin once (10% faster than doing it twice)\n angleInRadians\n );\n const sinValue = Math.sin(angleInRadians);\n const xToCenterXDelta = x - cx;\n const yToCenterYDelta = y - cy;\n x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;\n y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;\n result.length = 2;\n result[0] = x + (this.x - animationFrame.origin.x * absScaleX);\n result[1] = y + (this.y - animationFrame.origin.y * absScaleY);\n }\n\n /**\n * Get the X position, on the scene, of the origin of the texture of the object.\n * @return the X position, on the scene, of the origin of the texture of the object.\n */\n getDrawableX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.x;\n }\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n if (!this._flippedX) {\n return this.x - animationFrame.origin.x * absScaleX;\n } else {\n return (\n this.x +\n (-animationFrame.origin.x -\n this._renderer.getUnscaledWidth() +\n 2 * animationFrame.center.x) *\n absScaleX\n );\n }\n }\n\n /**\n * Get the Y position, on the scene, of the origin of the texture of the object.\n * @return the Y position, on the scene, of the origin of the texture of the object.\n */\n getDrawableY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.y;\n }\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n if (!this._flippedY) {\n return this.y - animationFrame.origin.y * absScaleY;\n } else {\n return (\n this.y +\n (-animationFrame.origin.y -\n this._renderer.getUnscaledHeight() +\n 2 * animationFrame.center.y) *\n absScaleY\n );\n }\n }\n\n /**\n * Get the X position of the center of the object, relative to top-left of the texture of the object (`getDrawableX`).\n * @return X position of the center of the object, relative to `getDrawableX()`.\n */\n getCenterX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedX) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.x * Math.abs(this._scaleX * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledWidth() - animationFrame.center.x) *\n Math.abs(this._scaleX * this._preScale)\n );\n }\n }\n\n /**\n * Get the Y position of the center of the object, relative to top-left of the texture of the object (`getDrawableY`).\n * @return Y position of the center of the object, relative to `getDrawableY()`.\n */\n getCenterY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedY) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.y * Math.abs(this._scaleY * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledHeight() - animationFrame.center.y) *\n Math.abs(this._scaleY * this._preScale)\n );\n }\n }\n\n /**\n * Set the X position of the (origin of the) object.\n * @param x The new X position.\n */\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateX();\n }\n }\n\n /**\n * Set the Y position of the (origin of the) object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateY();\n }\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle, in degrees.\n */\n setAngle(angle: float): void {\n const actualValue = this._animator.setAngle(this.angle, angle);\n if (actualValue !== null) {\n this.angle = actualValue;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n /**\n * Get the angle of the object.\n * @return The angle, in degrees.\n */\n getAngle(): float {\n return this._animator.getAngle(this.angle);\n }\n\n //Visibility and display :\n setBlendMode(newMode): void {\n if (this._blendMode === newMode) {\n return;\n }\n this._blendMode = newMode;\n this._renderer.update();\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this._renderer.updateVisibility();\n }\n\n /**\n * Change the tint of the sprite object.\n *\n * @param rgbOrHexColor The color as a string, in RGB format (\"128;200;255\") or Hex format.\n */\n setColor(rgbOrHexColor: string): void {\n this._renderer.setColor(rgbOrHexColor);\n }\n\n /**\n * Get the tint of the sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n //Scale and size :\n /**\n * Get the width of the object.\n *\n * @return The width of the object, in pixels.\n */\n getWidth(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n *\n * @return The height of the object, in pixels.\n */\n getHeight(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getHeight();\n }\n\n setWidth(newWidth: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledWidth = this._renderer.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / unscaledWidth);\n }\n }\n\n setHeight(newHeight: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledHeight = this._renderer.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / unscaledHeight);\n }\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n //Other :\n /**\n * @param obj The target object\n * @param scene The scene containing the object\n * @deprecated\n */\n turnTowardObject(obj: gdjs.RuntimeObject | null, scene: gdjs.RuntimeScene) {\n if (obj === null) {\n return;\n }\n this.rotateTowardPosition(\n obj.getDrawableX() + obj.getCenterX(),\n obj.getDrawableY() + obj.getCenterY(),\n 0,\n scene\n );\n }\n }\n gdjs.registerObject(\n 'Sprite',\n //Notify gdjs of the object existence.\n gdjs.SpriteRuntimeObject\n );\n\n //Others initialization and internal state management :\n SpriteRuntimeObject.supportsReinitialization = true;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CA6BS,eACG,GAAK,aAMS,CAkBtB,YACE,EACA,EACA,CACA,MAAM,EAAmB,GApB3B,aAAiB,EACjB,aAAiB,EACjB,gBAAsB,EACtB,eAAqB,GACrB,eAAqB,GACrB,aAAiB,IAEjB,eAAmB,EAGnB,0BAAuB,GAWrB,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAY,GAAI,GAAK,4BACxB,KACA,GAEF,KAAK,UAAY,GAAI,GAAK,eACxB,EAAiB,WACjB,EAAK,4BAA4B,gCAC/B,EAAkB,UAAU,oBAGhC,KAAK,wBAGL,KAAK,YAGP,aAAa,EAAoC,CAC/C,MAAM,aAAa,GACnB,KAAM,GAAoB,KAAK,uBAC/B,KAAK,UAAU,aAAa,EAAiB,YAC7C,KAAK,QAAU,EACf,KAAK,QAAU,EACf,KAAK,WAAa,EAClB,KAAK,UAAY,GACjB,KAAK,UAAY,GACjB,KAAK,QAAU,IACf,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAU,aAAa,KAAM,GAClC,KAAK,wBAGL,KAAK,YAGP,qBACE,EACA,EACS,CACT,YAAK,UAAY,EAAc,UAAY,EAC3C,KAAK,UAAU,qBACb,EAAc,WACd,EAAc,YAEhB,KAAK,oBAAsB,CAAC,CAAC,EAAc,mBAC3C,KAAK,wBACL,KAAK,qBACE,GAGT,oBAA4C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Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /** Represents the data of a {@link gdjs.SpriteRuntimeObject}. */\n export type SpriteObjectDataType = {\n /** Update the object even if he is not visible?. */\n updateIfNotVisible: boolean;\n /** The scale applied to object to evaluate the default dimensions */\n preScale?: float;\n /** The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances. */\n animations: Array<SpriteAnimationData>;\n };\n\n export type SpriteObjectData = ObjectData & SpriteObjectDataType;\n\n export type SpriteNetworkSyncDataType = {\n anim: SpriteAnimatorNetworkSyncData;\n ifx: boolean;\n ify: boolean;\n sx: float;\n sy: float;\n op: float;\n color: string;\n };\n\n export type SpriteNetworkSyncData = ObjectNetworkSyncData &\n SpriteNetworkSyncDataType;\n\n /**\n * The SpriteRuntimeObject represents an object that can display images.\n */\n export class SpriteRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.Animatable,\n gdjs.OpacityHandler {\n _animator: gdjs.SpriteAnimator<any>;\n _scaleX: float = 1;\n _scaleY: float = 1;\n _blendMode: integer = 0;\n _flippedX: boolean = false;\n _flippedY: boolean = false;\n opacity: float = 255;\n _updateIfNotVisible: boolean;\n _preScale: float = 1;\n\n _renderer: gdjs.SpriteRuntimeObjectRenderer;\n _animationFrameDirty = true;\n\n /**\n * @param instanceContainer The container the object belongs to\n * @param spriteObjectData The object data used to initialize the object\n */\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n spriteObjectData: ObjectData & SpriteObjectDataType\n ) {\n super(instanceContainer, spriteObjectData);\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer = new gdjs.SpriteRuntimeObjectRenderer(\n this,\n instanceContainer\n );\n this._animator = new gdjs.SpriteAnimator(\n spriteObjectData.animations,\n gdjs.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(\n instanceContainer.getGame().getImageManager()\n )\n );\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object constructor.\n this.onCreated();\n }\n\n reinitialize(spriteObjectData: SpriteObjectData) {\n super.reinitialize(spriteObjectData);\n const instanceContainer = this.getInstanceContainer();\n this._animator.reinitialize(spriteObjectData.animations);\n this._scaleX = 1;\n this._scaleY = 1;\n this._blendMode = 0;\n this._flippedX = false;\n this._flippedY = false;\n this.opacity = 255;\n this._updateIfNotVisible = !!spriteObjectData.updateIfNotVisible;\n this._preScale = spriteObjectData.preScale || 1;\n this._renderer.reinitialize(this, instanceContainer);\n this._updateAnimationFrame();\n\n // *ALWAYS* call `this.onCreated()` at the very end of your object reinitialize method.\n this.onCreated();\n }\n\n updateFromObjectData(\n oldObjectData: SpriteObjectData,\n newObjectData: SpriteObjectData\n ): boolean {\n this._preScale = newObjectData.preScale || 1;\n this._animator.updateFromObjectData(\n oldObjectData.animations,\n newObjectData.animations\n );\n this._updateIfNotVisible = !!newObjectData.updateIfNotVisible;\n this._updateAnimationFrame();\n this.invalidateHitboxes();\n return true;\n }\n\n getNetworkSyncData(): SpriteNetworkSyncData {\n return {\n ...super.getNetworkSyncData(),\n anim: this._animator.getNetworkSyncData(),\n ifx: this.isFlippedX(),\n ify: this.isFlippedY(),\n sx: this._scaleX,\n sy: this._scaleY,\n op: this.opacity,\n color: this.getColor(),\n };\n }\n\n updateFromNetworkSyncData(newNetworkSyncData: SpriteNetworkSyncData) {\n super.updateFromNetworkSyncData(newNetworkSyncData);\n if (newNetworkSyncData.ifx !== undefined) {\n this.flipX(newNetworkSyncData.ifx);\n }\n if (newNetworkSyncData.ify !== undefined) {\n this.flipY(newNetworkSyncData.ify);\n }\n if (newNetworkSyncData.sx !== undefined) {\n this.setScaleX(Math.abs(newNetworkSyncData.sx));\n }\n if (newNetworkSyncData.sy !== undefined) {\n this.setScaleY(Math.abs(newNetworkSyncData.sy));\n }\n if (newNetworkSyncData.op !== undefined) {\n this.setOpacity(newNetworkSyncData.op);\n }\n if (newNetworkSyncData.anim) {\n this._animator.updateFromNetworkSyncData(newNetworkSyncData.anim);\n // TODO: optimize updating the animation frame only if needed.\n this._updateAnimationFrame();\n }\n if (\n newNetworkSyncData.ifx !== undefined ||\n newNetworkSyncData.ify !== undefined ||\n newNetworkSyncData.sx !== undefined ||\n newNetworkSyncData.sy !== undefined ||\n newNetworkSyncData.anim !== undefined\n ) {\n this.invalidateHitboxes();\n }\n if (newNetworkSyncData.color !== undefined) {\n this.setColor(newNetworkSyncData.color);\n }\n }\n\n /**\n * Initialize the extra parameters that could be set for an instance.\n * @param initialInstanceData The extra parameters\n */\n extraInitializationFromInitialInstance(initialInstanceData: InstanceData) {\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (extraData.name === 'animation') {\n this.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n /**\n * Update the current frame of the object according to the elapsed time on the scene.\n */\n update(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n //Playing the animation of all objects including the ones outside the screen can be\n //costly when the scene is big with a lot of animated objects. By default, we skip\n //updating the object if it is not visible.\n if (\n !this._updateIfNotVisible &&\n !this._renderer.getRendererObject().visible\n ) {\n return;\n }\n const hasFrameChanged = this._animator.step(this.getElapsedTime() / 1000);\n if (hasFrameChanged) {\n this._updateAnimationFrame();\n // TODO: Hitboxes may not need an update if every frames has the same ones.\n this.invalidateHitboxes();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Ensure the sprite is ready to be displayed: the proper animation frame\n * is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).\n */\n updatePreRender(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n this._renderer.ensureUpToDate();\n }\n\n /**\n * Update `this._animationFrame` according to the current animation/direction/frame values\n * (`this._currentAnimation`, `this._currentDirection`, `this._currentFrame`) and set\n * `this._animationFrameDirty` back to false.\n *\n * Trigger a call to the renderer to change the texture being shown (if the animation/direction/frame\n * is valid).\n * If invalid, `this._animationFrame` will be `null` after calling this function.\n */\n _updateAnimationFrame() {\n this._animationFrameDirty = false;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame) {\n this._renderer.updateFrame(animationFrame);\n }\n }\n\n getRendererObject() {\n return this._renderer.getRendererObject();\n }\n\n /**\n * Update the hit boxes for the object.\n * Fallback to the default implementation (rotated bounding box) if there is no custom\n * hitboxes defined for the current animation frame.\n */\n updateHitBoxes(): void {\n const animationFrame = this._animator.getCurrentFrame();\n if (!animationFrame) {\n return;\n }\n\n if (!animationFrame.hasCustomHitBoxes) {\n return super.updateHitBoxes();\n }\n\n //logger.log(\"Update for \"+this.name); //Uncomment to track updates\n //(and in particular be sure that unnecessary update are avoided).\n\n //Update the current hitboxes with the frame custom hit boxes\n //and apply transformations.\n for (let i = 0; i < animationFrame.customHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < animationFrame.customHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n this._transformToGlobal(\n animationFrame.customHitBoxes[i].vertices[j][0],\n animationFrame.customHitBoxes[i].vertices[j][1],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n animationFrame.customHitBoxes[i].vertices.length;\n }\n this.hitBoxes.length = animationFrame.customHitBoxes.length;\n }\n\n //Rotate and scale and flipping have already been applied to the point by _transformToGlobal.\n //Animations :\n /**\n * Change the animation being played.\n * @param newAnimation The index of the new animation to be played\n * @deprecated Use `setAnimationIndex` instead\n */\n setAnimation(newAnimation: integer): void {\n this.setAnimationIndex(newAnimation);\n }\n\n setAnimationIndex(newAnimation: integer): void {\n const hasAnimationChanged = this._animator.setAnimationIndex(\n newAnimation\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n setAnimationName(newAnimationName: string): void {\n const hasAnimationChanged = this._animator.setAnimationName(\n newAnimationName\n );\n if (hasAnimationChanged) {\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the animation being played.\n * @return The index of the new animation being played\n * @deprecated Use `getAnimationIndex` instead\n */\n getAnimation(): integer {\n return this.getAnimationIndex();\n }\n\n getAnimationIndex(): integer {\n return this._animator.getAnimationIndex();\n }\n\n getAnimationName(): string {\n return this._animator.getAnimationName();\n }\n\n isCurrentAnimationName(name: string): boolean {\n return this.getAnimationName() === name;\n }\n\n /**\n * Change the angle (or direction index) of the object\n * @param The new angle (or direction index) to be applied\n */\n setDirectionOrAngle(newValue: float): void {\n const actualValue = this._animator.setDirectionOrAngle(\n this.angle,\n newValue\n );\n if (actualValue !== null) {\n this.angle = actualValue;\n //TODO: This may be unnecessary.\n this._renderer.update();\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n getDirectionOrAngle(): float {\n return this._animator.getDirectionOrAngle(this.angle);\n }\n\n /**\n * Change the current frame displayed by the animation\n * @param newFrame The index of the frame to be displayed\n */\n setAnimationFrame(newFrame: integer): void {\n const hasFrameChanged = this._animator.setAnimationFrameIndex(newFrame);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n /**\n * Get the index of the current frame displayed by the animation\n * @return newFrame The index of the frame being displayed\n */\n getAnimationFrame(): integer {\n return this._animator.getAnimationFrameIndex();\n }\n\n getAnimationElapsedTime(): float {\n return this._animator.getAnimationElapsedTime();\n }\n\n setAnimationElapsedTime(time: float): void {\n const hasFrameChanged = this._animator.setAnimationElapsedTime(time);\n if (hasFrameChanged) {\n this._animationFrameDirty = true;\n this.invalidateHitboxes();\n }\n }\n\n getAnimationDuration(): float {\n return this._animator.getAnimationDuration();\n }\n\n getAnimationFrameCount(): integer {\n return this._animator.getAnimationFrameCount();\n }\n\n /**\n * @deprecated\n * Return true if animation has ended.\n * Prefer using `hasAnimationEnded2`. This method returns true as soon as\n * the animation enters the last frame, not at the end of the last frame.\n */\n hasAnimationEndedLegacy(): boolean {\n return this._animator.hasAnimationEndedLegacy();\n }\n\n /**\n * Return true if animation has ended.\n * The animation had ended if:\n * - it's not configured as a loop;\n * - the current frame is the last frame;\n * - the last frame has been displayed long enough.\n *\n * @deprecated Use `hasAnimationEnded` instead.\n */\n hasAnimationEnded2(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n hasAnimationEnded(): boolean {\n return this._animator.hasAnimationEnded();\n }\n\n /**\n * @deprecated Use `isAnimationPaused` instead.\n */\n animationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n isAnimationPaused(): boolean {\n return this._animator.isAnimationPaused();\n }\n\n pauseAnimation(): void {\n this._animator.pauseAnimation();\n }\n\n /**\n * @deprecated Use `resumeAnimation` instead.\n */\n playAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n resumeAnimation(): void {\n this._animator.resumeAnimation();\n }\n\n getAnimationSpeedScale(): float {\n return this._animator.getAnimationSpeedScale();\n }\n\n setAnimationSpeedScale(ratio: float): void {\n this._animator.setAnimationSpeedScale(ratio);\n }\n\n //Position :\n /**\n * Get the position on X axis on the scene of the given point.\n * @param name The point name\n * @return the position on X axis on the scene of the given point.\n */\n getPointX(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getX();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[0];\n }\n\n /**\n * Get the position on Y axis on the scene of the given point.\n * @param name The point name\n * @return the position on Y axis on the scene of the given point.\n */\n getPointY(name: string): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return this.getY();\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointY);\n this._transformToGlobal(pt.x, pt.y, pos);\n return pos[1];\n }\n /**\n * Get the positions on X and Y axis on the scene of the given point.\n * @param name The point name\n * @return An array of the position on X and Y axis on the scene of the given point.\n */\n getPointPosition(name: string): [x: float, y: float] {\n const animationFrame = this._animator.getCurrentFrame();\n if (name.length === 0 || animationFrame === null) {\n return [this.getX(), this.getY()];\n }\n const pt = animationFrame.getPoint(name);\n const pos = gdjs.staticArray(SpriteRuntimeObject.prototype.getPointX);\n this._transformToGlobal(pt.x, pt.y, pos);\n return [pos[0], pos[1]];\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in world coordinates (as opposed to the object local coordinates).\n *\n * Beware: this._animationFrame and this._sprite must *not* be null!\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param result Array that will be updated with the result\n * (x and y position of the point in global coordinates).\n */\n private _transformToGlobal(x: float, y: float, result: float[]) {\n const animationFrame = this._animator.getCurrentFrame() as SpriteAnimationFrame<\n any\n >;\n let cx = animationFrame.center.x;\n let cy = animationFrame.center.y;\n\n //Flipping\n if (this._flippedX) {\n x = x + (cx - x) * 2;\n }\n if (this._flippedY) {\n y = y + (cy - y) * 2;\n }\n\n //Scale\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n x *= absScaleX;\n y *= absScaleY;\n cx *= absScaleX;\n cy *= absScaleY;\n\n //Rotation\n const angleInRadians = (this.angle / 180) * Math.PI;\n const cosValue = Math.cos(\n // Only compute cos and sin once (10% faster than doing it twice)\n angleInRadians\n );\n const sinValue = Math.sin(angleInRadians);\n const xToCenterXDelta = x - cx;\n const yToCenterYDelta = y - cy;\n x = cx + cosValue * xToCenterXDelta - sinValue * yToCenterYDelta;\n y = cy + sinValue * xToCenterXDelta + cosValue * yToCenterYDelta;\n result.length = 2;\n result[0] = x + (this.x - animationFrame.origin.x * absScaleX);\n result[1] = y + (this.y - animationFrame.origin.y * absScaleY);\n }\n\n /**\n * Get the X position, on the scene, of the origin of the texture of the object.\n * @return the X position, on the scene, of the origin of the texture of the object.\n */\n getDrawableX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.x;\n }\n const absScaleX = Math.abs(this._scaleX * this._preScale);\n if (!this._flippedX) {\n return this.x - animationFrame.origin.x * absScaleX;\n } else {\n return (\n this.x +\n (-animationFrame.origin.x -\n this._renderer.getUnscaledWidth() +\n 2 * animationFrame.center.x) *\n absScaleX\n );\n }\n }\n\n /**\n * Get the Y position, on the scene, of the origin of the texture of the object.\n * @return the Y position, on the scene, of the origin of the texture of the object.\n */\n getDrawableY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return this.y;\n }\n const absScaleY = Math.abs(this._scaleY * this._preScale);\n if (!this._flippedY) {\n return this.y - animationFrame.origin.y * absScaleY;\n } else {\n return (\n this.y +\n (-animationFrame.origin.y -\n this._renderer.getUnscaledHeight() +\n 2 * animationFrame.center.y) *\n absScaleY\n );\n }\n }\n\n /**\n * Get the X position of the center of the object, relative to top-left of the texture of the object (`getDrawableX`).\n * @return X position of the center of the object, relative to `getDrawableX()`.\n */\n getCenterX(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedX) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.x * Math.abs(this._scaleX * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledWidth() - animationFrame.center.x) *\n Math.abs(this._scaleX * this._preScale)\n );\n }\n }\n\n /**\n * Get the Y position of the center of the object, relative to top-left of the texture of the object (`getDrawableY`).\n * @return Y position of the center of the object, relative to `getDrawableY()`.\n */\n getCenterY(): float {\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame === null) {\n return 0;\n }\n if (!this._flippedY) {\n //Just need to multiply by the scale as it is the center.\n return (\n animationFrame.center.y * Math.abs(this._scaleY * this._preScale)\n );\n } else {\n return (\n (this._renderer.getUnscaledHeight() - animationFrame.center.y) *\n Math.abs(this._scaleY * this._preScale)\n );\n }\n }\n\n /**\n * Set the X position of the (origin of the) object.\n * @param x The new X position.\n */\n setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateX();\n }\n }\n\n /**\n * Set the Y position of the (origin of the) object.\n * @param y The new Y position.\n */\n setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n const animationFrame = this._animator.getCurrentFrame();\n if (animationFrame !== null) {\n this.invalidateHitboxes();\n this._renderer.updateY();\n }\n }\n\n /**\n * Set the angle of the object.\n * @param angle The new angle, in degrees.\n */\n setAngle(angle: float): void {\n const actualValue = this._animator.setAngle(this.angle, angle);\n if (actualValue !== null) {\n this.angle = actualValue;\n this.invalidateHitboxes();\n this._renderer.updateAngle();\n }\n }\n\n /**\n * Get the angle of the object.\n * @return The angle, in degrees.\n */\n getAngle(): float {\n return this._animator.getAngle(this.angle);\n }\n\n //Visibility and display :\n setBlendMode(newMode): void {\n if (this._blendMode === newMode) {\n return;\n }\n this._blendMode = newMode;\n this._renderer.update();\n }\n\n getBlendMode() {\n return this._blendMode;\n }\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this._renderer.updateOpacity();\n }\n\n getOpacity(): float {\n return this.opacity;\n }\n\n /**\n * Hide (or show) the object\n * @param enable true to hide the object, false to show it again.\n */\n hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this._renderer.updateVisibility();\n }\n\n /**\n * Change the tint of the sprite object.\n *\n * @param rgbOrHexColor The color as a string, in RGB format (\"128;200;255\") or Hex format.\n */\n setColor(rgbOrHexColor: string): void {\n this._renderer.setColor(rgbOrHexColor);\n }\n\n /**\n * Get the tint of the sprite object.\n *\n * @returns The color, in RGB format (\"128;200;255\").\n */\n getColor(): string {\n return this._renderer.getColor();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this._renderer.update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n //Scale and size :\n /**\n * Get the width of the object.\n *\n * @return The width of the object, in pixels.\n */\n getWidth(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getWidth();\n }\n\n /**\n * Get the height of the object.\n *\n * @return The height of the object, in pixels.\n */\n getHeight(): float {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n return this._renderer.getHeight();\n }\n\n setWidth(newWidth: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledWidth = this._renderer.getUnscaledWidth();\n if (unscaledWidth !== 0) {\n this.setScaleX(newWidth / (unscaledWidth * this._preScale));\n }\n }\n\n setHeight(newHeight: float): void {\n if (this._animationFrameDirty) {\n this._updateAnimationFrame();\n }\n const unscaledHeight = this._renderer.getUnscaledHeight();\n if (unscaledHeight !== 0) {\n this.setScaleY(newHeight / (unscaledHeight * this._preScale));\n }\n }\n\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._renderer.update();\n this.invalidateHitboxes();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n //Other :\n /**\n * @param obj The target object\n * @param scene The scene containing the object\n * @deprecated\n */\n turnTowardObject(obj: gdjs.RuntimeObject | null, scene: gdjs.RuntimeScene) {\n if (obj === null) {\n return;\n }\n this.rotateTowardPosition(\n obj.getDrawableX() + obj.getCenterX(),\n obj.getDrawableY() + obj.getCenterY(),\n 0,\n scene\n );\n }\n }\n gdjs.registerObject(\n 'Sprite',\n //Notify gdjs of the object existence.\n gdjs.SpriteRuntimeObject\n );\n\n //Others initialization and internal state management :\n SpriteRuntimeObject.supportsReinitialization = true;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CA6BS,eACG,GAAK,aAMS,CAkBtB,YACE,EACA,EACA,CACA,MAAM,EAAmB,GApB3B,aAAiB,EACjB,aAAiB,EACjB,gBAAsB,EACtB,eAAqB,GACrB,eAAqB,GACrB,aAAiB,IAEjB,eAAmB,EAGnB,0BAAuB,GAWrB,KAAK,oBAAsB,CAAC,CAAC,EAAiB,mBAC9C,KAAK,UAAY,EAAiB,UAAY,EAC9C,KAAK,UAAY,GAAI,GAAK,4BACxB,KACA,GAEF,KAAK,UAAY,GAAI,GAAK,eACxB,EAAiB,WACjB,EAAK,4BAA4B,gCAC/B,EAAkB,UAAU,oBAGhC,KAAK,wBAGL,KAAK,YAGP,aAAa,EAAoC,CAC/C,MAAM,aAAa,GACnB,KAAM,GAAoB,KAAK,uBAC/B,KAAK,UAAU,aAAa,EAAiB,YAC7C,KAAK,QAAU,EACf,KAAK,QAAU,EACf,KAAK,WAAa,EAClB,KAAK,UAAY,GACjB,KAAK,UAAY,GACjB,KAAK,QAAU,IACf,KAAK,oBAAsB,CAAC,CAAC,EAAiB,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