cyberia 3.2.5 → 3.2.12
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/.github/workflows/engine-cyberia.cd.yml +8 -2
- package/.github/workflows/npmpkg.ci.yml +1 -0
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +2 -2
- package/.vscode/extensions.json +9 -9
- package/.vscode/settings.json +20 -4
- package/CHANGELOG.md +563 -1
- package/CLI-HELP.md +130 -34
- package/Dockerfile +0 -4
- package/README.md +194 -607
- package/bin/build.js +42 -12
- package/bin/build.template.js +187 -0
- package/bin/cyberia.js +1367 -281
- package/bin/deploy.js +582 -3
- package/bin/index.js +1367 -281
- package/bump.config.js +26 -0
- package/conf.js +195 -111
- package/deployment.yaml +6 -222
- package/hardhat/package-lock.json +118 -149
- package/hardhat/package.json +5 -4
- package/jsconfig.json +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -2
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +2 -2
- package/manifests/deployment/dd-cyberia-development/deployment.yaml +6 -222
- package/manifests/deployment/dd-cyberia-development/proxy.yaml +10 -118
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -6
- package/manifests/deployment/dd-test-development/deployment.yaml +138 -66
- package/manifests/deployment/dd-test-development/proxy.yaml +41 -5
- package/manifests/kind-config-dev.yaml +8 -0
- package/manifests/lxd/lxd-admin-profile.yaml +12 -3
- package/manifests/mongodb/pv-pvc.yaml +44 -8
- package/manifests/mongodb/statefulset.yaml +55 -68
- package/manifests/mongodb-4.4/headless-service.yaml +10 -0
- package/manifests/mongodb-4.4/kustomization.yaml +3 -1
- package/manifests/mongodb-4.4/mongodb-nodeport.yaml +17 -0
- package/manifests/mongodb-4.4/pv-pvc.yaml +10 -14
- package/manifests/mongodb-4.4/statefulset.yaml +79 -0
- package/manifests/mongodb-4.4/storage-class.yaml +9 -0
- package/manifests/valkey/statefulset.yaml +1 -1
- package/manifests/valkey/valkey-nodeport.yaml +17 -0
- package/package.json +45 -24
- package/proxy.yaml +10 -118
- package/scripts/ipxe-setup.sh +52 -49
- package/scripts/k3s-node-setup.sh +83 -48
- package/scripts/lxd-vm-setup.sh +193 -8
- package/scripts/maas-nat-firewalld.sh +145 -0
- package/scripts/nat-iptables.sh +103 -18
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +18 -18
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +7 -14
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +38 -33
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +91 -36
- package/src/api/core/core.controller.js +10 -10
- package/src/api/core/core.router.js +19 -14
- package/src/api/core/core.service.js +15 -15
- package/src/api/crypto/crypto.controller.js +8 -8
- package/src/api/crypto/crypto.router.js +18 -12
- package/src/api/crypto/crypto.service.js +11 -11
- package/src/api/cyberia-action/cyberia-action.controller.js +74 -0
- package/src/api/cyberia-action/cyberia-action.model.js +87 -0
- package/src/api/cyberia-action/cyberia-action.router.js +31 -0
- package/src/api/cyberia-action/cyberia-action.service.js +42 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.controller.js +74 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.model.js +99 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.router.js +98 -0
- package/src/api/cyberia-client-hints/cyberia-client-hints.service.js +152 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +13 -13
- package/src/api/cyberia-dialogue/cyberia-dialogue.model.js +11 -11
- package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +25 -20
- package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +22 -22
- package/src/api/cyberia-entity/cyberia-entity.controller.js +10 -10
- package/src/api/cyberia-entity/cyberia-entity.router.js +22 -18
- package/src/api/cyberia-entity/cyberia-entity.service.js +15 -15
- package/src/api/cyberia-instance/cyberia-fallback-world.js +83 -198
- package/src/api/cyberia-instance/cyberia-instance.controller.js +14 -14
- package/src/api/cyberia-instance/cyberia-instance.model.js +3 -0
- package/src/api/cyberia-instance/cyberia-instance.router.js +57 -52
- package/src/api/cyberia-instance/cyberia-instance.service.js +32 -67
- package/src/api/cyberia-instance/cyberia-portal-connector.js +20 -246
- package/src/api/cyberia-instance/cyberia-world-generator.js +505 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +10 -10
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +18 -49
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +22 -18
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +19 -15
- package/src/api/cyberia-map/cyberia-map.controller.js +10 -10
- package/src/api/cyberia-map/cyberia-map.router.js +35 -30
- package/src/api/cyberia-map/cyberia-map.service.js +17 -17
- package/src/api/cyberia-quest/cyberia-quest.controller.js +74 -0
- package/src/api/cyberia-quest/cyberia-quest.model.js +67 -0
- package/src/api/cyberia-quest/cyberia-quest.router.js +31 -0
- package/src/api/cyberia-quest/cyberia-quest.service.js +42 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.controller.js +74 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.model.js +49 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.router.js +31 -0
- package/src/api/cyberia-quest-progress/cyberia-quest-progress.service.js +42 -0
- package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +451 -0
- package/src/api/default/default.controller.js +10 -10
- package/src/api/default/default.router.js +22 -18
- package/src/api/default/default.service.js +15 -15
- package/src/api/document/document.controller.js +12 -12
- package/src/api/document/document.model.js +10 -16
- package/src/api/document/document.router.js +28 -23
- package/src/api/document/document.service.js +100 -23
- package/src/api/file/file.controller.js +8 -8
- package/src/api/file/file.model.js +10 -10
- package/src/api/file/file.router.js +19 -13
- package/src/api/file/file.service.js +45 -43
- package/src/api/instance/instance.controller.js +10 -10
- package/src/api/instance/instance.model.js +4 -10
- package/src/api/instance/instance.router.js +29 -24
- package/src/api/instance/instance.service.js +16 -16
- package/src/api/ipfs/ipfs.controller.js +12 -12
- package/src/api/ipfs/ipfs.model.js +4 -13
- package/src/api/ipfs/ipfs.router.js +21 -16
- package/src/api/ipfs/ipfs.service.js +22 -36
- package/src/api/object-layer/object-layer.controller.js +12 -12
- package/src/api/object-layer/object-layer.model.js +4 -17
- package/src/api/object-layer/object-layer.router.js +512 -507
- package/src/api/object-layer/object-layer.service.js +29 -26
- package/src/api/object-layer-render-frames/object-layer-render-frames.controller.js +10 -10
- package/src/api/object-layer-render-frames/object-layer-render-frames.model.js +6 -16
- package/src/api/object-layer-render-frames/object-layer-render-frames.router.js +22 -18
- package/src/api/object-layer-render-frames/object-layer-render-frames.service.js +19 -15
- package/src/api/test/test.controller.js +8 -8
- package/src/api/test/test.router.js +17 -12
- package/src/api/test/test.service.js +8 -8
- package/src/api/types.js +24 -0
- package/src/api/user/guest.service.js +100 -0
- package/src/api/user/user.controller.js +6 -6
- package/src/api/user/user.model.js +8 -13
- package/src/api/user/user.router.js +297 -288
- package/src/api/user/user.service.js +103 -55
- package/src/cli/baremetal.js +132 -101
- package/src/cli/cluster.js +732 -217
- package/src/cli/db.js +106 -62
- package/src/cli/deploy.js +260 -149
- package/src/cli/fs.js +90 -9
- package/src/cli/image.js +43 -1
- package/src/cli/index.js +106 -16
- package/src/cli/ipfs.js +4 -6
- package/src/cli/kubectl.js +4 -1
- package/src/cli/lxd.js +1099 -223
- package/src/cli/monitor.js +9 -3
- package/src/cli/release.js +336 -86
- package/src/cli/repository.js +136 -53
- package/src/cli/run.js +599 -76
- package/src/cli/secrets.js +11 -2
- package/src/cli/ssh.js +1 -1
- package/src/cli/static.js +43 -115
- package/src/cli/test.js +9 -3
- package/src/client/Cryptokoyn.index.js +18 -21
- package/src/client/CyberiaPortal.index.js +19 -23
- package/src/client/Default.index.js +30 -36
- package/src/client/Itemledger.index.js +20 -26
- package/src/client/Underpost.index.js +19 -23
- package/src/client/components/core/404.js +4 -4
- package/src/client/components/core/500.js +4 -4
- package/src/client/components/core/Account.js +73 -60
- package/src/client/components/core/AgGrid.js +23 -33
- package/src/client/components/core/Alert.js +12 -13
- package/src/client/components/core/AppStore.js +1 -1
- package/src/client/components/core/Auth.js +40 -37
- package/src/client/components/core/Badge.js +7 -13
- package/src/client/components/core/BtnIcon.js +15 -17
- package/src/client/components/core/CalendarCore.js +42 -63
- package/src/client/components/core/Chat.js +13 -15
- package/src/client/components/core/ClientEvents.js +163 -0
- package/src/client/components/core/ColorPaletteElement.js +309 -0
- package/src/client/components/core/Content.js +17 -14
- package/src/client/components/core/Css.js +15 -71
- package/src/client/components/core/CssCore.js +12 -16
- package/src/client/components/core/D3Chart.js +4 -4
- package/src/client/components/core/Docs.js +64 -91
- package/src/client/components/core/DropDown.js +69 -91
- package/src/client/components/core/EventBus.js +96 -0
- package/src/client/components/core/EventsUI.js +14 -17
- package/src/client/components/core/FileExplorer.js +96 -228
- package/src/client/components/core/FullScreen.js +47 -75
- package/src/client/components/core/Input.js +24 -69
- package/src/client/components/core/Keyboard.js +25 -18
- package/src/client/components/core/KeyboardAvoidance.js +145 -0
- package/src/client/components/core/LoadingAnimation.js +25 -31
- package/src/client/components/core/LogIn.js +41 -41
- package/src/client/components/core/LogOut.js +23 -14
- package/src/client/components/core/Modal.js +544 -219
- package/src/client/components/core/NotificationManager.js +14 -18
- package/src/client/components/core/Panel.js +54 -50
- package/src/client/components/core/PanelForm.js +81 -177
- package/src/client/components/core/Polyhedron.js +110 -214
- package/src/client/components/core/PublicProfile.js +39 -32
- package/src/client/components/core/Recover.js +48 -44
- package/src/client/components/core/Responsive.js +88 -32
- package/src/client/components/core/RichText.js +9 -18
- package/src/client/components/core/Router.js +24 -3
- package/src/client/components/core/SearchBox.js +37 -37
- package/src/client/components/core/SignUp.js +39 -30
- package/src/client/components/core/SocketIo.js +31 -2
- package/src/client/components/core/SocketIoHandler.js +6 -6
- package/src/client/components/core/ToggleSwitch.js +8 -20
- package/src/client/components/core/ToolTip.js +5 -17
- package/src/client/components/core/Translate.js +56 -59
- package/src/client/components/core/Validator.js +26 -16
- package/src/client/components/core/Wallet.js +15 -26
- package/src/client/components/core/Worker.js +211 -276
- package/src/client/components/core/windowGetDimensions.js +7 -7
- package/src/client/components/cryptokoyn/{MenuCryptokoyn.js → AppShellCryptokoyn.js} +57 -57
- package/src/client/components/cryptokoyn/CssCryptokoyn.js +15 -15
- package/src/client/components/cryptokoyn/LogInCryptokoyn.js +6 -4
- package/src/client/components/cryptokoyn/LogOutCryptokoyn.js +6 -4
- package/src/client/components/cryptokoyn/RouterCryptokoyn.js +37 -0
- package/src/client/components/cryptokoyn/SettingsCryptokoyn.js +4 -4
- package/src/client/components/cryptokoyn/SignUpCryptokoyn.js +6 -4
- package/src/client/components/cyberia/InstanceEngineCyberia.js +141 -60
- package/src/client/components/cyberia/MapEngineCyberia.js +691 -214
- package/src/client/components/cyberia/ObjectLayerEngine.js +19 -0
- package/src/client/components/cyberia/ObjectLayerEngineModal.js +1204 -94
- package/src/client/components/cyberia/ObjectLayerEngineViewer.js +196 -298
- package/src/client/components/cyberia/SharedDefaultsCyberia.js +330 -0
- package/src/client/components/cyberia-portal/{MenuCyberiaPortal.js → AppShellCyberiaPortal.js} +102 -102
- package/src/client/components/cyberia-portal/CssCyberiaPortal.js +15 -15
- package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +6 -4
- package/src/client/components/cyberia-portal/LogOutCyberiaPortal.js +6 -4
- package/src/client/components/cyberia-portal/MainBodyCyberiaPortal.js +4 -4
- package/src/client/components/cyberia-portal/RouterCyberiaPortal.js +60 -0
- package/src/client/components/cyberia-portal/SettingsCyberiaPortal.js +4 -4
- package/src/client/components/cyberia-portal/SignUpCyberiaPortal.js +6 -4
- package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -4
- package/src/client/components/default/{MenuDefault.js → AppShellDefault.js} +87 -87
- package/src/client/components/default/CssDefault.js +12 -12
- package/src/client/components/default/LogInDefault.js +6 -4
- package/src/client/components/default/LogOutDefault.js +6 -4
- package/src/client/components/default/RouterDefault.js +47 -0
- package/src/client/components/default/SettingsDefault.js +4 -4
- package/src/client/components/default/SignUpDefault.js +6 -4
- package/src/client/components/default/TranslateDefault.js +3 -3
- package/src/client/components/itemledger/{MenuItemledger.js → AppShellItemledger.js} +57 -57
- package/src/client/components/itemledger/CssItemledger.js +15 -15
- package/src/client/components/itemledger/LogInItemledger.js +6 -4
- package/src/client/components/itemledger/LogOutItemledger.js +6 -4
- package/src/client/components/itemledger/RouterItemledger.js +38 -0
- package/src/client/components/itemledger/SettingsItemledger.js +4 -4
- package/src/client/components/itemledger/SignUpItemledger.js +6 -4
- package/src/client/components/itemledger/TranslateItemledger.js +3 -3
- package/src/client/components/underpost/{MenuUnderpost.js → AppShellUnderpost.js} +88 -88
- package/src/client/components/underpost/CssUnderpost.js +14 -14
- package/src/client/components/underpost/CyberpunkBloggerUnderpost.js +4 -4
- package/src/client/components/underpost/DocumentSearchProvider.js +1 -1
- package/src/client/components/underpost/LabGalleryUnderpost.js +12 -15
- package/src/client/components/underpost/LogInUnderpost.js +6 -4
- package/src/client/components/underpost/LogOutUnderpost.js +6 -4
- package/src/client/components/underpost/RouterUnderpost.js +45 -0
- package/src/client/components/underpost/SettingsUnderpost.js +4 -4
- package/src/client/components/underpost/SignUpUnderpost.js +6 -4
- package/src/client/components/underpost/TranslateUnderpost.js +4 -4
- package/src/client/public/cyberia-docs/ACTION-SYSTEM.md +235 -0
- package/src/client/public/cyberia-docs/ARCHITECTURE.md +83 -0
- package/src/client/public/cyberia-docs/CYBERIA-CLI.md +204 -0
- package/src/client/public/cyberia-docs/CYBERIA-CLIENT.md +291 -0
- package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +278 -0
- package/src/client/public/cyberia-docs/CYBERIA.md +259 -0
- package/src/client/public/cyberia-docs/ENTITY-PROFILE.md +241 -0
- package/src/client/public/cyberia-docs/HARDHAT-MODULE.md +300 -0
- package/src/client/public/cyberia-docs/OFF-CHAIN-ECONOMY.md +279 -0
- package/src/client/public/cyberia-docs/QUEST-SYSTEM.md +206 -0
- package/src/client/public/cyberia-docs/ROADMAP.md +240 -0
- package/src/client/public/cyberia-docs/UNDERPOST-PLATFORM.md +106 -0
- package/src/client/public/cyberia-docs/WHITE-PAPER.md +732 -0
- package/src/client/services/atlas-sprite-sheet/atlas-sprite-sheet.service.js +14 -20
- package/src/client/services/core/core.service.js +17 -49
- package/src/client/services/crypto/crypto.service.js +8 -13
- package/src/client/services/cyberia-action/cyberia-action.service.js +99 -0
- package/src/client/services/cyberia-client-hints/cyberia-client-hints.service.js +99 -0
- package/src/client/services/cyberia-dialogue/cyberia-dialogue.service.js +10 -16
- package/src/client/services/cyberia-entity/cyberia-entity.management.js +5 -5
- package/src/client/services/cyberia-entity/cyberia-entity.service.js +10 -16
- package/src/client/services/cyberia-instance/cyberia-instance.management.js +6 -6
- package/src/client/services/cyberia-instance/cyberia-instance.service.js +12 -18
- package/src/client/services/cyberia-instance-conf/cyberia-instance-conf.service.js +10 -16
- package/src/client/services/cyberia-map/cyberia-map.management.js +6 -6
- package/src/client/services/cyberia-map/cyberia-map.service.js +12 -18
- package/src/client/services/cyberia-quest/cyberia-quest.service.js +99 -0
- package/src/client/services/cyberia-quest-progress/cyberia-quest-progress.service.js +99 -0
- package/src/client/services/default/default.management.js +159 -267
- package/src/client/services/default/default.service.js +10 -16
- package/src/client/services/document/document.service.js +14 -19
- package/src/client/services/file/file.service.js +8 -13
- package/src/client/services/instance/instance.management.js +5 -5
- package/src/client/services/instance/instance.service.js +10 -15
- package/src/client/services/ipfs/ipfs.service.js +12 -18
- package/src/client/services/object-layer/object-layer.management.js +12 -12
- package/src/client/services/object-layer/object-layer.service.js +20 -26
- package/src/client/services/object-layer-render-frames/object-layer-render-frames.service.js +10 -16
- package/src/client/services/test/test.service.js +8 -13
- package/src/client/services/user/guest.service.js +86 -0
- package/src/client/services/user/user.management.js +5 -5
- package/src/client/services/user/user.service.js +14 -20
- package/src/client/ssr/body/404.js +3 -3
- package/src/client/ssr/body/500.js +3 -3
- package/src/client/ssr/body/CacheControl.js +5 -2
- package/src/client/ssr/body/DefaultSplashScreen.js +19 -12
- package/src/client/ssr/body/UnderpostDefaultSplashScreen.js +13 -6
- package/src/client/ssr/head/PwaItemledger.js +197 -60
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +19 -20
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +15 -16
- package/src/client/ssr/views/CyberiaServerMetrics.js +982 -0
- package/src/client/ssr/{offline → views}/Maintenance.js +12 -11
- package/src/client/ssr/{offline → views}/NoNetworkConnection.js +3 -3
- package/src/client/ssr/{pages → views}/Test.js +2 -2
- package/src/client/sw/core.sw.js +274 -0
- package/src/db/DataBaseProvider.js +115 -15
- package/src/db/mariadb/MariaDB.js +2 -1
- package/src/db/mongo/MongoBootstrap.js +657 -0
- package/src/db/mongo/MongooseDB.js +129 -21
- package/src/grpc/cyberia/grpc-server.js +185 -105
- package/src/index.js +1 -1
- package/src/runtime/cyberia-client/Dockerfile +101 -0
- package/src/runtime/cyberia-client/Dockerfile.dev +82 -0
- package/src/runtime/cyberia-server/Dockerfile +62 -0
- package/src/runtime/cyberia-server/Dockerfile.dev +71 -0
- package/src/runtime/express/Dockerfile +4 -4
- package/src/runtime/express/Express.js +2 -2
- package/src/runtime/lampp/Dockerfile +8 -7
- package/src/runtime/wp/Dockerfile +11 -17
- package/src/runtime/wp/Wp.js +8 -5
- package/src/server/atlas-sprite-sheet-generator.js +4 -2
- package/src/server/auth.js +2 -2
- package/src/server/client-build-docs.js +46 -47
- package/src/server/client-build.js +371 -132
- package/src/server/client-formatted.js +47 -16
- package/src/server/conf.js +91 -87
- package/src/server/data-query.js +32 -20
- package/src/server/dns.js +22 -0
- package/src/server/ipfs-client.js +232 -91
- package/src/server/object-layer.js +1 -6
- package/src/server/process.js +192 -45
- package/src/server/proxy.js +9 -2
- package/src/server/runtime.js +1 -1
- package/src/server/semantic-layer-generator-floor.js +11 -51
- package/src/server/semantic-layer-generator-resource.js +259 -0
- package/src/server/semantic-layer-generator-skin.js +41 -171
- package/src/server/semantic-layer-generator.js +122 -14
- package/src/server/shape-generator.js +108 -0
- package/src/server/start.js +34 -8
- package/src/server/valkey.js +143 -235
- package/src/ws/IoInterface.js +16 -16
- package/src/ws/core/channels/core.ws.chat.js +11 -11
- package/src/ws/core/channels/core.ws.mailer.js +29 -29
- package/src/ws/core/channels/core.ws.stream.js +19 -19
- package/src/ws/core/core.ws.connection.js +8 -8
- package/src/ws/core/core.ws.server.js +6 -5
- package/src/ws/default/channels/default.ws.main.js +10 -10
- package/src/ws/default/default.ws.connection.js +4 -4
- package/src/ws/default/default.ws.server.js +4 -3
- package/tsconfig.docs.json +15 -0
- package/typedoc.dd-cyberia.json +29 -0
- package/typedoc.json +29 -0
- package/WHITE-PAPER.md +0 -1540
- package/bin/file.js +0 -196
- package/bin/vs.js +0 -74
- package/bin/zed.js +0 -84
- package/hardhat/README.md +0 -531
- package/hardhat/WHITE-PAPER.md +0 -1540
- package/jsdoc.dd-cyberia.json +0 -68
- package/jsdoc.json +0 -68
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +0 -413
- package/src/api/object-layer/README.md +0 -672
- package/src/client/components/core/ColorPalette.js +0 -5267
- package/src/client/components/core/JoyStick.js +0 -80
- package/src/client/components/cryptokoyn/RoutesCryptokoyn.js +0 -39
- package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +0 -223
- package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +0 -62
- package/src/client/components/cyberia-portal/ServerCyberiaPortal.js +0 -136
- package/src/client/components/default/RoutesDefault.js +0 -49
- package/src/client/components/itemledger/RoutesItemledger.js +0 -40
- package/src/client/components/underpost/RoutesUnderpost.js +0 -47
- package/src/client/ssr/email/DefaultRecoverEmail.js +0 -21
- package/src/client/ssr/email/DefaultVerifyEmail.js +0 -17
- package/src/client/ssr/pages/CyberiaServerMetrics.js +0 -461
- package/src/client/sw/default.sw.js +0 -127
- package/src/client/sw/template.sw.js +0 -84
- package/src/grpc/cyberia/OFF_CHAIN_ECONOMY.md +0 -305
- package/src/grpc/cyberia/README.md +0 -326
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedural World Generator — pure-function module.
|
|
3
|
+
*
|
|
4
|
+
* Centralises every procedural entity generator used by the Cyberia Online
|
|
5
|
+
* engine (obstacles, foreground, resources, floors, portals, bots) together
|
|
6
|
+
* with the shared helpers they need (colour conversion, random numbers,
|
|
7
|
+
* occupancy-grid placement).
|
|
8
|
+
*
|
|
9
|
+
* Consumers:
|
|
10
|
+
* - cyberia-fallback-world.js (full fallback world)
|
|
11
|
+
* - cyberia-portal-connector.js (no generators — uses colour/random helpers only)
|
|
12
|
+
* - cyberia-instance.service.js (optional entity back-fill in portalConnect endpoint)
|
|
13
|
+
*
|
|
14
|
+
* All exported functions are stateless and synchronous.
|
|
15
|
+
*
|
|
16
|
+
* @module src/api/cyberia-instance/cyberia-world-generator
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
ENTITY_TYPE_DEFAULTS,
|
|
21
|
+
RESOURCE_ENTITY_TYPE_DEFAULTS,
|
|
22
|
+
DefaultCyberiaItems,
|
|
23
|
+
ITEM_TYPES,
|
|
24
|
+
} from '../cyberia-server-defaults/cyberia-server-defaults.js';
|
|
25
|
+
|
|
26
|
+
import { PORTAL_MODES, PORTAL_MODE_COLOR_KEY, EXTRA_PORTAL_MODES } from './cyberia-portal-connector.js';
|
|
27
|
+
|
|
28
|
+
// ── Color helpers ────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Convert a { r, g, b, a } palette entry to an `rgba(…)` CSS string.
|
|
32
|
+
* @param {{ r: number, g: number, b: number, a: number }} c
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
const colorToRgba = (c) => `rgba(${c.r}, ${c.g}, ${c.b}, ${c.a / 255})`;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Look up a palette entry by key from a colours array.
|
|
39
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors
|
|
40
|
+
* @param {string} key
|
|
41
|
+
* @returns {{ r: number, g: number, b: number, a: number } | undefined}
|
|
42
|
+
*/
|
|
43
|
+
const findColor = (colors, key) => colors.find((c) => c.key === key);
|
|
44
|
+
|
|
45
|
+
// ── Random helpers ───────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Return a random integer in [min, max] (inclusive).
|
|
49
|
+
* @param {number} min
|
|
50
|
+
* @param {number} max
|
|
51
|
+
* @returns {number}
|
|
52
|
+
*/
|
|
53
|
+
const randInt = (min, max) => min + Math.floor(Math.random() * (max - min + 1));
|
|
54
|
+
|
|
55
|
+
// ── Entity count ranges ──────────────────────────────────────────────────────
|
|
56
|
+
// [min, max] — actual count is random within range on each generation call.
|
|
57
|
+
|
|
58
|
+
const OBSTACLE_RANGE = [20, 35];
|
|
59
|
+
const FOREGROUND_RANGE = [10, 20];
|
|
60
|
+
const BOT_RANGE = [8, 16];
|
|
61
|
+
const RESOURCE_RANGE = [6, 12];
|
|
62
|
+
const BOT_WEAPON_CHANCE = 0.6;
|
|
63
|
+
const PORTAL_DIM_RANGE = [2, 3];
|
|
64
|
+
const PORTAL_COUNT_RANGE = [2, 4];
|
|
65
|
+
|
|
66
|
+
// ── Bot defaults ─────────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
const DEFAULT_BOT_DIM_RANGE = [2, 3];
|
|
69
|
+
const DEFAULT_FLOOR_TILE_DIM = 4;
|
|
70
|
+
|
|
71
|
+
function pickDefaultResourceItemIds() {
|
|
72
|
+
const resourceBuilds = RESOURCE_ENTITY_TYPE_DEFAULTS.filter((build) => build.liveItemIds?.length);
|
|
73
|
+
if (resourceBuilds.length === 0) {
|
|
74
|
+
return ['wood'];
|
|
75
|
+
}
|
|
76
|
+
const build = resourceBuilds[randInt(0, resourceBuilds.length - 1)];
|
|
77
|
+
return [...build.liveItemIds];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** NPC skin pool — all items with type 'skin' from DefaultCyberiaItems. */
|
|
81
|
+
const BOT_SKIN_POOL = DefaultCyberiaItems.filter((e) => e.item.type === ITEM_TYPES.skin).map((e) => e.item.id);
|
|
82
|
+
|
|
83
|
+
// ── Occupancy grid ───────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 2D boolean grid that tracks which cells are blocked (obstacle / placed entity).
|
|
87
|
+
* Used to find valid walkable positions when placing portals and bots.
|
|
88
|
+
*/
|
|
89
|
+
class OccupancyGrid {
|
|
90
|
+
/**
|
|
91
|
+
* @param {number} width Grid columns.
|
|
92
|
+
* @param {number} height Grid rows.
|
|
93
|
+
*/
|
|
94
|
+
constructor(width, height) {
|
|
95
|
+
this.width = width;
|
|
96
|
+
this.height = height;
|
|
97
|
+
// false = walkable, true = blocked
|
|
98
|
+
this.cells = Array.from({ length: height }, () => new Array(width).fill(false));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Mark a rectangular region as blocked.
|
|
103
|
+
* @param {number} x
|
|
104
|
+
* @param {number} y
|
|
105
|
+
* @param {number} w
|
|
106
|
+
* @param {number} h
|
|
107
|
+
*/
|
|
108
|
+
block(x, y, w, h) {
|
|
109
|
+
for (let row = y; row < y + h && row < this.height; row++) {
|
|
110
|
+
for (let col = x; col < x + w && col < this.width; col++) {
|
|
111
|
+
if (row >= 0 && col >= 0) this.cells[row][col] = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Check whether a rectangle fits entirely within walkable (unblocked) cells.
|
|
118
|
+
* @param {number} x
|
|
119
|
+
* @param {number} y
|
|
120
|
+
* @param {number} w
|
|
121
|
+
* @param {number} h
|
|
122
|
+
* @returns {boolean}
|
|
123
|
+
*/
|
|
124
|
+
fits(x, y, w, h) {
|
|
125
|
+
if (x < 0 || y < 0 || x + w > this.width || y + h > this.height) return false;
|
|
126
|
+
for (let row = y; row < y + h; row++) {
|
|
127
|
+
for (let col = x; col < x + w; col++) {
|
|
128
|
+
if (this.cells[row][col]) return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Find a random walkable position for a rectangle of given dimensions.
|
|
136
|
+
* Tries up to `maxAttempts` random positions before giving up.
|
|
137
|
+
* @param {number} w
|
|
138
|
+
* @param {number} h
|
|
139
|
+
* @param {number} [maxAttempts=200]
|
|
140
|
+
* @returns {{ x: number, y: number } | null} Position or null if no fit found.
|
|
141
|
+
*/
|
|
142
|
+
findPosition(w, h, maxAttempts = 200) {
|
|
143
|
+
const maxX = Math.max(0, this.width - w);
|
|
144
|
+
const maxY = Math.max(0, this.height - h);
|
|
145
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
146
|
+
const x = randInt(0, maxX);
|
|
147
|
+
const y = randInt(0, maxY);
|
|
148
|
+
if (this.fits(x, y, w, h)) return { x, y };
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Populate the grid from an array of obstacle entities.
|
|
155
|
+
* @param {Array<{ initCellX: number, initCellY: number, dimX: number, dimY: number }>} obstacles
|
|
156
|
+
*/
|
|
157
|
+
addObstacles(obstacles) {
|
|
158
|
+
for (const o of obstacles) {
|
|
159
|
+
this.block(o.initCellX, o.initCellY, o.dimX, o.dimY);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ── Procedural entity generators ─────────────────────────────────────────────
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Generate floor tiles that cover the entire map grid.
|
|
168
|
+
* Floor is NOT random — it tiles deterministically so every cell is covered.
|
|
169
|
+
*
|
|
170
|
+
* @param {{ gridX: number, gridY: number }} mapDims
|
|
171
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors
|
|
172
|
+
* @param {object} [opts]
|
|
173
|
+
* @param {number} [opts.tileDim=4] Floor tile size in cells.
|
|
174
|
+
* @returns {object[]}
|
|
175
|
+
*/
|
|
176
|
+
function generateFloorEntities(mapDims, colors, opts = {}) {
|
|
177
|
+
const { tileDim = DEFAULT_FLOOR_TILE_DIM } = opts;
|
|
178
|
+
const floorDefault = ENTITY_TYPE_DEFAULTS.find((d) => d.entityType === 'floor');
|
|
179
|
+
const floorItemIds = floorDefault?.liveItemIds?.length ? [...floorDefault.liveItemIds] : [];
|
|
180
|
+
const floorColor = findColor(colors, 'FLOOR');
|
|
181
|
+
const rgba = floorColor ? colorToRgba(floorColor) : '';
|
|
182
|
+
|
|
183
|
+
const entities = [];
|
|
184
|
+
for (let y = 0; y < mapDims.gridY; y += tileDim) {
|
|
185
|
+
for (let x = 0; x < mapDims.gridX; x += tileDim) {
|
|
186
|
+
entities.push({
|
|
187
|
+
entityType: 'floor',
|
|
188
|
+
initCellX: x,
|
|
189
|
+
initCellY: y,
|
|
190
|
+
dimX: Math.min(tileDim, mapDims.gridX - x),
|
|
191
|
+
dimY: Math.min(tileDim, mapDims.gridY - y),
|
|
192
|
+
color: rgba,
|
|
193
|
+
objectLayerItemIds: floorItemIds,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return entities;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Generate procedural obstacle entities for a map.
|
|
202
|
+
*
|
|
203
|
+
* @param {{ gridX: number, gridY: number }} mapDims Map grid dimensions.
|
|
204
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors Palette.
|
|
205
|
+
* @param {object} [opts]
|
|
206
|
+
* @param {number} [opts.count] Override count (ignores range).
|
|
207
|
+
* @param {number} [opts.minDim=1] Minimum obstacle width/height (cells).
|
|
208
|
+
* @param {number} [opts.maxDim=4] Maximum obstacle width/height (cells).
|
|
209
|
+
* @returns {object[]} Array of CyberiaEntity plain objects.
|
|
210
|
+
*/
|
|
211
|
+
function generateObstacles(mapDims, colors, opts = {}) {
|
|
212
|
+
const { minDim = 1, maxDim = 4 } = opts;
|
|
213
|
+
const count = opts.count ?? randInt(OBSTACLE_RANGE[0], OBSTACLE_RANGE[1]);
|
|
214
|
+
const { gridX, gridY } = mapDims;
|
|
215
|
+
|
|
216
|
+
const obstacleColor = findColor(colors, 'OBSTACLE');
|
|
217
|
+
const rgba = obstacleColor ? colorToRgba(obstacleColor) : 'rgba(80, 80, 80, 1)';
|
|
218
|
+
|
|
219
|
+
const entities = [];
|
|
220
|
+
for (let i = 0; i < count; i++) {
|
|
221
|
+
const dimX = randInt(minDim, maxDim);
|
|
222
|
+
const dimY = randInt(minDim, maxDim);
|
|
223
|
+
const maxX = Math.max(0, gridX - dimX);
|
|
224
|
+
const maxY = Math.max(0, gridY - dimY);
|
|
225
|
+
entities.push({
|
|
226
|
+
entityType: 'obstacle',
|
|
227
|
+
initCellX: randInt(0, maxX),
|
|
228
|
+
initCellY: randInt(0, maxY),
|
|
229
|
+
dimX,
|
|
230
|
+
dimY,
|
|
231
|
+
color: rgba,
|
|
232
|
+
objectLayerItemIds: [],
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return entities;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Generate procedural foreground entities for a map.
|
|
240
|
+
*
|
|
241
|
+
* @param {{ gridX: number, gridY: number }} mapDims Map grid dimensions.
|
|
242
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors Palette.
|
|
243
|
+
* @param {object} [opts]
|
|
244
|
+
* @param {number} [opts.count] Override count (ignores range).
|
|
245
|
+
* @param {number} [opts.minDim=2] Minimum foreground width/height (cells).
|
|
246
|
+
* @param {number} [opts.maxDim=6] Maximum foreground width/height (cells).
|
|
247
|
+
* @returns {object[]} Array of CyberiaEntity plain objects.
|
|
248
|
+
*/
|
|
249
|
+
function generateForeground(mapDims, colors, opts = {}) {
|
|
250
|
+
const { minDim = 2, maxDim = 6 } = opts;
|
|
251
|
+
const count = opts.count ?? randInt(FOREGROUND_RANGE[0], FOREGROUND_RANGE[1]);
|
|
252
|
+
const { gridX, gridY } = mapDims;
|
|
253
|
+
|
|
254
|
+
const fgColor = findColor(colors, 'FOREGROUND');
|
|
255
|
+
const rgba = fgColor ? colorToRgba(fgColor) : 'rgba(200, 200, 200, 0.31)';
|
|
256
|
+
|
|
257
|
+
const entities = [];
|
|
258
|
+
for (let i = 0; i < count; i++) {
|
|
259
|
+
const dimX = randInt(minDim, maxDim);
|
|
260
|
+
const dimY = randInt(minDim, maxDim);
|
|
261
|
+
const maxX = Math.max(0, gridX - dimX);
|
|
262
|
+
const maxY = Math.max(0, gridY - dimY);
|
|
263
|
+
entities.push({
|
|
264
|
+
entityType: 'foreground',
|
|
265
|
+
initCellX: randInt(0, maxX),
|
|
266
|
+
initCellY: randInt(0, maxY),
|
|
267
|
+
dimX,
|
|
268
|
+
dimY,
|
|
269
|
+
color: rgba,
|
|
270
|
+
objectLayerItemIds: [],
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return entities;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Generate procedural resource entities for a map.
|
|
278
|
+
*
|
|
279
|
+
* Resources are static, exploitable entities (wood, minerals, etc.).
|
|
280
|
+
* They use the RESOURCE palette colour as fallback and are placed
|
|
281
|
+
* on walkable cells via the occupancy grid when provided.
|
|
282
|
+
*
|
|
283
|
+
* @param {{ gridX: number, gridY: number }} mapDims Map grid dimensions.
|
|
284
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors Palette.
|
|
285
|
+
* @param {object} [opts]
|
|
286
|
+
* @param {number} [opts.count] Override count (ignores range).
|
|
287
|
+
* @param {number} [opts.dim=2] Resource width/height (cells).
|
|
288
|
+
* @param {number} [opts.maxLife=80] Hit-points before destruction.
|
|
289
|
+
* @param {string[]} [opts.itemIds] Object layer item IDs (default: resource liveItemIds from instance defaults).
|
|
290
|
+
* @param {OccupancyGrid} [opts.grid] If provided, places resources only on walkable cells.
|
|
291
|
+
* @returns {object[]} Array of CyberiaEntity plain objects.
|
|
292
|
+
*/
|
|
293
|
+
function generateResources(mapDims, colors, opts = {}) {
|
|
294
|
+
const { dim = 2, maxLife = 80 } = opts;
|
|
295
|
+
const count = opts.count ?? randInt(RESOURCE_RANGE[0], RESOURCE_RANGE[1]);
|
|
296
|
+
const fixedItemIds = opts.itemIds != null ? [...opts.itemIds] : null;
|
|
297
|
+
const resColor = findColor(colors, 'RESOURCE');
|
|
298
|
+
const rgba = resColor ? colorToRgba(resColor) : 'rgba(100, 180, 80, 1)';
|
|
299
|
+
|
|
300
|
+
const entities = [];
|
|
301
|
+
for (let i = 0; i < count; i++) {
|
|
302
|
+
let cellX, cellY;
|
|
303
|
+
if (opts.grid) {
|
|
304
|
+
const pos = opts.grid.findPosition(dim, dim);
|
|
305
|
+
if (!pos) continue;
|
|
306
|
+
opts.grid.block(pos.x, pos.y, dim, dim);
|
|
307
|
+
cellX = pos.x;
|
|
308
|
+
cellY = pos.y;
|
|
309
|
+
} else {
|
|
310
|
+
const maxX = Math.max(0, mapDims.gridX - dim);
|
|
311
|
+
const maxY = Math.max(0, mapDims.gridY - dim);
|
|
312
|
+
cellX = randInt(0, maxX);
|
|
313
|
+
cellY = randInt(0, maxY);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
entities.push({
|
|
317
|
+
entityType: 'resource',
|
|
318
|
+
initCellX: cellX,
|
|
319
|
+
initCellY: cellY,
|
|
320
|
+
dimX: dim,
|
|
321
|
+
dimY: dim,
|
|
322
|
+
color: rgba,
|
|
323
|
+
objectLayerItemIds: fixedItemIds ? [...fixedItemIds] : pickDefaultResourceItemIds(),
|
|
324
|
+
maxLife,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return entities;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Generate a portal entity at a random walkable position with random dimensions.
|
|
332
|
+
*
|
|
333
|
+
* @param {{ gridX: number, gridY: number }} mapDims
|
|
334
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors
|
|
335
|
+
* @param {OccupancyGrid} [grid] If provided, places portal only on walkable cells and marks them blocked.
|
|
336
|
+
* @param {string} [portalSubtype] One of PORTAL_MODE_LIST values. Determines the portal colour.
|
|
337
|
+
* @returns {object|null} Portal entity or null if no valid position found.
|
|
338
|
+
*/
|
|
339
|
+
function generatePortalEntity(mapDims, colors, grid, portalSubtype) {
|
|
340
|
+
const colorKey = portalSubtype ? PORTAL_MODE_COLOR_KEY[portalSubtype] : 'PORTAL';
|
|
341
|
+
const portalColor = findColor(colors, colorKey) || findColor(colors, 'PORTAL');
|
|
342
|
+
const rgba = portalColor ? colorToRgba(portalColor) : 'rgba(0, 200, 200, 1)';
|
|
343
|
+
const dimX = randInt(PORTAL_DIM_RANGE[0], PORTAL_DIM_RANGE[1]);
|
|
344
|
+
const dimY = randInt(PORTAL_DIM_RANGE[0], PORTAL_DIM_RANGE[1]);
|
|
345
|
+
|
|
346
|
+
if (grid) {
|
|
347
|
+
const pos = grid.findPosition(dimX, dimY);
|
|
348
|
+
if (!pos) return null;
|
|
349
|
+
grid.block(pos.x, pos.y, dimX, dimY);
|
|
350
|
+
return {
|
|
351
|
+
entityType: 'portal',
|
|
352
|
+
portalSubtype: portalSubtype || 'inter-portal',
|
|
353
|
+
initCellX: pos.x,
|
|
354
|
+
initCellY: pos.y,
|
|
355
|
+
dimX,
|
|
356
|
+
dimY,
|
|
357
|
+
color: rgba,
|
|
358
|
+
objectLayerItemIds: [],
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const maxX = Math.max(0, mapDims.gridX - dimX);
|
|
363
|
+
const maxY = Math.max(0, mapDims.gridY - dimY);
|
|
364
|
+
return {
|
|
365
|
+
entityType: 'portal',
|
|
366
|
+
portalSubtype: portalSubtype || 'inter-portal',
|
|
367
|
+
initCellX: randInt(0, maxX),
|
|
368
|
+
initCellY: randInt(0, maxY),
|
|
369
|
+
dimX,
|
|
370
|
+
dimY,
|
|
371
|
+
color: rgba,
|
|
372
|
+
objectLayerItemIds: [],
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Generate a random number of portal entities for a map, each with a
|
|
378
|
+
* randomly assigned portal subtype (and corresponding colour).
|
|
379
|
+
*
|
|
380
|
+
* @param {{ gridX: number, gridY: number }} mapDims
|
|
381
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors
|
|
382
|
+
* @param {object} [opts]
|
|
383
|
+
* @param {number} [opts.count] Override count (ignores range).
|
|
384
|
+
* @param {OccupancyGrid} [opts.grid] If provided, places portals only on walkable cells.
|
|
385
|
+
* @returns {object[]}
|
|
386
|
+
*/
|
|
387
|
+
function generatePortalEntities(mapDims, colors, opts = {}) {
|
|
388
|
+
const count = opts.count ?? randInt(PORTAL_COUNT_RANGE[0], PORTAL_COUNT_RANGE[1]);
|
|
389
|
+
const entities = [];
|
|
390
|
+
for (let i = 0; i < count; i++) {
|
|
391
|
+
// First portal is always inter-portal (reserved for the ring topology);
|
|
392
|
+
// extra portals get a random non-ring subtype.
|
|
393
|
+
const subtype =
|
|
394
|
+
i === 0 ? PORTAL_MODES.INTER_PORTAL : EXTRA_PORTAL_MODES[Math.floor(Math.random() * EXTRA_PORTAL_MODES.length)];
|
|
395
|
+
const portal = generatePortalEntity(mapDims, colors, opts.grid, subtype);
|
|
396
|
+
if (portal) entities.push(portal);
|
|
397
|
+
}
|
|
398
|
+
return entities;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Generate bot entities for a map.
|
|
403
|
+
*
|
|
404
|
+
* @param {{ gridX: number, gridY: number }} mapDims
|
|
405
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors
|
|
406
|
+
* @param {object} [opts]
|
|
407
|
+
* @param {number} [opts.count] Override count (ignores range).
|
|
408
|
+
* @param {number} [opts.spawnRadius]
|
|
409
|
+
* @param {number} [opts.aggroRange]
|
|
410
|
+
* @param {number} [opts.maxLife]
|
|
411
|
+
* @param {OccupancyGrid} [opts.grid] If provided, places bots only on walkable cells.
|
|
412
|
+
* @returns {object[]}
|
|
413
|
+
*/
|
|
414
|
+
function generateBots(mapDims, colors, opts = {}) {
|
|
415
|
+
const count = opts.count ?? randInt(BOT_RANGE[0], BOT_RANGE[1]);
|
|
416
|
+
const { spawnRadius = 5, aggroRange = 10, maxLife = 100 } = opts;
|
|
417
|
+
const botColor = findColor(colors, 'BOT');
|
|
418
|
+
const rgba = botColor ? colorToRgba(botColor) : 'rgba(255, 128, 0, 1)';
|
|
419
|
+
|
|
420
|
+
const entities = [];
|
|
421
|
+
for (let i = 0; i < count; i++) {
|
|
422
|
+
const dim = randInt(DEFAULT_BOT_DIM_RANGE[0], DEFAULT_BOT_DIM_RANGE[1]);
|
|
423
|
+
|
|
424
|
+
let cellX, cellY;
|
|
425
|
+
if (opts.grid) {
|
|
426
|
+
const pos = opts.grid.findPosition(dim, dim);
|
|
427
|
+
if (!pos) continue;
|
|
428
|
+
opts.grid.block(pos.x, pos.y, dim, dim);
|
|
429
|
+
cellX = pos.x;
|
|
430
|
+
cellY = pos.y;
|
|
431
|
+
} else {
|
|
432
|
+
const maxX = Math.max(0, mapDims.gridX - dim);
|
|
433
|
+
const maxY = Math.max(0, mapDims.gridY - dim);
|
|
434
|
+
cellX = randInt(0, maxX);
|
|
435
|
+
cellY = randInt(0, maxY);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const skin = BOT_SKIN_POOL[Math.floor(Math.random() * BOT_SKIN_POOL.length)];
|
|
439
|
+
const hasWeapon = Math.random() < BOT_WEAPON_CHANCE;
|
|
440
|
+
const itemIds = hasWeapon ? [skin, 'atlas_pistol_mk2'] : [skin];
|
|
441
|
+
|
|
442
|
+
entities.push({
|
|
443
|
+
entityType: 'bot',
|
|
444
|
+
initCellX: cellX,
|
|
445
|
+
initCellY: cellY,
|
|
446
|
+
dimX: dim,
|
|
447
|
+
dimY: dim,
|
|
448
|
+
color: rgba,
|
|
449
|
+
objectLayerItemIds: itemIds,
|
|
450
|
+
spawnRadius,
|
|
451
|
+
aggroRange,
|
|
452
|
+
maxLife,
|
|
453
|
+
lifeRegen: 0,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return entities;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Generate all procedural fallback entities (obstacles + foreground + resources) for a map.
|
|
461
|
+
*
|
|
462
|
+
* @param {{ gridX: number, gridY: number }} mapDims
|
|
463
|
+
* @param {Array<{ key: string, r: number, g: number, b: number, a: number }>} colors
|
|
464
|
+
* @param {object} [opts]
|
|
465
|
+
* @param {number} [opts.obstacleCount]
|
|
466
|
+
* @param {number} [opts.foregroundCount]
|
|
467
|
+
* @param {number} [opts.resourceCount]
|
|
468
|
+
* @param {OccupancyGrid} [opts.grid]
|
|
469
|
+
* @returns {{ obstacles: object[], foreground: object[], resources: object[] }}
|
|
470
|
+
*/
|
|
471
|
+
function generateProceduralEntities(mapDims, colors, opts = {}) {
|
|
472
|
+
return {
|
|
473
|
+
obstacles: generateObstacles(mapDims, colors, { count: opts.obstacleCount }),
|
|
474
|
+
foreground: generateForeground(mapDims, colors, { count: opts.foregroundCount }),
|
|
475
|
+
resources: generateResources(mapDims, colors, { count: opts.resourceCount, grid: opts.grid }),
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// ── Public API ───────────────────────────────────────────────────────────────
|
|
480
|
+
|
|
481
|
+
export {
|
|
482
|
+
// Helpers
|
|
483
|
+
colorToRgba,
|
|
484
|
+
findColor,
|
|
485
|
+
randInt,
|
|
486
|
+
// Placement
|
|
487
|
+
OccupancyGrid,
|
|
488
|
+
// Generators
|
|
489
|
+
generateFloorEntities,
|
|
490
|
+
generateObstacles,
|
|
491
|
+
generateForeground,
|
|
492
|
+
generateResources,
|
|
493
|
+
generatePortalEntity,
|
|
494
|
+
generatePortalEntities,
|
|
495
|
+
generateBots,
|
|
496
|
+
generateProceduralEntities,
|
|
497
|
+
// Ranges
|
|
498
|
+
OBSTACLE_RANGE,
|
|
499
|
+
FOREGROUND_RANGE,
|
|
500
|
+
BOT_RANGE,
|
|
501
|
+
RESOURCE_RANGE,
|
|
502
|
+
BOT_WEAPON_CHANCE,
|
|
503
|
+
PORTAL_DIM_RANGE,
|
|
504
|
+
PORTAL_COUNT_RANGE,
|
|
505
|
+
};
|
|
@@ -3,8 +3,8 @@ import { CyberiaInstanceConfService } from './cyberia-instance-conf.service.js';
|
|
|
3
3
|
|
|
4
4
|
const logger = loggerFactory(import.meta);
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
post
|
|
6
|
+
class CyberiaInstanceConfController {
|
|
7
|
+
static post = async (req, res, options) => {
|
|
8
8
|
try {
|
|
9
9
|
const result = await CyberiaInstanceConfService.post(req, res, options);
|
|
10
10
|
return res.status(200).json({
|
|
@@ -18,8 +18,8 @@ const CyberiaInstanceConfController = {
|
|
|
18
18
|
message: error.message,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
}
|
|
22
|
-
get
|
|
21
|
+
};
|
|
22
|
+
static get = async (req, res, options) => {
|
|
23
23
|
try {
|
|
24
24
|
const { page, limit } = req.query;
|
|
25
25
|
const result = await CyberiaInstanceConfService.get(
|
|
@@ -38,8 +38,8 @@ const CyberiaInstanceConfController = {
|
|
|
38
38
|
message: error.message,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
}
|
|
42
|
-
put
|
|
41
|
+
};
|
|
42
|
+
static put = async (req, res, options) => {
|
|
43
43
|
try {
|
|
44
44
|
const result = await CyberiaInstanceConfService.put(req, res, options);
|
|
45
45
|
return res.status(200).json({
|
|
@@ -53,8 +53,8 @@ const CyberiaInstanceConfController = {
|
|
|
53
53
|
message: error.message,
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
}
|
|
57
|
-
delete
|
|
56
|
+
};
|
|
57
|
+
static delete = async (req, res, options) => {
|
|
58
58
|
try {
|
|
59
59
|
const result = await CyberiaInstanceConfService.delete(req, res, options);
|
|
60
60
|
return res.status(200).json({
|
|
@@ -68,7 +68,7 @@ const CyberiaInstanceConfController = {
|
|
|
68
68
|
message: error.message,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
73
|
|
|
74
74
|
export { CyberiaInstanceConfController };
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { Schema, model } from 'mongoose';
|
|
2
|
-
import { CYBERIA_INSTANCE_CONF_DEFAULTS as D } from '
|
|
3
|
-
|
|
4
|
-
const ColorEntrySchema = new Schema(
|
|
5
|
-
{
|
|
6
|
-
key: { type: String, required: true },
|
|
7
|
-
r: { type: Number, default: 0 },
|
|
8
|
-
g: { type: Number, default: 0 },
|
|
9
|
-
b: { type: Number, default: 0 },
|
|
10
|
-
a: { type: Number, default: 255 },
|
|
11
|
-
},
|
|
12
|
-
{ _id: false },
|
|
13
|
-
);
|
|
2
|
+
import { CYBERIA_INSTANCE_CONF_DEFAULTS as D } from '../cyberia-server-defaults/cyberia-server-defaults.js';
|
|
14
3
|
|
|
15
4
|
// ObjectLayer inventory slot: itemId + whether it starts active + initial quantity.
|
|
16
5
|
// Used by EntityDefaultSchema.defaultObjectLayers.
|
|
@@ -23,6 +12,9 @@ const ObjectLayerSlotSchema = new Schema(
|
|
|
23
12
|
{ _id: false },
|
|
24
13
|
);
|
|
25
14
|
|
|
15
|
+
// Per-entity-type simulation defaults. ONLY authoritative item-id wiring
|
|
16
|
+
// lives here — presentation (palette, colour keys) is the client's
|
|
17
|
+
// responsibility and travels through the CyberiaClientHints REST contract.
|
|
26
18
|
const EntityDefaultSchema = new Schema(
|
|
27
19
|
{
|
|
28
20
|
// Entity category string (matches entity_type_str / bot Behavior in game engine)
|
|
@@ -30,10 +22,10 @@ const EntityDefaultSchema = new Schema(
|
|
|
30
22
|
// Default ObjectLayer item IDs when the entity is alive and carries no assigned items.
|
|
31
23
|
liveItemIds: { type: [String], default: [] },
|
|
32
24
|
// Default ObjectLayer item IDs for the dead / ghost / respawning state.
|
|
33
|
-
// Empty array = use liveItemIds solid fill color.
|
|
34
25
|
deadItemIds: { type: [String], default: [] },
|
|
35
|
-
//
|
|
36
|
-
|
|
26
|
+
// Resource-only inventory items granted on extraction/depletion.
|
|
27
|
+
// These are not auto-activated on the entity itself.
|
|
28
|
+
dropItemIds: { type: [String], default: [] },
|
|
37
29
|
// Full default ObjectLayer inventory for this entity type.
|
|
38
30
|
// Each entry specifies itemId, whether it starts active, and its initial quantity.
|
|
39
31
|
// The coin slot must always have active:false — coins are non-activable.
|
|
@@ -52,26 +44,14 @@ const SkillConfigEntrySchema = new Schema(
|
|
|
52
44
|
);
|
|
53
45
|
|
|
54
46
|
// ── StatusIconEntrySchema ────────────────────────────────────────────────────
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
r: { type: Number, default: 100 },
|
|
61
|
-
g: { type: Number, default: 100 },
|
|
62
|
-
b: { type: Number, default: 100 },
|
|
63
|
-
a: { type: Number, default: 200 },
|
|
64
|
-
},
|
|
65
|
-
{ _id: false },
|
|
66
|
-
);
|
|
67
|
-
|
|
47
|
+
// Numeric Entity Status Indicator (ESI) IDs. The Go server stamps one of
|
|
48
|
+
// these u8 IDs on every entity in the AOI binary wire format. Visual
|
|
49
|
+
// resolution (icon stem, border colour, bounce) is the C client's job and
|
|
50
|
+
// arrives through the /api/cyberia-client-hints REST contract — NOT here.
|
|
68
51
|
const StatusIconEntrySchema = new Schema(
|
|
69
52
|
{
|
|
70
53
|
id: { type: Number, required: true },
|
|
71
54
|
name: { type: String, default: '' },
|
|
72
|
-
iconId: { type: String, default: null },
|
|
73
|
-
bounce: { type: Boolean, default: false },
|
|
74
|
-
borderColor: { type: StatusIconBorderColorSchema },
|
|
75
55
|
description: { type: String, default: '' },
|
|
76
56
|
},
|
|
77
57
|
{ _id: false },
|
|
@@ -79,7 +59,7 @@ const StatusIconEntrySchema = new Schema(
|
|
|
79
59
|
|
|
80
60
|
// ── EconomyRulesSchema ───────────────────────────────────────────────────────
|
|
81
61
|
// Mirrors the EconomyRules proto message and the economyRules sub-document in
|
|
82
|
-
// cyberia-
|
|
62
|
+
// cyberia-server-defaults.js. All fields default from those canonical
|
|
83
63
|
// values so a freshly created document is immediately playable.
|
|
84
64
|
// See OFF_CHAIN_ECONOMY.md for the full Fountain & Sink architecture.
|
|
85
65
|
const EconomyRulesSchema = new Schema(
|
|
@@ -102,7 +82,7 @@ const EconomyRulesSchema = new Schema(
|
|
|
102
82
|
// ── EquipmentRulesSchema ─────────────────────────────────────────────────────
|
|
103
83
|
// Governs which ObjectLayer item types can be simultaneously active on a
|
|
104
84
|
// character entity and enforces the one-active-per-type constraint.
|
|
105
|
-
// See EQUIPMENT_RULES_DEFAULTS in cyberia-
|
|
85
|
+
// See EQUIPMENT_RULES_DEFAULTS in cyberia-server-defaults.js.
|
|
106
86
|
const EquipmentRulesSchema = new Schema(
|
|
107
87
|
{
|
|
108
88
|
// Item types that players are allowed to activate (equip).
|
|
@@ -144,20 +124,9 @@ const CyberiaInstanceConfSchema = new Schema(
|
|
|
144
124
|
// Back-reference to the owning instance (indexed for fast lookup by code).
|
|
145
125
|
instanceCode: { type: String, required: true, unique: true, trim: true },
|
|
146
126
|
|
|
147
|
-
// ──
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
interpolationMs: { type: Number, default: D.interpolationMs },
|
|
151
|
-
defaultObjWidth: { type: Number, default: D.defaultObjWidth },
|
|
152
|
-
defaultObjHeight: { type: Number, default: D.defaultObjHeight },
|
|
153
|
-
cameraSmoothing: { type: Number, default: D.cameraSmoothing },
|
|
154
|
-
cameraZoom: { type: Number, default: D.cameraZoom },
|
|
155
|
-
defaultWidthScreenFactor: { type: Number, default: D.defaultWidthScreenFactor },
|
|
156
|
-
defaultHeightScreenFactor: { type: Number, default: D.defaultHeightScreenFactor },
|
|
157
|
-
devUi: { type: Boolean, default: D.devUi },
|
|
158
|
-
// Empty array by default — colours must be configured per-instance.
|
|
159
|
-
// toInstanceConfig() fills in CYBERIA_INSTANCE_CONF_DEFAULTS.colors when the array is empty.
|
|
160
|
-
colors: { type: [ColorEntrySchema], default: [] },
|
|
127
|
+
// ── Tick model (authoritative simulation cadence) ─────────────────
|
|
128
|
+
tickRate: { type: Number, default: D.tickRate },
|
|
129
|
+
snapshotRate: { type: Number, default: D.snapshotRate },
|
|
161
130
|
|
|
162
131
|
// ── World / AOI ─────────────────────────────────────────────────
|
|
163
132
|
aoiRadius: { type: Number, default: D.aoiRadius },
|
|
@@ -197,12 +166,12 @@ const CyberiaInstanceConfSchema = new Schema(
|
|
|
197
166
|
// ── Entity type rendering defaults ───────────────────────────────
|
|
198
167
|
// Replaces flat fields: userDefaultItemId, botDefaultItemId, ghostItemId,
|
|
199
168
|
// coinItemId, defaultFloorItemId, weaponDefaultItemId.
|
|
200
|
-
// Each entry: { entityType, liveItemIds, deadItemIds, colorKey }.
|
|
169
|
+
// Each entry: { entityType, liveItemIds, deadItemIds, dropItemIds, colorKey }.
|
|
201
170
|
entityDefaults: { type: [EntityDefaultSchema], default: D.entityDefaults },
|
|
202
171
|
|
|
203
172
|
// ── Entity Status Indicators ────────────────────────────────────
|
|
204
173
|
// Overhead icon mapping + per-status border colour.
|
|
205
|
-
// See STATUS_ICONS in cyberia-
|
|
174
|
+
// See STATUS_ICONS in cyberia-server-defaults.js.
|
|
206
175
|
statusIcons: { type: [StatusIconEntrySchema], default: D.statusIcons },
|
|
207
176
|
|
|
208
177
|
// ── Skill system ─────────────────────────────────────────────────
|