From 9ea06f6b6e09455910bf36d66f8bafeff873efc7 Mon Sep 17 00:00:00 2001 From: LiprikON2 <44316968+LiprikON2@users.noreply.github.com> Date: Sat, 27 Jul 2024 16:02:57 +0300 Subject: [PATCH] fix: enable ai --- .../objects/Sprite/Spaceship/Mob/Mob.ts | 11 +++- .../objects/Sprite/Spaceship/Spaceship.ts | 8 ++- server/package-lock.json | 50 +++++++++++-------- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/client/src/game/scripts/objects/Sprite/Spaceship/Mob/Mob.ts b/client/src/game/scripts/objects/Sprite/Spaceship/Mob/Mob.ts index 8aeb043..52c839b 100644 --- a/client/src/game/scripts/objects/Sprite/Spaceship/Mob/Mob.ts +++ b/client/src/game/scripts/objects/Sprite/Spaceship/Mob/Mob.ts @@ -13,7 +13,7 @@ export class Mob extends Spaceship { isReadyToFire = false; isSleeping = false; isAggresive = true; - disableAI = true; + disableAi = false; readyToFireEvent: Phaser.Time.TimerEvent | null; sleepEvent: Phaser.Time.TimerEvent | null; @@ -68,7 +68,14 @@ export class Mob extends Spaceship { update(time, delta) { super.update(time, delta); - if (this.disableAI) return; + const { x, y } = this.getActionsState(); + + const s = Phaser.Math.Between(0, 200); + // if (s === 444) this.teleport(x + 50, y + 50); + if (s === 111) this.staticBox.setPosition(x + 50, y + 50); + console.log("x,y", x, y); + + if (this.disableAi) return; this.sleep(this.reactionTime); this.exhausts.updateExhaustPosition(); diff --git a/client/src/game/scripts/objects/Sprite/Spaceship/Spaceship.ts b/client/src/game/scripts/objects/Sprite/Spaceship/Spaceship.ts index f56a6b4..e2062cf 100644 --- a/client/src/game/scripts/objects/Sprite/Spaceship/Spaceship.ts +++ b/client/src/game/scripts/objects/Sprite/Spaceship/Spaceship.ts @@ -207,11 +207,11 @@ export class Spaceship extends Sprite { this.scene.physics.world.enable(this.staticBox); // this.staticBox.body.setCollideWorldBounds(true); - this.rotatingBox.pin(this); + this.rotatingBox.pin(this, { syncPosition: false }); this.shields = new Shields(this); this.staticBox.pin(this.shields, { syncRotation: false }); - this.staticBox.pin(this.rotatingBox, { syncRotation: false }); + this.staticBox.pin(this.rotatingBox, { syncPosition: false, syncRotation: false }); // Modules const { modules } = this.atlasMetadata; @@ -264,6 +264,10 @@ export class Spaceship extends Sprite { this.rotatingBox.setDepth(this.depth + 100); this.pilot = new Pilot(); + + for (let i = 0; i < 100; i++) { + this.setPosition(x, y); + } } /** * Destroys not only the sprite itself, but also related objects pinned to its bounding box diff --git a/server/package-lock.json b/server/package-lock.json index ccd6d45..f29647f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -61,6 +61,8 @@ "core-js": "~3.31.0", "immer": "~10.0.2", "lodash": "~4.17.21", + "mobx": "^6.10.0", + "mobx-react-lite": "^4.0.4", "nanoevents": "~8.0.0", "navmesh": "~2.3.1", "phaser": "3.55.2", @@ -69,6 +71,7 @@ "react": "~18.2.0", "react-dom": "~18.2.0", "tabler-icons-react": "~1.48.0", + "ts-mixer": "^6.0.3", "zustand": "~4.3.8" }, "devDependencies": { @@ -2989,6 +2992,20 @@ "node": ">=10" } }, + "node_modules/node-datachannel/node_modules/node-abi/node_modules/semver": { + "version": "7.3.7", + "inBundle": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/node-datachannel/node_modules/npmlog": { "version": "4.1.2", "inBundle": true, @@ -3121,20 +3138,6 @@ "inBundle": true, "license": "MIT" }, - "node_modules/node-datachannel/node_modules/semver": { - "version": "7.5.4", - "inBundle": true, - "license": "ISC", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/node-datachannel/node_modules/set-blocking": { "version": "2.0.0", "inBundle": true, @@ -5168,6 +5171,8 @@ "javascript-obfuscator": "~4.0.2", "lodash": "~4.17.21", "mini-css-extract-plugin": "~2.6.0", + "mobx": "^6.10.0", + "mobx-react-lite": "^4.0.4", "nanoevents": "~8.0.0", "navmesh": "~2.3.1", "netlify-cli": "^15.10.0", @@ -5186,6 +5191,7 @@ "style-loader": "~3.3.3", "tabler-icons-react": "~1.48.0", "ts-loader": "~9.4.4", + "ts-mixer": "^6.0.3", "typescript": "4.5.5", "vitest": "^0.33.0", "webpack": "~5.65.0", @@ -6959,6 +6965,15 @@ "bundled": true, "requires": { "semver": "^7.3.5" + }, + "dependencies": { + "semver": { + "version": "7.3.7", + "bundled": true, + "requires": { + "lru-cache": "^6.0.0" + } + } } }, "npmlog": { @@ -7068,13 +7083,6 @@ "version": "5.1.2", "bundled": true }, - "semver": { - "version": "7.5.4", - "bundled": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, "set-blocking": { "version": "2.0.0", "bundled": true