Add WeChat minigame triple-engine scaffold with Godot Chiang Mai plaza SoT.

Unity and Cocos stay as parallel schemes; apps/minigame ships the Godot 4.7 WeChat pack for DevTools.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Eric 2026-11-06 20:17:14 +08:00
parent 83f87e5ef3
commit 58a845db32
364 changed files with 63651 additions and 0 deletions

11
apps/minigame-cocos/.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
library/
temp/
local/
build/
profiles/
native/
.settings/
*.log
.DS_Store
.creator/
node_modules/

View File

@ -0,0 +1,63 @@
# 数字游民模拟器 — AI 开发总规范(Cocos 方案)
本文件约束 **`apps/minigame-cocos`**(Cocos Creator 3.8.x → 微信小游戏)。
**并行关系**:`apps/minigame-unity`(Unity)为现有可运行方案,**禁止删除或替换**。Cocos 为另一套引擎方案,目录与导出互不覆盖。
## 一、项目目标
3D 数字游民人生模拟经营游戏。
- 平台:微信小游戏
- 类型:第三人称 3D · Stylized 卡通 · 城市探索 · 人生模拟 · 创业经营 · 单机离线
- 成长线:远程工作 → 创业 / 投资 → 财务自由与全球旅居
## 二、技术选型
| 项 | 固定 |
|---|---|
| 引擎 | Cocos Creator **3.8.x**(当前锁定 `3.8.6`,见 `package.json`) |
| 语言 | TypeScript |
| 模型 | Blender → GLB / glTF |
| 数据 | JSON |
| 存档 | 微信小游戏 Storage API(本地兜底 `sys.localStorage`) |
- 必须优先保证微信小游戏兼容性
- **禁止未经评估更换游戏引擎**
- **禁止擅自升级 Cocos Creator 版本**
## 三、开源项目优先原则
开发任何模块前:搜 GitHub → 核实 Stars **> 1000** → 检查更新 / License / 维护状态 / 与 3.8.x 兼容性 → 记录来源 → 再写业务代码。
不合格项目不得混入推荐列表;找不到合格项目时明确说明,不得虚构。
详见 `docs/OSS_RESEARCH.md`(含实时核实结果)。
## 四、项目架构
严格分离:游戏核心 · 3D 场景 · 人物 · 摄像机 · 交互 · UI · 经济 · 工作/创业 · 城市 · 时间/事件 · 存档 · 音频。
**模拟逻辑必须独立于 Cocos 场景节点**(`assets/scripts/sim/**` 禁止 `import 'cc'`)。
组件化 + 事件驱动;**禁止**超级 `GameManager`。
## 五、第一阶段内容(城市原型)
公寓 · 街道 · 咖啡馆 · 联合办公 · 超市 · 直播工作室;自由移动 · 第三人称摄像机 · 进入建筑 · 家具互动 · 电脑工作 · 睡觉 · 购物 · 赚钱 · 精力 · 推进时间。
## 六~八、美术 / 性能 / 纪律
统一 Stylized;优先开源模块化资产;控制 Draw Call / 纹理;烘焙光照优先;中低端 Android 基准;离线可玩;小步提交;每阶段交付修改清单、OSS、测试与未决问题(见 `docs/PHASE_LOG.md`)。
## 九、开发优先级
| 级 | 内容 | 状态 |
|---|---|---|
| P0 | 第三人称人物 + 摄像机 | 本迭代落地代码 |
| P1 | 3D 公寓与家具交互 | 本迭代落地代码 |
| P2 | 电脑工作系统 | 本迭代落地代码 |
| P3 | 收入/支出/精力/时间 | 本迭代落地代码 |
| P4+ | 街道扩展 → 发布优化 | 未开始 |
每阶段验收通过后再进下一阶段。

View File

@ -0,0 +1,44 @@
# NOMADRO 3D · Cocos Creator 3.8.x(并行方案 B)
数字游民人生模拟 · 微信小游戏。规范见 [`AGENTS.md`](./AGENTS.md)。
**Unity 方案(A)继续保留**:`apps/minigame-unity` → `apps/minigame`。本目录互不覆盖。
| | |
|---|---|
| 引擎 | Cocos Creator **3.8.6**(禁止擅自升级) |
| 语言 | TypeScript |
| AppID | `wx2900cac0858ca7dc` |
| 开源调研 | [`docs/OSS_RESEARCH.md`](./docs/OSS_RESEARCH.md) |
## 架构
```
assets/scripts/
vendor/ mitt · nipple-math(>1k stars 核实复用)
core/ 事件总线 · 类型
sim/ 时间/经济/精力/工作/存档(禁止 import 'cc')
data/ 离线 catalog 种子
player/ P0 电机 · 第三人称相机
ui/ 虚拟摇杆 · HUD
scene/ 程序化城市 · 交互区
bootstrap/ AutoSceneSetup · GameRoot
assets/data/ city-prototype.json · economy.json
```
## 本地
1. 本机已备 Creator:**`tools/CocosCreator-3.8.6`**(见 `tools/README-COCOS.md`)
2. 打开本工程 → 打开 **`assets/scenes/Main.scene`** → 预览 ▶
3. 构建 **微信小游戏** → `build/wechatgame`(**禁止**覆盖 `apps/minigame`)
4. 细节:[`docs/SCENE_SETUP.md`](./docs/SCENE_SETUP.md)
```bash
node tests/sim-world.test.mjs
# 或
pnpm --dir apps/minigame-cocos test:sim
```
## 阶段
P0~P3 代码已进仓。P4+ 街道扩展与 Kenney CC0 GLB 见 `docs/PHASE_LOG.md`。

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "ac36e64b-488a-4f83-b789-9368fd69b464",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,164 @@
{
"id": "chiangmai-proto-v1",
"name": "旅居城市原型",
"boundRadius": 28,
"spawn": { "x": -8, "y": 0, "z": -3.5 },
"structures": [
{
"id": "apartment",
"kind": "apartment",
"x": -8,
"z": -7,
"w": 7,
"d": 6,
"h": 3.2,
"color": "#f2a6c8",
"label": "城市公寓",
"price": 0,
"enterable": true
},
{
"id": "cafe",
"kind": "cafe",
"x": 7,
"z": -5,
"w": 6,
"d": 5,
"h": 2.8,
"color": "#6ec6b0",
"label": "咖啡馆",
"price": 0,
"enterable": true
},
{
"id": "cowork",
"kind": "cowork",
"x": 5,
"z": 9,
"w": 8,
"d": 6,
"h": 4.5,
"color": "#7eb6ff",
"label": "联合办公",
"price": 0,
"enterable": true
},
{
"id": "market",
"kind": "market",
"x": -7,
"z": 8,
"w": 6,
"d": 5,
"h": 2.6,
"color": "#f5c542",
"label": "超市",
"price": 0,
"enterable": true
},
{
"id": "studio",
"kind": "studio",
"x": 0,
"z": 14,
"w": 5,
"d": 5,
"h": 3,
"color": "#c9a0ff",
"label": "直播工作室",
"price": 0,
"enterable": true
},
{
"id": "street_main",
"kind": "street",
"x": 0,
"z": 1,
"w": 4,
"d": 22,
"h": 0.08,
"color": "#5a5f6b",
"label": "主街",
"price": 0
}
],
"interactables": [
{
"id": "bed_home",
"kind": "bed",
"structureId": "apartment",
"x": -9.2,
"y": 0,
"z": -8.2,
"radius": 1.6,
"label": "睡觉",
"action": "sleep"
},
{
"id": "pc_home",
"kind": "pc",
"structureId": "apartment",
"x": -6.5,
"y": 0,
"z": -6.2,
"radius": 1.5,
"label": "用电脑远程工作",
"action": "work_remote"
},
{
"id": "fridge_home",
"kind": "fridge",
"structureId": "apartment",
"x": -9.5,
"y": 0,
"z": -5.5,
"radius": 1.3,
"label": "吃点东西",
"action": "eat"
},
{
"id": "counter_cafe",
"kind": "counter",
"structureId": "cafe",
"x": 7,
"y": 0,
"z": -5,
"radius": 2.2,
"label": "咖啡馆深工",
"action": "work_cafe"
},
{
"id": "desk_cowork",
"kind": "desk",
"structureId": "cowork",
"x": 5,
"y": 0,
"z": 9,
"radius": 2.4,
"label": "联合办公交付",
"action": "work_cowork"
},
{
"id": "shelf_market",
"kind": "shelf",
"structureId": "market",
"x": -7,
"y": 0,
"z": 8,
"radius": 2.2,
"label": "买日用品",
"action": "shop"
},
{
"id": "cam_studio",
"kind": "camera",
"structureId": "studio",
"x": 0,
"y": 0,
"z": 14,
"radius": 2.2,
"label": "开播赚钱",
"action": "stream"
}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "2.0.1",
"importer": "json",
"imported": true,
"uuid": "2711edfb-8901-41bd-8b01-69e5290338c5",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,49 @@
{
"startCash": 1200,
"startEnergy": 80,
"maxEnergy": 100,
"actions": {
"sleep": {
"energyDelta": 55,
"cashDelta": 0,
"minutesDelta": 420,
"message": "睡了一觉,精力恢复。"
},
"eat": {
"energyDelta": 15,
"cashDelta": -25,
"minutesDelta": 20,
"message": "填饱肚子,花了 ¥25。"
},
"work_remote": {
"energyDelta": -22,
"cashDelta": 180,
"minutesDelta": 180,
"message": "远程交付完成,到账 ¥180。"
},
"work_cafe": {
"energyDelta": -18,
"cashDelta": 140,
"minutesDelta": 150,
"message": "咖啡馆深工结束,到账 ¥140。"
},
"work_cowork": {
"energyDelta": -25,
"cashDelta": 260,
"minutesDelta": 210,
"message": "联合办公交付客户,到账 ¥260。"
},
"shop": {
"energyDelta": -5,
"cashDelta": -80,
"minutesDelta": 40,
"message": "采购完成,支出 ¥80。"
},
"stream": {
"energyDelta": -30,
"cashDelta": 220,
"minutesDelta": 120,
"message": "直播结束,打赏 ¥220。"
}
}
}

View File

@ -0,0 +1,11 @@
{
"ver": "2.0.1",
"importer": "json",
"imported": true,
"uuid": "a0ac2a18-3ceb-4e9c-a87e-8a930f53e4bc",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "e0b54ddc-5a33-4e5f-945c-c56eafa27003",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,374 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "Main",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_name": "",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 12
}
],
"_active": true,
"_components": [],
"_prefab": null,
"autoReleaseAssets": false,
"_globals": {
"__id__": 7
},
"_id": "f26eaba4-119d-4108-a3a7-84f954d25692"
},
{
"__type__": "cc.Node",
"_name": "Main Light",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": -0.06397656665577071,
"y": -0.44608233363525845,
"z": -0.8239028751062036,
"w": -0.3436591377065261
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": -117.894,
"y": -194.909,
"z": 38.562
},
"_id": "c0y6F5f+pAvI805TdmxIjx"
},
{
"__type__": "cc.DirectionalLight",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": null,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 250,
"b": 240,
"a": 255
},
"_useColorTemperature": false,
"_colorTemperature": 6550,
"_staticSettings": {
"__id__": 4
},
"_illuminanceHDR": 65000,
"_illuminance": 65000,
"_illuminanceLDR": 1.6927083333333335,
"_id": "597uMYCbhEtJQc0ffJlcgA"
},
{
"__type__": "cc.StaticLightSettings",
"_baked": false,
"_editorOnly": false,
"_bakeable": false,
"_castShadow": false
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -10,
"y": 10,
"z": 10
},
"_lrot": {
"__type__": "cc.Quat",
"x": -0.27781593346944056,
"y": -0.36497167621709875,
"z": -0.11507512748638377,
"w": 0.8811195706053617
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": -35,
"y": -45,
"z": 0
},
"_id": "c9DMICJLFO5IeO07EPon7U"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"_projection": 1,
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 10,
"_near": 1,
"_far": 1000,
"_color": {
"__type__": "cc.Color",
"r": 51,
"g": 51,
"b": 51,
"a": 255
},
"_depth": 1,
"_stencil": 0,
"_clearFlags": 14,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_aperture": 19,
"_shutter": 7,
"_iso": 0,
"_screenScale": 1,
"_visibility": 1822425087,
"_targetTexture": null,
"_id": "7dWQTpwS5LrIHnc1zAPUtf"
},
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 8
},
"shadows": {
"__id__": 9
},
"_skybox": {
"__id__": 10
},
"fog": {
"__id__": 11
}
},
{
"__type__": "cc.AmbientInfo",
"_skyColorHDR": {
"__type__": "cc.Vec4",
"x": 0.365754,
"y": 0.568107,
"z": 0.9080791,
"w": 0
},
"_skyIllumHDR": 20000,
"_skyIllum": 20000,
"_groundAlbedoHDR": {
"__type__": "cc.Vec4",
"x": 0.455624,
"y": 0.403274,
"z": 0.370948,
"w": 0
},
"_skyColorLDR": {
"__type__": "cc.Vec4",
"x": 0.452588,
"y": 0.607642,
"z": 0.755699,
"w": 0
},
"_skyIllumLDR": 0.8,
"_groundAlbedoLDR": {
"__type__": "cc.Vec4",
"x": 0.618555,
"y": 0.577848,
"z": 0.544564,
"w": 0
}
},
{
"__type__": "cc.ShadowsInfo",
"_type": 0,
"_enabled": false,
"_normal": {
"__type__": "cc.Vec3",
"x": 0,
"y": 1,
"z": 0
},
"_distance": 0,
"_shadowColor": {
"__type__": "cc.Color",
"r": 76,
"g": 76,
"b": 76,
"a": 255
},
"_firstSetCSM": false,
"_fixedArea": false,
"_pcf": 1,
"_bias": 0.00001,
"_normalBias": 0,
"_near": 0.1,
"_far": 10,
"_shadowDistance": 10,
"_invisibleOcclusionRange": 200,
"_orthoSize": 5,
"_maxReceived": 4,
"_size": {
"__type__": "cc.Vec2",
"x": 1024,
"y": 1024
},
"_saturation": 0.75
},
{
"__type__": "cc.SkyboxInfo",
"_applyDiffuseMap": false,
"_envmapHDR": {
"__uuid__": "d032ac98-05e1-4090-88bb-eb640dcb5fc1@b47c0",
"__expectedType__": "cc.TextureCube"
},
"_envmap": {
"__uuid__": "d032ac98-05e1-4090-88bb-eb640dcb5fc1@b47c0",
"__expectedType__": "cc.TextureCube"
},
"_envmapLDR": {
"__uuid__": "6f01cf7f-81bf-4a7e-bd5d-0afc19696480@b47c0",
"__expectedType__": "cc.TextureCube"
},
"_diffuseMapHDR": null,
"_diffuseMapLDR": null,
"_enabled": true,
"_useIBL": false,
"_useHDR": true
},
{
"__type__": "cc.FogInfo",
"_type": 0,
"_fogColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_enabled": false,
"_fogDensity": 0.3,
"_fogStart": 0.5,
"_fogEnd": 300,
"_fogAtten": 5,
"_fogTop": 1.5,
"_fogRange": 1.2
},
{
"__type__": "cc.Node",
"_name": "Game",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"z": 0,
"y": 0,
"x": 0
},
"_lrot": {
"__type__": "cc.Quat",
"z": 0,
"w": 1,
"y": 0,
"x": 0
},
"_lscale": {
"__type__": "cc.Vec3",
"z": 1,
"y": 1,
"x": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"z": 0,
"y": 0,
"x": 0
},
"_id": "nomadroGameRootNode01"
},
{
"__type__": "c15bce397ea3458c878a070a2a91b06f",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"__prefab": null,
"_id": "nomadroAutoSceneSetup01"
}
]

View File

@ -0,0 +1,11 @@
{
"ver": "1.1.50",
"importer": "scene",
"imported": true,
"uuid": "f26eaba4-119d-4108-a3a7-84f954d25692",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "264f20be-d314-4e6e-bb48-445a1eb102d0",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "e681815e-b718-4b79-9380-ee4b34c21dc6",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,194 @@
import {
_decorator,
Component,
Node,
Camera,
Color,
DirectionalLight,
Canvas,
UITransform,
Label,
Widget,
ProgressBar,
Sprite,
SpriteFrame,
Texture2D,
ImageAsset,
view,
ResolutionPolicy,
Vec3,
MeshRenderer,
primitives,
utils,
Material,
BlockInputEvents,
} from 'cc'
import { GameRoot } from './GameRoot'
import { PlayerMotor } from '../player/PlayerMotor'
import { CameraFollow } from '../player/CameraFollow'
import { WorldBootstrap } from '../scene/WorldBootstrap'
import { HudView } from '../ui/HudView'
import { VirtualJoystick } from '../ui/VirtualJoystick'
import { CITY } from '../data/CatalogSeed'
const { ccclass } = _decorator
function solidSprite(r: number, g: number, b: number, a = 180): SpriteFrame {
const data = new Uint8Array([r, g, b, a])
const img = new ImageAsset()
img.reset({
_data: data,
width: 1,
height: 1,
format: Texture2D.PixelFormat.RGBA8888,
_compressed: false,
} as never)
const tex = new Texture2D()
tex.image = img
const sf = new SpriteFrame()
sf.texture = tex
return sf
}
function unlit(hex: string): Material {
const h = hex.replace('#', '')
const n = parseInt(h, 16)
const m = new Material()
m.initialize({ effectName: 'builtin-unlit' })
m.setProperty(
'mainColor',
new Color((n >> 16) & 255, (n >> 8) & 255, n & 255, 255),
)
return m
}
/**
* Drop on an empty scene → builds player / camera / lights / HUD / GameRoot.
* Portrait WeChat-friendly 750×1334 design size.
*/
@ccclass('AutoSceneSetup')
export class AutoSceneSetup extends Component {
/** onLoad before GameRoot.start */
onLoad() {
if (this.node.getChildByName('Player')) {
this.enabled = false
return
}
view.setDesignResolutionSize(750, 1334, ResolutionPolicy.FIXED_WIDTH)
const worldRoot = new Node('World')
this.node.addChild(worldRoot)
const sunNode = new Node('Sun')
this.node.addChild(sunNode)
sunNode.setPosition(12, 22, 8)
sunNode.lookAt(new Vec3(0, 0, 0))
const sun = sunNode.addComponent(DirectionalLight)
sun.illuminance = 42000
sun.color = new Color(255, 244, 220)
const player = new Node('Player')
this.node.addChild(player)
player.setPosition(CITY.spawn.x, CITY.spawn.y, CITY.spawn.z)
const body = new Node('Body')
player.addChild(body)
body.setScale(0.7, 1.5, 0.7)
body.setPosition(0, 0.75, 0)
const mr = body.addComponent(MeshRenderer)
mr.mesh = utils.MeshUtils.createMesh(primitives.capsule())
mr.setMaterial(unlit('#f0a060'), 0)
const motor = player.addComponent(PlayerMotor)
motor.boundRadius = CITY.boundRadius
const camNode = new Node('MainCamera')
this.node.addChild(camNode)
const cam = camNode.addComponent(Camera)
cam.fov = 50
cam.clearColor = new Color(140, 200, 242, 255)
const follow = camNode.addComponent(CameraFollow)
follow.target = player
follow.motor = motor
const world = worldRoot.addComponent(WorldBootstrap)
world.worldRoot = worldRoot
world.sun = sun
const canvasNode = new Node('Canvas')
this.node.addChild(canvasNode)
const canvas = canvasNode.addComponent(Canvas)
canvasNode.addComponent(UITransform).setContentSize(750, 1334)
const widget = canvasNode.addComponent(Widget)
widget.isAlignTop = widget.isAlignBottom = widget.isAlignLeft = widget.isAlignRight = true
widget.top = widget.bottom = widget.left = widget.right = 0
const joyNode = new Node('JoystickZone')
canvasNode.addChild(joyNode)
joyNode.addComponent(UITransform).setContentSize(750, 1334)
joyNode.addComponent(BlockInputEvents)
const joyWidget = joyNode.addComponent(Widget)
joyWidget.isAlignTop = joyWidget.isAlignBottom = joyWidget.isAlignLeft = joyWidget.isAlignRight = true
joyWidget.top = joyWidget.bottom = joyWidget.left = joyWidget.right = 0
const knob = new Node('Knob')
joyNode.addChild(knob)
knob.setPosition(-220, -420, 0)
const knobUi = knob.addComponent(UITransform)
knobUi.setContentSize(56, 56)
const knobSp = knob.addComponent(Sprite)
knobSp.spriteFrame = solidSprite(255, 200, 80, 200)
const joy = joyNode.addComponent(VirtualJoystick)
joy.stickKnob = knob
joy.maxRadius = 72
const hudNode = new Node('HUD')
canvasNode.addChild(hudNode)
const hud = hudNode.addComponent(HudView)
hud.titleLabel = this.mkLabel(hudNode, 'Title', '数字游民', 28, 0, 580)
hud.timeLabel = this.mkLabel(hudNode, 'Time', 'D1 07:10', 22, 0, 540)
hud.cashLabel = this.mkLabel(hudNode, 'Cash', '¥1200', 24, -260, 580)
hud.hintLabel = this.mkLabel(hudNode, 'Hint', '探索城市', 20, 0, -520)
hud.interactLabel = this.mkLabel(hudNode, 'Interact', '互动', 22, 220, -420)
if (hud.interactLabel) hud.interactLabel.node.active = false
const barNode = new Node('Energy')
hudNode.addChild(barNode)
barNode.setPosition(0, 500, 0)
barNode.addComponent(UITransform).setContentSize(280, 18)
const bar = barNode.addComponent(ProgressBar)
bar.totalLength = 280
bar.progress = 0.8
hud.energyBar = bar
void canvas
const root = this.node.getComponent(GameRoot) || this.node.addComponent(GameRoot)
root.player = motor
root.cameraFollow = follow
root.world = world
root.hud = hud
root.joystick = joy
root.playerNode = player
// AutoSceneSetup only scaffolds once; disable to avoid rebuild
this.enabled = false
}
private mkLabel(
parent: Node,
name: string,
text: string,
size: number,
x: number,
y: number,
): Label {
const n = new Node(name)
parent.addChild(n)
n.setPosition(x, y, 0)
n.addComponent(UITransform).setContentSize(700, 40)
const lab = n.addComponent(Label)
lab.string = text
lab.fontSize = size
lab.color = new Color(255, 255, 255, 255)
lab.overflow = Label.Overflow.SHRINK
return lab
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "c15bce39-7ea3-458c-878a-070a2a91b06f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,89 @@
import { _decorator, Component, Node } from 'cc'
import { getBus, resetBus } from '../core/EventBus'
import { CITY, ECONOMY } from '../data/CatalogSeed'
import { SimWorld } from '../sim/SimWorld'
import { PlayerMotor } from '../player/PlayerMotor'
import { CameraFollow } from '../player/CameraFollow'
import { WorldBootstrap } from '../scene/WorldBootstrap'
import { HudView } from '../ui/HudView'
import { VirtualJoystick } from '../ui/VirtualJoystick'
const { ccclass, property } = _decorator
/**
* Thin scene glue — wires views to SimWorld. No economy rules here.
* Attach to scene root in Cocos Creator 3.8.6.
*/
@ccclass('GameRoot')
export class GameRoot extends Component {
@property(PlayerMotor)
player: PlayerMotor | null = null
@property(CameraFollow)
cameraFollow: CameraFollow | null = null
@property(WorldBootstrap)
world: WorldBootstrap | null = null
@property(HudView)
hud: HudView | null = null
@property(VirtualJoystick)
joystick: VirtualJoystick | null = null
@property(Node)
playerNode: Node | null = null
private _sim: SimWorld | null = null
/** start() so AutoSceneSetup.onLoad can wire refs first */
start() {
if (this._sim) return
resetBus()
this._sim = new SimWorld(CITY, ECONOMY)
const pn = this.playerNode || this.player?.node
if (this.world) this.world.playerForNpcLook = pn
this.world?.build(CITY)
const spawn = CITY.spawn
pn?.setPosition(spawn.x, spawn.y, spawn.z)
if (this.player) this.player.boundRadius = CITY.boundRadius
this._sim.bootFromSave()
this.world?.applySun(this._sim.stats.minutes)
getBus().on('interact:request', this.onInteract, this)
getBus().on('stats:changed', this.onStats, this)
}
onDestroy() {
getBus().off('interact:request', this.onInteract, this)
getBus().off('stats:changed', this.onStats, this)
}
update() {
if (!this._sim || !this.player) return
const p = this.player.node.worldPosition
this._sim.updateProximity(p.x, p.z)
}
private onInteract = () => {
if (!this._sim || !this.player) return
const p = this.player.node.worldPosition
this._sim.tryInteract(p.x, p.z)
}
private onStats = () => {
if (!this._sim) return
this.world?.applySun(this._sim.stats.minutes)
}
/** Optional UI restart button */
onRestart() {
if (!this._sim) return
this._sim.stats = this._sim.defaultStats()
this._sim.flags = {}
this._sim.persist()
this._sim.emitAll()
const spawn = CITY.spawn
this.player?.node.setPosition(spawn.x, spawn.y, spawn.z)
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "f720768e-46b9-4017-9033-268a65395b28",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "800137d6-4284-4cfc-9e48-023a1a725560",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,14 @@
import mitt, { type Emitter } from '../vendor/mitt'
import type { GameEvents } from './GameEvents'
/** Process-wide typed bus. Sim and Cocos views both subscribe here. */
let bus: Emitter<GameEvents> | null = null
export function getBus(): Emitter<GameEvents> {
if (!bus) bus = mitt<GameEvents>()
return bus
}
export function resetBus(): void {
bus = mitt<GameEvents>()
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "dbed4821-4058-4799-9948-619a44fa664e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,14 @@
import type { PlayerStats } from './types'
/** Typed mitt payload map — sim ↔ view glue. */
export type GameEvents = {
'stats:changed': PlayerStats
'hud:hint': { text: string; interactable: boolean }
'time:tick': { minutes: number; day: number; label: string }
'player:move-input': { x: number; z: number }
'player:look-input': { yawDelta: number; pitchDelta: number }
'interact:request': undefined
'interact:done': { id: string; action: string; ok: boolean; message: string }
'save:done': { ok: boolean }
'scene:enter': { structureId: string }
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "c0562cd8-33fd-433d-9709-1ffee6f4bdb2",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,71 @@
/** Shared pure types — no Cocos imports. */
export type Vec2Like = { x: number; z: number }
export type StructureKind =
| 'apartment'
| 'cafe'
| 'cowork'
| 'market'
| 'studio'
| 'street'
| 'prop'
export type StructureDef = {
id: string
kind: StructureKind
/** grid / world XZ center */
x: number
z: number
/** footprint */
w: number
d: number
h: number
/** stylized hex color */
color: string
label: string
/** Kenney-style cash cost if purchasable; 0 = landmark */
price: number
enterable?: boolean
}
export type InteractableKind =
| 'bed'
| 'pc'
| 'fridge'
| 'door'
| 'counter'
| 'shelf'
| 'desk'
| 'camera'
export type InteractableDef = {
id: string
kind: InteractableKind
structureId: string
x: number
y: number
z: number
radius: number
label: string
/** sim action key */
action: string
}
export type PlayerStats = {
cash: number
energy: number
maxEnergy: number
/** minutes since day 0 00:00 */
minutes: number
day: number
locationId: string
}
export type SaveBlob = {
version: 1
stats: PlayerStats
flags: Record<string, boolean>
/** Kenney city-builder inspired placed extras */
structures: Array<{ id: string; x: number; z: number; orientation: number }>
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "0a5685e4-a32f-4847-b0cd-37e799c69240",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "aa481c0f-a798-4846-803a-66b81e7ec4f5",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,221 @@
/**
* Offline seed catalogs (packaged with client).
* Designer SoT also kept as assets/data/*.json — keep values aligned.
* Inlined here so Cocos / tsc need no JSON module loader.
*/
import type { CityCatalog, EconomyCatalog } from '../sim/SimWorld'
export const CITY: CityCatalog = {
id: 'chiangmai-proto-v1',
name: '旅居城市原型',
boundRadius: 28,
spawn: { x: -8, y: 0, z: -3.5 },
structures: [
{
id: 'apartment',
kind: 'apartment',
x: -8,
z: -7,
w: 7,
d: 6,
h: 3.2,
color: '#f2a6c8',
label: '城市公寓',
price: 0,
enterable: true,
},
{
id: 'cafe',
kind: 'cafe',
x: 7,
z: -5,
w: 6,
d: 5,
h: 2.8,
color: '#6ec6b0',
label: '咖啡馆',
price: 0,
enterable: true,
},
{
id: 'cowork',
kind: 'cowork',
x: 5,
z: 9,
w: 8,
d: 6,
h: 4.5,
color: '#7eb6ff',
label: '联合办公',
price: 0,
enterable: true,
},
{
id: 'market',
kind: 'market',
x: -7,
z: 8,
w: 6,
d: 5,
h: 2.6,
color: '#f5c542',
label: '超市',
price: 0,
enterable: true,
},
{
id: 'studio',
kind: 'studio',
x: 0,
z: 14,
w: 5,
d: 5,
h: 3,
color: '#c9a0ff',
label: '直播工作室',
price: 0,
enterable: true,
},
{
id: 'street_main',
kind: 'street',
x: 0,
z: 1,
w: 4,
d: 22,
h: 0.08,
color: '#5a5f6b',
label: '主街',
price: 0,
},
],
interactables: [
{
id: 'bed_home',
kind: 'bed',
structureId: 'apartment',
x: -9.2,
y: 0,
z: -8.2,
radius: 1.6,
label: '睡觉',
action: 'sleep',
},
{
id: 'pc_home',
kind: 'pc',
structureId: 'apartment',
x: -6.5,
y: 0,
z: -6.2,
radius: 1.5,
label: '用电脑远程工作',
action: 'work_remote',
},
{
id: 'fridge_home',
kind: 'fridge',
structureId: 'apartment',
x: -9.5,
y: 0,
z: -5.5,
radius: 1.3,
label: '吃点东西',
action: 'eat',
},
{
id: 'counter_cafe',
kind: 'counter',
structureId: 'cafe',
x: 7,
y: 0,
z: -5,
radius: 2.2,
label: '咖啡馆深工',
action: 'work_cafe',
},
{
id: 'desk_cowork',
kind: 'desk',
structureId: 'cowork',
x: 5,
y: 0,
z: 9,
radius: 2.4,
label: '联合办公交付',
action: 'work_cowork',
},
{
id: 'shelf_market',
kind: 'shelf',
structureId: 'market',
x: -7,
y: 0,
z: 8,
radius: 2.2,
label: '买日用品',
action: 'shop',
},
{
id: 'cam_studio',
kind: 'camera',
structureId: 'studio',
x: 0,
y: 0,
z: 14,
radius: 2.2,
label: '开播赚钱',
action: 'stream',
},
],
}
export const ECONOMY: EconomyCatalog = {
startCash: 1200,
startEnergy: 80,
maxEnergy: 100,
actions: {
sleep: {
energyDelta: 55,
cashDelta: 0,
minutesDelta: 420,
message: '睡了一觉,精力恢复。',
},
eat: {
energyDelta: 15,
cashDelta: -25,
minutesDelta: 20,
message: '填饱肚子,花了 ¥25。',
},
work_remote: {
energyDelta: -22,
cashDelta: 180,
minutesDelta: 180,
message: '远程交付完成,到账 ¥180。',
},
work_cafe: {
energyDelta: -18,
cashDelta: 140,
minutesDelta: 150,
message: '咖啡馆深工结束,到账 ¥140。',
},
work_cowork: {
energyDelta: -25,
cashDelta: 260,
minutesDelta: 210,
message: '联合办公交付客户,到账 ¥260。',
},
shop: {
energyDelta: -5,
cashDelta: -80,
minutesDelta: 40,
message: '采购完成,支出 ¥80。',
},
stream: {
energyDelta: -30,
cashDelta: 220,
minutesDelta: 120,
message: '直播结束,打赏 ¥220。',
},
},
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "10cc63ab-8d2d-412c-9a43-9f0cda06491b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "91fd22e1-fce9-4f60-b500-9eed9fe91b4d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,113 @@
import { _decorator, Component, Node, Vec3, input, Input, EventTouch } from 'cc'
import { getBus } from '../core/EventBus'
import { PlayerMotor } from './PlayerMotor'
const { ccclass, property } = _decorator
/**
* P0 third-person follow + orbit (right-half drag).
* Pattern: spring follow + yaw/pitch — Cocos 3.8 Camera node.
*/
@ccclass('CameraFollow')
export class CameraFollow extends Component {
@property(Node)
target: Node | null = null
@property(PlayerMotor)
motor: PlayerMotor | null = null
@property
distance = 7.2
@property
height = 3.4
@property
minPitch = -10
@property
maxPitch = 55
@property
sens = 0.18
private _yaw = 25
private _pitch = 18
private _dragging = false
private _last = { x: 0, y: 0 }
private _pos = new Vec3()
private _look = new Vec3()
onEnable() {
input.on(Input.EventType.TOUCH_START, this.onTouchStart, this)
input.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this)
input.on(Input.EventType.TOUCH_END, this.onTouchEnd, this)
input.on(Input.EventType.TOUCH_CANCEL, this.onTouchEnd, this)
getBus().on('player:look-input', this.onLook)
}
onDisable() {
input.off(Input.EventType.TOUCH_START, this.onTouchStart, this)
input.off(Input.EventType.TOUCH_MOVE, this.onTouchMove, this)
input.off(Input.EventType.TOUCH_END, this.onTouchEnd, this)
input.off(Input.EventType.TOUCH_CANCEL, this.onTouchEnd, this)
getBus().off('player:look-input', this.onLook)
}
private onLook = (e: { yawDelta: number; pitchDelta: number }) => {
this._yaw += e.yawDelta
this._pitch = Math.min(
this.maxPitch,
Math.max(this.minPitch, this._pitch + e.pitchDelta),
)
}
private onTouchStart(e: EventTouch) {
const loc = e.getUILocation()
// right half = look (left reserved for joystick)
if (loc.x < 375) return
this._dragging = true
this._last.x = loc.x
this._last.y = loc.y
}
private onTouchMove(e: EventTouch) {
if (!this._dragging) return
const loc = e.getUILocation()
const dx = loc.x - this._last.x
const dy = loc.y - this._last.y
this._last.x = loc.x
this._last.y = loc.y
this._yaw -= dx * this.sens
this._pitch = Math.min(
this.maxPitch,
Math.max(this.minPitch, this._pitch + dy * this.sens),
)
}
private onTouchEnd() {
this._dragging = false
}
lateUpdate(dt: number) {
if (!this.target) return
const t = this.target.worldPosition
const yaw = (this._yaw * Math.PI) / 180
const pitch = (this._pitch * Math.PI) / 180
const cp = Math.cos(pitch)
const ox = Math.sin(yaw) * cp * this.distance
const oy = Math.sin(pitch) * this.distance + this.height * 0.15
const oz = Math.cos(yaw) * cp * this.distance
this._pos.set(t.x + ox, t.y + this.height + oy * 0.25, t.z + oz)
const damp = 1 - Math.exp(-10 * dt)
const cur = this.node.worldPosition
this.node.setWorldPosition(
cur.x + (this._pos.x - cur.x) * damp,
cur.y + (this._pos.y - cur.y) * damp,
cur.z + (this._pos.z - cur.z) * damp,
)
this._look.set(t.x, t.y + 1.2, t.z)
this.node.lookAt(this._look)
this.motor?.setCameraYaw(this._yaw)
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "292c36ba-dcfc-4a2a-9398-93bc93a6a9dc",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,111 @@
import {
_decorator,
Component,
input,
Input,
EventKeyboard,
KeyCode,
Vec3,
} from 'cc'
import { getBus } from '../core/EventBus'
const { ccclass, property } = _decorator
/**
* P0 third-person motor (XZ). Move input from EventBus or WASD.
* Uses Cocos Creator 3.8 Input API (cocos-engine).
*/
@ccclass('PlayerMotor')
export class PlayerMotor extends Component {
@property
speed = 5.4
@property
boundRadius = 28
private _ix = 0
private _iz = 0
private _vel = new Vec3()
private _tmp = new Vec3()
private _keys = new Set<KeyCode>()
private _yaw = 0
/** Camera yaw (degrees) so stick forward matches view. */
setCameraYaw(yawDeg: number) {
this._yaw = yawDeg
}
onEnable() {
input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this)
input.on(Input.EventType.KEY_UP, this.onKeyUp, this)
getBus().on('player:move-input', this.onMove)
}
onDisable() {
input.off(Input.EventType.KEY_DOWN, this.onKeyDown, this)
input.off(Input.EventType.KEY_UP, this.onKeyUp, this)
getBus().off('player:move-input', this.onMove)
}
private onMove = (e: { x: number; z: number }) => {
this._ix = e.x
this._iz = e.z
}
private onKeyDown(e: EventKeyboard) {
this._keys.add(e.keyCode)
}
private onKeyUp(e: EventKeyboard) {
this._keys.delete(e.keyCode)
}
update(dt: number) {
let ix = this._ix
let iz = this._iz
if (this._keys.has(KeyCode.KEY_W) || this._keys.has(KeyCode.ARROW_UP)) iz -= 1
if (this._keys.has(KeyCode.KEY_S) || this._keys.has(KeyCode.ARROW_DOWN)) iz += 1
if (this._keys.has(KeyCode.KEY_A) || this._keys.has(KeyCode.ARROW_LEFT)) ix -= 1
if (this._keys.has(KeyCode.KEY_D) || this._keys.has(KeyCode.ARROW_RIGHT)) ix += 1
const len = Math.hypot(ix, iz)
if (len > 1) {
ix /= len
iz /= len
}
const yaw = (this._yaw * Math.PI) / 180
const fx = Math.sin(yaw)
const fz = Math.cos(yaw)
const rx = Math.cos(yaw)
const rz = -Math.sin(yaw)
const wx = fx * -iz + rx * ix
const wz = fz * -iz + rz * ix
const damp = 1 - Math.exp(-12 * dt)
this._vel.x += (wx * this.speed - this._vel.x) * damp
this._vel.z += (wz * this.speed - this._vel.z) * damp
const p = this.node.position
this._tmp.set(p.x + this._vel.x * dt, p.y, p.z + this._vel.z * dt)
const r = Math.hypot(this._tmp.x, this._tmp.z)
if (r > this.boundRadius) {
this._tmp.x *= this.boundRadius / r
this._tmp.z *= this.boundRadius / r
}
this.node.setPosition(this._tmp)
const spd = Math.hypot(this._vel.x, this._vel.z)
if (spd > 0.08) {
const ang = (Math.atan2(this._vel.x, this._vel.z) * 180) / Math.PI
const euler = this.node.eulerAngles
let diff = ((ang - euler.y + 540) % 360) - 180
this.node.setRotationFromEuler(0, euler.y + diff * damp * 1.4, 0)
this.node.setPosition(
this._tmp.x,
Math.abs(Math.sin(Date.now() * 0.012)) * 0.05,
this._tmp.z,
)
}
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "cedc93a8-39a3-4320-8276-5b17b8683e85",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "de51c7c0-01b8-4522-9245-758f710d1ade",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,36 @@
import { _decorator, Component, Vec3 } from 'cc'
import type { InteractableDef } from '../core/types'
const { ccclass, property } = _decorator
/**
* Optional editor-placed zone marker. Runtime proximity uses SimWorld catalog;
* this component is for designers to visualize radii in the editor.
*/
@ccclass('InteractableZone')
export class InteractableZone extends Component {
@property
interactableId = ''
@property
radius = 1.5
toDef(structureId: string, kind: InteractableDef['kind'], action: string, label: string): InteractableDef {
const p = this.node.worldPosition
return {
id: this.interactableId || this.node.name,
kind,
structureId,
x: p.x,
y: p.y,
z: p.z,
radius: this.radius,
label,
action,
}
}
distanceTo(world: Vec3): number {
return Vec3.distance(this.node.worldPosition, world)
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "d2065945-d658-4737-bd67-4e8685098dd6",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,56 @@
import { _decorator, Component, Node, Vec3 } from 'cc'
const { ccclass, property } = _decorator
/**
* Lightweight NPC / dust motion — keeps scene alive without AI stack.
*/
@ccclass('NpcWander')
export class NpcWander extends Component {
@property(Node)
lookAt: Node | null = null
@property
mode: 'wander' | 'dust' = 'wander'
@property
radius = 1.8
@property
speed = 0.55
private _origin = new Vec3()
private _t = Math.random() * 10
private _baseY = 0
start() {
this._origin.set(this.node.position)
this._baseY = this.node.position.y
this._t = Math.random() * 10
}
update(dt: number) {
this._t += dt
if (this.mode === 'dust') {
const p = this.node.position
const y = this._baseY + Math.abs(Math.sin(this._t * this.speed)) * 1.2
const x = p.x + Math.sin(this._t * 0.25 + p.z) * dt * 0.15
this.node.setPosition(x, y, p.z)
return
}
const ox = this._origin.x + Math.cos(this._t * this.speed) * this.radius
const oz = this._origin.z + Math.sin(this._t * this.speed * 0.85) * this.radius
this.node.setPosition(ox, this._origin.y, oz)
if (this.lookAt) {
const t = this.lookAt.worldPosition
const dx = t.x - ox
const dz = t.z - oz
if (dx * dx + dz * dz > 0.01) {
const yaw = (Math.atan2(dx, dz) * 180) / Math.PI
this.node.setRotationFromEuler(0, yaw, 0)
}
}
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "abc59317-f98f-47d2-b391-824752f59751",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,301 @@
import {
_decorator,
Component,
Node,
MeshRenderer,
primitives,
utils,
Material,
Color,
Vec3,
DirectionalLight,
} from 'cc'
import type { CityCatalog } from '../sim/SimWorld'
import type { StructureDef } from '../core/types'
import { sunElevFromMinutes } from '../sim/TimeSystem'
import { NpcWander } from './NpcWander'
const { ccclass, property } = _decorator
function hexColor(hex: string): Color {
const h = hex.replace('#', '')
const n = parseInt(
h.length === 3 ? h.split('').map((c) => c + c).join('') : h,
16,
)
return new Color((n >> 16) & 255, (n >> 8) & 255, n & 255, 255)
}
type Prim = 'box' | 'sphere' | 'cylinder' | 'capsule'
/**
* Stylized cozy city — aligned with Unity WorldBootstrap pastel look.
* Procedural primitives until Kenney CC0 GLB swap.
*/
@ccclass('WorldBootstrap')
export class WorldBootstrap extends Component {
@property(Node)
worldRoot: Node | null = null
@property(DirectionalLight)
sun: DirectionalLight | null = null
@property(Node)
playerForNpcLook: Node | null = null
private _matCache = new Map<string, Material>()
private _meshCache = new Map<Prim, ReturnType<typeof utils.MeshUtils.createMesh>>()
build(city: CityCatalog) {
const root = this.worldRoot || this.node
root.removeAllChildren()
// grass disc (cylinder flattened)
this.spawn(
root,
'ground',
'cylinder',
new Vec3(0, -0.02, 0),
new Vec3(36, 0.04, 36),
'#7BC67E',
)
this.spawn(
root,
'sand',
'cylinder',
new Vec3(0, 0.03, 12),
new Vec3(18, 0.03, 10),
'#C4A574',
)
// cross roads
this.spawn(root, 'road_ns', 'box', new Vec3(0, 0.05, 0), new Vec3(5.2, 0.03, 28), '#E8E0D4')
this.spawn(root, 'road_ew', 'box', new Vec3(0, 0.055, 0), new Vec3(28, 0.03, 5.2), '#E8E0D4')
for (const s of city.structures) {
if (s.kind === 'street') continue
this.placeBuilding(root, s)
this.placeInterior(root, s)
}
// cafe terrace
this.spawn(root, 'CafeDeck', 'box', new Vec3(5.4, 0.12, -2.2), new Vec3(2.8, 0.12, 2.2), '#D4A574')
this.spawn(root, 'UmbrellaPole', 'cylinder', new Vec3(5.2, 0.7, -2.2), new Vec3(0.08, 0.7, 0.08), '#F5F5F5')
this.spawn(root, 'Umbrella', 'cylinder', new Vec3(5.2, 1.55, -2.2), new Vec3(2.4, 0.06, 2.4), '#FFD56A')
// river + pier
this.spawn(root, 'River', 'box', new Vec3(0, 0.02, 15.5), new Vec3(38, 0.08, 6.5), '#4DB7D6')
this.spawn(root, 'Pier', 'box', new Vec3(0, 0.2, 13.2), new Vec3(3.2, 0.15, 2.4), '#D9A066')
for (const it of city.interactables) {
this.spawn(
root,
`marker_${it.id}`,
'cylinder',
new Vec3(it.x, 0.55, it.z),
new Vec3(0.28, 0.55, 0.28),
'#FFD27A',
)
}
for (let i = 0; i < 14; i++) {
const a = (i / 14) * Math.PI * 2
const r = 12 + (i % 3) * 1.5
const x = Math.cos(a) * r
const z = Math.sin(a) * r * 0.88
if (Math.hypot(x, z) < 5) continue
this.placeTree(root, new Vec3(x, 0, z), 0.85 + (i % 3) * 0.15)
}
for (let i = 0; i < 10; i++) {
const ang = i * 0.62
this.spawn(
root,
`Bush_${i}`,
'sphere',
new Vec3(Math.cos(ang) * 7.5, 0.35, Math.sin(ang) * 7.5),
new Vec3(0.55 + (i % 3) * 0.12, 0.55 + (i % 3) * 0.12, 0.55 + (i % 3) * 0.12),
i % 2 === 0 ? '#5FBF6A' : '#F28BA0',
)
}
this.spawnNpc(root, 'Mira', new Vec3(5.2, 0, -3), '#5ED4C8')
this.spawnNpc(root, 'Alex', new Vec3(3.2, 0, 7), '#9BB0C4')
this.spawnNpc(root, 'Friend', new Vec3(-5, 0, 6.2), '#B39DDB')
for (let i = 0; i < 8; i++) {
const d = this.spawn(
root,
`Dust_${i}`,
'sphere',
new Vec3((i - 4) * 2.5, 1.2 + (i % 3) * 0.4, (i % 5) - 2),
new Vec3(0.07, 0.07, 0.07),
'#FFE9A8',
)
d.addComponent(NpcWander).mode = 'dust'
}
}
applySun(minutes: number) {
if (!this.sun) return
const elev = sunElevFromMinutes(minutes)
const az = 0.85
this.sun.node.setWorldPosition(
Math.cos(az) * 18,
3 + elev * 20,
Math.sin(az) * 18,
)
this.sun.illuminance = 18000 + elev * 45000
this.sun.color = Color.lerp(
new Color(),
new Color(255, 170, 120),
new Color(255, 245, 220),
elev,
)
}
private placeBuilding(root: Node, s: StructureDef) {
const group = new Node(s.id)
root.addChild(group)
group.setPosition(s.x, 0, s.z)
this.spawn(
group,
'Body',
'box',
new Vec3(0, s.h * 0.5, 0),
new Vec3(s.w, s.h, s.d),
s.color,
)
const roofHex =
s.kind === 'apartment'
? '#E86860'
: s.kind === 'cafe'
? '#3CB8AE'
: s.kind === 'cowork'
? '#6B7C90'
: s.kind === 'market'
? '#E0A820'
: '#9B7ED9'
this.spawn(
group,
'Roof',
'box',
new Vec3(0, s.h + 0.18, 0),
new Vec3(s.w * 1.12, 0.28, s.d * 1.12),
roofHex,
)
const rows = Math.max(1, Math.floor(s.h / 1.4))
for (let r = 0; r < rows; r++) {
for (let c = 0; c < 2; c++) {
this.spawn(
group,
`Win_${r}_${c}`,
'box',
new Vec3((c - 0.5) * s.w * 0.35, 0.9 + r * 1.35, s.d * 0.51),
new Vec3(0.55, 0.65, 0.08),
'#FFF6D8',
)
}
}
this.spawn(
group,
'Door',
'box',
new Vec3(0, 0.7, s.d * 0.51),
new Vec3(0.7, 1.35, 0.1),
'#6B4F3A',
)
}
/** Simple furniture props for apartment / cafe / studio */
private placeInterior(root: Node, s: StructureDef) {
if (s.kind === 'apartment') {
this.spawn(root, 'Bed', 'box', new Vec3(s.x - 1.4, 0.35, s.z - 1.4), new Vec3(1.8, 0.4, 1.1), '#F8E1E7')
this.spawn(root, 'Desk', 'box', new Vec3(s.x + 1.5, 0.4, s.z + 0.2), new Vec3(1.2, 0.08, 0.6), '#C4A574')
this.spawn(root, 'PC', 'box', new Vec3(s.x + 1.5, 0.7, s.z + 0.2), new Vec3(0.55, 0.4, 0.08), '#333333')
this.spawn(root, 'Sofa', 'box', new Vec3(s.x, 0.35, s.z + 1.6), new Vec3(2.2, 0.55, 0.9), '#E85D4C')
this.spawn(root, 'Rug', 'box', new Vec3(s.x, 0.06, s.z), new Vec3(2.4, 0.04, 2.0), '#F2D6A2')
} else if (s.kind === 'cafe') {
this.spawn(root, 'Counter', 'box', new Vec3(s.x, 0.55, s.z), new Vec3(2.4, 1.0, 0.7), '#8B5A3C')
this.spawn(root, 'StoolA', 'cylinder', new Vec3(s.x - 0.9, 0.35, s.z + 1.1), new Vec3(0.4, 0.35, 0.4), '#E8D5B7')
this.spawn(root, 'StoolB', 'cylinder', new Vec3(s.x + 0.9, 0.35, s.z + 1.1), new Vec3(0.4, 0.35, 0.4), '#E8D5B7')
} else if (s.kind === 'studio') {
this.spawn(root, 'CamStand', 'cylinder', new Vec3(s.x, 0.7, s.z + 1.2), new Vec3(0.08, 0.7, 0.08), '#444444')
this.spawn(root, 'Cam', 'box', new Vec3(s.x, 1.35, s.z + 1.2), new Vec3(0.35, 0.22, 0.45), '#222222')
this.spawn(root, 'RingLight', 'cylinder', new Vec3(s.x, 1.5, s.z + 0.4), new Vec3(1.1, 0.05, 1.1), '#FFE082')
} else if (s.kind === 'market') {
this.spawn(root, 'Shelf', 'box', new Vec3(s.x, 0.9, s.z), new Vec3(2.8, 1.6, 0.5), '#F5C542')
} else if (s.kind === 'cowork') {
this.spawn(root, 'DeskRow', 'box', new Vec3(s.x, 0.4, s.z), new Vec3(3.2, 0.08, 1.2), '#B0BEC5')
this.spawn(root, 'Chair', 'box', new Vec3(s.x, 0.35, s.z + 1.0), new Vec3(0.55, 0.55, 0.55), '#78909C')
}
}
private placeTree(root: Node, pos: Vec3, scale: number) {
const t = new Node('Tree')
root.addChild(t)
t.setPosition(pos)
t.setScale(scale, scale, scale)
this.spawn(t, 'Trunk', 'cylinder', new Vec3(0, 0.45, 0), new Vec3(0.22, 0.45, 0.22), '#8B5A3C')
this.spawn(t, 'Leaf1', 'sphere', new Vec3(0, 1.25, 0), new Vec3(1.35, 1.35, 1.35), '#4CAF50')
this.spawn(t, 'Leaf2', 'sphere', new Vec3(0.35, 1.55, 0.1), new Vec3(0.9, 0.9, 0.9), '#66BB6A')
}
private spawnNpc(root: Node, name: string, pos: Vec3, accent: string) {
const g = new Node(name)
root.addChild(g)
g.setPosition(pos)
this.spawn(g, 'Body', 'capsule', new Vec3(0, 0.85, 0), new Vec3(0.58, 0.5, 0.58), accent)
this.spawn(g, 'Head', 'sphere', new Vec3(0, 1.5, 0), new Vec3(0.42, 0.42, 0.42), '#FFE0BD')
this.spawn(g, 'Bag', 'box', new Vec3(0.28, 0.9, -0.05), new Vec3(0.22, 0.28, 0.12), '#5D4037')
const npc = g.addComponent(NpcWander)
npc.lookAt = this.playerForNpcLook
npc.mode = 'wander'
}
private spawn(
parent: Node,
name: string,
prim: Prim,
pos: Vec3,
scale: Vec3,
colorHex: string,
): Node {
const n = new Node(name)
parent.addChild(n)
n.setPosition(pos)
n.setScale(scale)
const mr = n.addComponent(MeshRenderer)
mr.mesh = this.mesh(prim)
mr.setMaterial(this.mat(colorHex), 0)
return n
}
private mesh(prim: Prim) {
let m = this._meshCache.get(prim)
if (m) return m
const geo =
prim === 'sphere'
? primitives.sphere()
: prim === 'cylinder'
? primitives.cylinder()
: prim === 'capsule'
? primitives.capsule()
: primitives.box()
m = utils.MeshUtils.createMesh(geo)
this._meshCache.set(prim, m)
return m
}
private mat(hex: string): Material {
let m = this._matCache.get(hex)
if (m) return m
m = new Material()
m.initialize({ effectName: 'builtin-unlit', technique: 0 })
m.setProperty('mainColor', hexColor(hex))
this._matCache.set(hex, m)
return m
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "d543c204-5950-4a57-9010-c06fc5394029",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "3358ba27-7d21-4900-be19-e8b0007ffddb",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,17 @@
import type { PlayerStats } from '../core/types'
export type ActionEconomy = {
energyDelta: number
cashDelta: number
minutesDelta: number
message: string
}
export function canAfford(stats: PlayerStats, cashDelta: number): boolean {
if (cashDelta >= 0) return true
return stats.cash + cashDelta >= 0
}
export function applyCash(stats: PlayerStats, cashDelta: number): PlayerStats {
return { ...stats, cash: Math.max(0, Math.round(stats.cash + cashDelta)) }
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "8ed3f3d2-1afa-41fa-ab7f-829ba984d354",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,17 @@
import type { PlayerStats } from '../core/types'
export function applyEnergy(
stats: PlayerStats,
energyDelta: number,
): PlayerStats {
const energy = Math.min(
stats.maxEnergy,
Math.max(0, Math.round(stats.energy + energyDelta)),
)
return { ...stats, energy }
}
export function hasEnergy(stats: PlayerStats, cost: number): boolean {
if (cost >= 0) return true
return stats.energy + cost >= 0
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "363bf2a2-6b1d-4ee5-b67a-6e17ad5b5c1b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,76 @@
/**
* Local save — WeChat Storage when present, else browser/localStorage.
* Field shape inspired by KenneyNL/Starter-Kit-City-Builder map.structures + cash
* (MIT, stars>1000) — see docs/OSS_RESEARCH.md.
*/
import type { SaveBlob } from '../core/types'
export const SAVE_KEY = 'nomadro_cocos_nomad_v1'
type StorageLike = {
getItem(key: string): string | null
setItem(key: string, value: string): void
removeItem?(key: string): void
}
function resolveStorage(): StorageLike | null {
const g = globalThis as {
wx?: {
getStorageSync?: (k: string) => unknown
setStorageSync?: (k: string, v: unknown) => void
removeStorageSync?: (k: string) => void
}
localStorage?: StorageLike
}
if (g.wx?.getStorageSync && g.wx?.setStorageSync) {
return {
getItem(key) {
try {
const v = g.wx!.getStorageSync!(key)
if (v == null || v === '') return null
return typeof v === 'string' ? v : JSON.stringify(v)
} catch {
return null
}
},
setItem(key, value) {
g.wx!.setStorageSync!(key, value)
},
removeItem(key) {
g.wx!.removeStorageSync?.(key)
},
}
}
if (g.localStorage) return g.localStorage
return null
}
export function saveBlob(blob: SaveBlob): boolean {
const store = resolveStorage()
if (!store) return false
try {
store.setItem(SAVE_KEY, JSON.stringify(blob))
return true
} catch {
return false
}
}
export function loadBlob(): SaveBlob | null {
const store = resolveStorage()
if (!store) return null
try {
const raw = store.getItem(SAVE_KEY)
if (!raw) return null
const data = JSON.parse(raw) as SaveBlob
if (!data || data.version !== 1 || !data.stats) return null
return data
} catch {
return null
}
}
export function clearSave(): void {
resolveStorage()?.removeItem?.(SAVE_KEY)
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "0c82f6e2-5f87-4888-82d0-2a15aedd2db7",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,141 @@
/**
* Game simulation root — NO Cocos imports.
* Views subscribe via EventBus; this class never touches nodes.
*/
import { getBus } from '../core/EventBus'
import type {
InteractableDef,
PlayerStats,
SaveBlob,
StructureDef,
} from '../core/types'
import type { ActionEconomy } from './EconomySystem'
import { applyAction } from './WorkSystem'
import { formatClock } from './TimeSystem'
import { loadBlob, saveBlob } from './SaveSystem'
export type CityCatalog = {
id: string
name: string
boundRadius: number
spawn: { x: number; y: number; z: number }
structures: StructureDef[]
interactables: InteractableDef[]
}
export type EconomyCatalog = {
startCash: number
startEnergy: number
maxEnergy: number
actions: Record<string, ActionEconomy>
}
export class SimWorld {
readonly city: CityCatalog
readonly economy: EconomyCatalog
stats: PlayerStats
flags: Record<string, boolean> = {}
placed: SaveBlob['structures'] = []
constructor(city: CityCatalog, economy: EconomyCatalog) {
this.city = city
this.economy = economy
this.stats = this.defaultStats()
}
defaultStats(): PlayerStats {
return {
cash: this.economy.startCash,
energy: this.economy.startEnergy,
maxEnergy: this.economy.maxEnergy,
minutes: 7 * 60 + 10,
day: 1,
locationId: 'street',
}
}
bootFromSave(): void {
const blob = loadBlob()
if (blob) {
this.stats = { ...this.defaultStats(), ...blob.stats }
this.flags = { ...blob.flags }
this.placed = [...(blob.structures || [])]
}
this.emitAll()
}
persist(): boolean {
const blob: SaveBlob = {
version: 1,
stats: this.stats,
flags: this.flags,
structures: this.placed,
}
const ok = saveBlob(blob)
getBus().emit('save:done', { ok })
return ok
}
nearestInteractable(
x: number,
z: number,
): InteractableDef | null {
let best: InteractableDef | null = null
let bestD = Infinity
for (const it of this.city.interactables) {
const d = Math.hypot(it.x - x, it.z - z)
if (d <= it.radius && d < bestD) {
best = it
bestD = d
}
}
return best
}
updateProximity(x: number, z: number): void {
const near = this.nearestInteractable(x, z)
getBus().emit('hud:hint', {
text: near ? near.label : '探索城市 · 靠近高亮物互动',
interactable: !!near,
})
}
tryInteract(x: number, z: number): void {
const near = this.nearestInteractable(x, z)
if (!near) {
getBus().emit('interact:done', {
id: '',
action: '',
ok: false,
message: '附近没有可互动对象',
})
return
}
const action = this.economy.actions[near.action]
const result = applyAction(this.stats, action)
this.stats = result.stats
if (result.ok) {
this.flags[`did_${near.action}`] = true
this.stats.locationId = near.structureId
getBus().emit('scene:enter', { structureId: near.structureId })
this.persist()
this.emitAll()
}
getBus().emit('interact:done', {
id: near.id,
action: near.action,
ok: result.ok,
message: result.message,
})
}
emitAll(): void {
getBus().emit('stats:changed', this.stats)
getBus().emit('time:tick', {
minutes: this.stats.minutes,
day: this.stats.day,
label: `D${this.stats.day} ${formatClock(this.stats.minutes)}`,
})
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "f8871e41-a1b3-49a9-82c5-46c0db23c9a8",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,34 @@
/** Pure game clock — independent of Cocos. */
export function formatClock(minutes: number): string {
const m = ((minutes % 1440) + 1440) % 1440
const h = Math.floor(m / 60)
const mm = m % 60
return `${String(h).padStart(2, '0')}:${String(mm).padStart(2, '0')}`
}
export function advanceMinutes(
current: number,
day: number,
delta: number,
): { minutes: number; day: number } {
let minutes = current + delta
let d = day
while (minutes >= 1440) {
minutes -= 1440
d += 1
}
while (minutes < 0) {
minutes += 1440
d = Math.max(1, d - 1)
}
return { minutes, day: d }
}
/** 0..1 sun elevation heuristic from clock minutes */
export function sunElevFromMinutes(minutes: number): number {
const m = ((minutes % 1440) + 1440) % 1440
// peak noon
const noonDist = Math.abs(m - 12 * 60) / (12 * 60)
return Math.max(0.08, 1 - noonDist)
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "9c9b92f5-3cd3-4be4-a3da-b6227bd85da1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,31 @@
import type { ActionEconomy } from './EconomySystem'
import type { PlayerStats } from '../core/types'
import { canAfford, applyCash } from './EconomySystem'
import { applyEnergy, hasEnergy } from './EnergySystem'
import { advanceMinutes } from './TimeSystem'
export type WorkResult = {
ok: boolean
stats: PlayerStats
message: string
}
export function applyAction(
stats: PlayerStats,
action: ActionEconomy | undefined,
): WorkResult {
if (!action) {
return { ok: false, stats, message: '未知互动' }
}
if (!canAfford(stats, action.cashDelta)) {
return { ok: false, stats, message: '现金不足' }
}
if (!hasEnergy(stats, action.energyDelta)) {
return { ok: false, stats, message: '精力不足,先去睡觉或吃饭' }
}
let next = applyCash(stats, action.cashDelta)
next = applyEnergy(next, action.energyDelta)
const t = advanceMinutes(next.minutes, next.day, action.minutesDelta)
next = { ...next, minutes: t.minutes, day: t.day }
return { ok: true, stats: next, message: action.message }
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ae6b58cc-d5ed-40bd-a2a6-481110ffcb3e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "5efe558c-d801-45d3-bafc-c103fdbf5ef1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,67 @@
import { _decorator, Component, Label, ProgressBar } from 'cc'
import { getBus } from '../core/EventBus'
import type { PlayerStats } from '../core/types'
const { ccclass, property } = _decorator
/** Thin HUD binder — no game rules. */
@ccclass('HudView')
export class HudView extends Component {
@property(Label)
titleLabel: Label | null = null
@property(Label)
hintLabel: Label | null = null
@property(Label)
timeLabel: Label | null = null
@property(Label)
cashLabel: Label | null = null
@property(Label)
interactLabel: Label | null = null
@property(ProgressBar)
energyBar: ProgressBar | null = null
onEnable() {
getBus().on('stats:changed', this.onStats, this)
getBus().on('hud:hint', this.onHint, this)
getBus().on('time:tick', this.onTime, this)
getBus().on('interact:done', this.onInteractDone, this)
}
onDisable() {
getBus().off('stats:changed', this.onStats, this)
getBus().off('hud:hint', this.onHint, this)
getBus().off('time:tick', this.onTime, this)
getBus().off('interact:done', this.onInteractDone, this)
}
private onStats = (s: PlayerStats) => {
if (this.cashLabel) this.cashLabel.string = `¥${s.cash}`
if (this.energyBar) {
this.energyBar.progress = s.maxEnergy > 0 ? s.energy / s.maxEnergy : 0
}
if (this.titleLabel) {
this.titleLabel.string = `数字游民 · Day ${s.day}`
}
}
private onHint = (e: { text: string; interactable: boolean }) => {
if (this.hintLabel) this.hintLabel.string = e.text
if (this.interactLabel) {
this.interactLabel.node.active = e.interactable
this.interactLabel.string = '互动 · E / 点按右侧'
}
}
private onTime = (e: { label: string }) => {
if (this.timeLabel) this.timeLabel.string = e.label
}
private onInteractDone = (e: { message: string }) => {
if (this.hintLabel) this.hintLabel.string = e.message
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "77ff3bfe-03d9-4eb6-aac5-372ca481ef5c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,101 @@
import {
_decorator,
Component,
Node,
EventTouch,
UITransform,
input,
Input,
EventKeyboard,
KeyCode,
} from 'cc'
import { getBus } from '../core/EventBus'
import { stickVector } from '../vendor/nipple-math'
const { ccclass, property } = _decorator
/**
* Left-zone virtual stick — math from nipplejs (MIT).
* Emits player:move-input; E / Space / right-tap → interact:request.
*/
@ccclass('VirtualJoystick')
export class VirtualJoystick extends Component {
@property(Node)
stickKnob: Node | null = null
@property
maxRadius = 72
@property
threshold = 0.1
private _active = false
private _origin = { x: 0, y: 0 }
onEnable() {
this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this)
this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
this.node.on(Node.EventType.TOUCH_END, this.onTouchEnd, this)
this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this)
input.on(Input.EventType.KEY_DOWN, this.onKey, this)
}
onDisable() {
this.node.off(Node.EventType.TOUCH_START, this.onTouchStart, this)
this.node.off(Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
this.node.off(Node.EventType.TOUCH_END, this.onTouchEnd, this)
this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this)
input.off(Input.EventType.KEY_DOWN, this.onKey, this)
}
private onKey(e: EventKeyboard) {
if (e.keyCode === KeyCode.KEY_E || e.keyCode === KeyCode.SPACE) {
getBus().emit('interact:request')
}
}
/** Editor button Click */
onInteractClick() {
getBus().emit('interact:request')
}
private zoneWidth(): number {
return this.node.getComponent(UITransform)?.width ?? 750
}
private onTouchStart(e: EventTouch) {
const ui = e.getUILocation()
if (ui.x > this.zoneWidth() * 0.45) {
getBus().emit('interact:request')
return
}
this._active = true
this._origin = { x: ui.x, y: ui.y }
}
private onTouchMove(e: EventTouch) {
if (!this._active) return
const ui = e.getUILocation()
const v = stickVector(
this._origin,
{ x: ui.x, y: ui.y },
this.maxRadius,
this.threshold,
)
if (this.stickKnob) {
this.stickKnob.setPosition(
v.x * this.maxRadius,
v.y * this.maxRadius,
0,
)
}
// UI +y up → world forward as -z for stickVector y
getBus().emit('player:move-input', { x: v.x, z: -v.y })
}
private onTouchEnd() {
this._active = false
getBus().emit('player:move-input', { x: 0, z: 0 })
if (this.stickKnob) this.stickKnob.setPosition(0, 0, 0)
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "8dcab59e-88cd-4524-9a82-fc5af581d22a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "d825d806-0ca6-4283-9e8a-588b934f8d66",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,84 @@
/**
* Vendored from developit/mitt (MIT)
* https://github.com/developit/mitt
* Stars verified >1000 — see docs/OSS_RESEARCH.md
*
* Copyright (c) Jason Miller
* Permission is hereby granted, free of charge, to any person obtaining a copy...
*/
export type EventType = string | symbol
export type Handler<T = unknown> = (event: T) => void
export type WildcardHandler<T = Record<string, unknown>> = (
type: keyof T,
event: T[keyof T],
) => void
export type EventHandlerList<T = unknown> = Array<Handler<T>>
export type WildCardEventHandlerList<T = Record<string, unknown>> = Array<
WildcardHandler<T>
>
export type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<
keyof Events | '*',
EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>
>
export interface Emitter<Events extends Record<EventType, unknown>> {
all: EventHandlerMap<Events>
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void
on(type: '*', handler: WildcardHandler<Events>): void
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void
off(type: '*', handler: WildcardHandler<Events>): void
emit<Key extends keyof Events>(type: Key, event: Events[Key]): void
emit<Key extends keyof Events>(
type: undefined extends Events[Key] ? Key : never,
): void
}
export default function mitt<Events extends Record<EventType, unknown>>(
all?: EventHandlerMap<Events>,
): Emitter<Events> {
type GenericEventHandler =
| Handler<Events[keyof Events]>
| WildcardHandler<Events>
all = all || new Map()
return {
all,
on(type: EventType, handler: GenericEventHandler) {
const handlers = all!.get(type)
if (handlers) {
;(handlers as GenericEventHandler[]).push(handler)
} else {
all!.set(type, [handler] as EventHandlerList<Events[keyof Events]>)
}
},
off(type: EventType, handler?: GenericEventHandler) {
const handlers = all!.get(type)
if (handlers) {
if (handler) {
handlers.splice(handlers.indexOf(handler as never) >>> 0, 1)
} else {
all!.set(type, [])
}
}
},
emit(type: EventType, evt?: unknown) {
let handlers = all!.get(type)
if (handlers) {
;(handlers as EventHandlerList)
.slice()
.map((handler) => {
handler(evt!)
})
}
handlers = all!.get('*')
if (handlers) {
;(handlers as WildCardEventHandlerList)
.slice()
.map((handler) => {
handler(type, evt!)
})
}
},
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "062c8aba-e78a-44c8-bd00-fc6ca19cfad4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,61 @@
/**
* Math helpers adapted from yoannmoinet/nipplejs (MIT)
* https://github.com/yoannmoinet/nipplejs — src/utils.js
* Stars verified >1000 — see docs/OSS_RESEARCH.md
*
* Only pure functions; no DOM. Used by VirtualJoystick.
*/
export type Point = { x: number; y: number }
export function distance(p1: Point, p2: Point): number {
const dx = p2.x - p1.x
const dy = p2.y - p1.y
return Math.sqrt(dx * dx + dy * dy)
}
export function radians(a: number): number {
return a * (Math.PI / 180)
}
export function degrees(a: number): number {
return a * (180 / Math.PI)
}
/** nipplejs: angle in degrees from p1 → p2 */
export function angle(p1: Point, p2: Point): number {
const dx = p2.x - p1.x
const dy = p2.y - p1.y
return degrees(Math.atan2(dy, dx))
}
/** nipplejs clamp: keep pos within size radius of nipplePos (axis-aligned box; circle applied by caller) */
export function clamp(pos: Point, nipplePos: Point, size: number): Point {
return {
x: Math.min(Math.max(pos.x, nipplePos.x - size), nipplePos.x + size),
y: Math.min(Math.max(pos.y, nipplePos.y - size), nipplePos.y + size),
}
}
/**
* Circle-constrained stick vector (common nipple pattern):
* force = dist / maxRadius, capped at 1; vector normalized * force.
*/
export function stickVector(
origin: Point,
finger: Point,
maxRadius: number,
threshold = 0.1,
): { x: number; y: number; force: number; angleDeg: number; active: boolean } {
const dist = distance(origin, finger)
const angleDeg = angle(origin, finger)
const force = Math.min(1, dist / Math.max(1e-6, maxRadius))
if (force < threshold) {
return { x: 0, y: 0, force: 0, angleDeg, active: false }
}
const rad = radians(angleDeg)
// screen: +x right, +y up (Cocos UI); world XZ mapped by consumer
const x = Math.cos(rad) * force
const y = Math.sin(rad) * force
return { x, y, force, angleDeg, active: true }
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "808659c4-22bf-499e-8b33-ce30691d734a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,23 @@
{
"name": "nomadro-minigame-cocos",
"platform": "wechatgame",
"buildPath": "project://build",
"debug": true,
"md5Cache": false,
"sourceMaps": false,
"replaceSplashScreen": false,
"mainBundleCompressionType": "merge_dep",
"mainBundleIsRemote": false,
"startScene": "f26eaba4-119d-4108-a3a7-84f954d25692",
"outputName": "wechatgame",
"packages": {
"wechatgame": {
"appid": "wx2900cac0858ca7dc",
"orientation": "portrait",
"separate_engine": false,
"highPerformanceMode": false,
"wasm": false,
"enabelWebGL2": "off"
}
}
}

View File

@ -0,0 +1,13 @@
# 双引擎并行
| 方案 | 路径 | 角色 |
|---|---|---|
| **A · Unity(当前可玩)** | `apps/minigame-unity` → 导出同步 `apps/minigame` | 微信开发者工具正在跑的方案 |
| **B · Cocos Creator 3.8.x(新方案)** | `apps/minigame-cocos` | 按 `AGENTS.md` 规范推进的第二套实现 |
规则:
1. **保留** Unity;不得用 Cocos 覆盖 `apps/minigame` 导出目录,除非产品明确切主引擎。
2. Cocos 构建输出建议:`apps/minigame-cocos/build/wechatgame`(独立目录)。
3. AppID 共用:`wx2900cac0858ca7dc`。
4. 玩法数据可对齐 JSON 语义,但代码树隔离。

View File

@ -0,0 +1,45 @@
# 开源调研记录(实时核实)
核实时间:2026-11-06 · 来源:GitHub API `stargazers_count` / `pushed_at` / `license.spdx_id`。
规则:推荐列表 **仅含 Stars > 1000**;不足者单独列入「不合格,不得复用为依赖」。
## 合格项目(可复用)
| 仓库 | Stars | 更新 | License | 用途 | 本项目落地 |
|---|---:|---|---|---|---|
| [cocos/cocos-engine](https://github.com/cocos/cocos-engine) | 9908 | 2026-10-28 | NOASSERTION(引擎随 Creator) | 3.8 CharacterController / Camera / Input / Physics API | 人物与摄像机走引擎官方 API,不 fork 子示例 |
| [developit/mitt](https://github.com/developit/mitt) | 11906 | 2024-08-14 | MIT | 事件总线 | `assets/scripts/vendor/mitt.ts` 原样适配(MIT 保留版权头) |
| [yoannmoinet/nipplejs](https://github.com/yoannmoinet/nipplejs) | 1953 | 2026-05-27 | MIT | 虚拟摇杆数学 | `nipple-math.ts` 复用 `distance` / `angle` / `clamp` / `force=threshold` |
| [KenneyNL/Starter-Kit-City-Builder](https://github.com/KenneyNL/Starter-Kit-City-Builder) | 1505 | 2026-03-12 | MIT(模型 CC0) | 城市结构目录 + 存档字段 | JSON:`structures[{id,position,orientation}]` + cash;**不移植 Godot 脚本** |
| [primus/eventemitter3](https://github.com/primus/eventemitter3) | 3532 | 2026-01-19 | MIT | 备选事件总线 | 已选 mitt(更小);本仓未再 vendor |
Kenney 站点 glTF(Tiny City / Furniture Kit 等)为 **CC0**,可作为后续 GLB 资产来源(非 GitHub Star 规则对象,但需注明授权)。
## 不合格(明确排除)
| 仓库 | Stars | 原因 |
|---|---:|---|
| cocos/cocos-example-projects | 587 | < 1000 |
| AndyYuTian/ThirdPersonGameTemplate | 1 | < 1000;仅为 3.8 官方案例参考,**不拷贝进仓** |
| cocos-creator/tutorial-mind-your-step-3d | 105 | < 1000 |
| a1076559139/xforge | 250 | < 1000 |
| cocos/cocos-test-projects | 328 | < 1000 |
> 第三人称官方模板 Stars 不足,**不允许**声称「复用了 ThirdPersonGameTemplate」。P0 以 `cocos-engine` 公开 API + nipplejs 数学自研适配。
## 模块 → OSS 映射
| 模块 | 选用 | 复用内容 |
|---|---|---|
| 事件总线 | mitt | `on/off/emit` + Map 存储 |
| 虚拟摇杆 | nipplejs | 距离、角度、半径 clamp、force 阈值 |
| 城市数据 | Kenney City Builder | 结构数组 + cash + 序列化字段形态 |
| 角色/相机 | cocos-engine 3.8 | Input、节点变换、相机跟拍(自写组件) |
| 存档 | 微信 Storage + Kenney 字段思路 | JSON blob;键版本化 |
## 验证动作(本迭代)
1. 已用 GitHub API 拉取上述仓库元数据(非仅读 README)。
2. 已阅读 mitt 源码全文、nipplejs `utils.js` / `nipple.js` 关键算法、Kenney `builder.gd` 存档结构。
3. Cocos 专用 3D 控制器示例无一达标 → 已书面声明,未虚构。

View File

@ -0,0 +1,52 @@
# 阶段交付日志
## 2026-11-06 · 并行方案立项 + P0~P3 代码落地
### 修改文件清单
- `AGENTS.md` — 用户总规范落地
- `docs/OSS_RESEARCH.md` — Stars 实时核实
- `docs/DUAL_ENGINE.md` — Unity / Cocos 并行关系
- `docs/PHASE_LOG.md` — 本文件
- `README.md` / `package.json` / `tsconfig.json`
- `assets/data/city-prototype.json` · `economy.json`
- `assets/scripts/**` — core / sim / player / ui / scene / bootstrap / vendor
- `assets/scripts/bootstrap/AutoSceneSetup.ts` — 空场景一键搭景
- `docs/SCENE_SETUP.md`
- `tests/sim-world.test.mjs`
- 移除旧单体脚本:`assets/scripts/game/*`(由模块化目录取代)
- 同步说明:`apps/minigame-unity/README.md`、`apps/minigame/README.md`(双引擎并行,不覆盖)
**未改玩法导出**:Unity 工程与 `apps/minigame` 运行包保持可玩,Cocos 不盖写。
### 使用的开源项目
见 `OSS_RESEARCH.md`:cocos-engine · mitt · nipplejs · Kenney Starter-Kit-City-Builder。
### 复用的具体代码
- mitt:`vendor/mitt.ts` 完整 API
- nipplejs:`distance` / `angle` / `clamp` / force-threshold → `vendor/nipple-math.ts`
- Kenney:structures + cash 存档字段形态 → `SaveBlob` / `city-prototype.json`
### 新增代码
模块化架构 + 离线城市原型 JSON + 纯 TS 模拟(时间/经济/精力/工作/存档)+ P0 电机/相机/摇杆 + 程序化 stylized 场景。
### 测试结果
```
node tests/sim-world.test.mjs → OK
```
### 性能情况
尚未上微信真机;当前为程序化盒体原型,Draw Call 预期可控。GLB / 烘焙光照待 P4+。
### 未解决问题
1. Cocos Creator 3.8.6 已解压并可打开工程(窗口标题可见);需在编辑器内打开 `assets/scenes/Main.scene` 点预览 / 构建微信到 `build/wechatgame`。
2. Cocos 专用第三人称示例 Stars <1000,未拷贝官方模板。
3. 美术为增强后的程序化 stylized(窗门/家具/NPC);Kenney CC0 GLB 待换。
4. 音频系统未做。
5. 桌面 Computer Use 通道不可用,未能自动点预览按钮。

View File

@ -0,0 +1,27 @@
# Cocos 场景挂载(3.8.6)
## 最快路径
1. Creator 3.8.6 打开 `apps/minigame-cocos`(本机:`tools/CocosCreator-3.8.6`,说明见 `tools/README-COCOS.md`)
2. 资源管理器打开 **`assets/scenes/Main.scene`**(已挂 `Game` + `AutoSceneSetup`)
3. 点顶部 **预览**(▶):运行时生成 pastel 城市 / 玩家 / 第三人称相机 / HUD
4. 构建 → 微信小游戏 → `build/wechatgame`(勿覆盖 `apps/minigame` Unity 导出)
## 手动挂线(可选)
若不用 `AutoSceneSetup`,根节点挂 `GameRoot`,并拖拽:
| 属性 | 组件 |
|---|---|
| player | `PlayerMotor` |
| cameraFollow | `CameraFollow` |
| world | `WorldBootstrap` |
| hud | `HudView` |
| joystick | `VirtualJoystick` |
| playerNode | 玩家节点 |
## 操作
- 左半屏拖动摇杆 / WASD 移动
- 右半屏拖动旋转相机
- 右侧点按 / E / Space 互动

View File

@ -0,0 +1,13 @@
{
"name": "nomadro-minigame-cocos",
"uuid": "a7c3e9f1-2b4d-4e8a-9c1f-6d5e8b0a2f31",
"version": "1.0.0",
"creator": {
"version": "3.8.6"
},
"description": "NOMADRO 3D digital-nomad life sim — Cocos Creator 3.8.6 → WeChat Mini Game (parallel to Unity)",
"scripts": {
"test:sim": "node tests/sim-world.test.mjs",
"open-hint": "node scripts/print-cocos-path.mjs"
}
}

View File

@ -0,0 +1,11 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
console.log('')
console.log('Cocos Dashboard / Creator → 打开工程:')
console.log(root)
console.log('')
console.log('构建微信小游戏后 → 微信开发者工具导入 build/wechatgame')
console.log('AppID: wx2900cac0858ca7dc')
console.log('')

View File

@ -0,0 +1,6 @@
{
"__version__": "1.3.9",
"textureCompressConfig": {
"genMipmaps": false
}
}

View File

@ -0,0 +1,3 @@
{
"__version__": "1.0.1"
}

View File

@ -0,0 +1,222 @@
{
"__version__": "1.0.12",
"modules": {
"configs": {
"defaultConfig": {
"name": "Default Config",
"cache": {
"base": {
"_value": true
},
"gfx-webgl": {
"_value": true
},
"gfx-webgl2": {
"_value": true
},
"gfx-webgpu": {
"_value": false
},
"animation": {
"_value": true
},
"skeletal-animation": {
"_value": false
},
"3d": {
"_value": true
},
"meshopt": {
"_value": false
},
"2d": {
"_value": true
},
"xr": {
"_value": false
},
"rich-text": {
"_value": true
},
"mask": {
"_value": true
},
"graphics": {
"_value": true
},
"ui-skew": {
"_value": true
},
"affine-transform": {
"_value": true
},
"ui": {
"_value": true
},
"particle": {
"_value": false
},
"physics": {
"_value": false,
"_option": "physics-ammo"
},
"physics-ammo": {
"_value": false,
"_flags": {
"LOAD_BULLET_MANUALLY": false
}
},
"physics-cannon": {
"_value": false
},
"physics-physx": {
"_value": false,
"_flags": {
"LOAD_PHYSX_MANUALLY": false
}
},
"physics-builtin": {
"_value": false
},
"physics-2d": {
"_value": false,
"_option": "physics-2d-box2d"
},
"physics-2d-box2d": {
"_value": true
},
"physics-2d-box2d-wasm": {
"_value": false,
"_flags": {
"LOAD_BOX2D_MANUALLY": false
}
},
"physics-2d-builtin": {
"_value": false
},
"physics-2d-box2d-jsb": {
"_value": false
},
"intersection-2d": {
"_value": false
},
"primitive": {
"_value": true
},
"profiler": {
"_value": false
},
"occlusion-query": {
"_value": false
},
"geometry-renderer": {
"_value": false
},
"debug-renderer": {
"_value": false
},
"particle-2d": {
"_value": false
},
"audio": {
"_value": true
},
"video": {
"_value": false
},
"webview": {
"_value": false
},
"tween": {
"_value": true
},
"websocket": {
"_value": false
},
"websocket-server": {
"_value": false
},
"terrain": {
"_value": false
},
"light-probe": {
"_value": false
},
"tiled-map": {
"_value": true
},
"vendor-google": {
"_value": false
},
"spine": {
"_value": true,
"_option": "spine-3.8"
},
"spine-3.8": {
"_value": false,
"_flags": {
"LOAD_SPINE_MANUALLY": false
}
},
"spine-4.2": {
"_value": false,
"_flags": {
"LOAD_SPINE_MANUALLY": false
}
},
"dragon-bones": {
"_value": true
},
"marionette": {
"_value": true
},
"procedural-animation": {
"_value": false
},
"custom-pipeline-post-process": {
"_value": false
},
"render-pipeline": {
"_value": true,
"_option": "custom-pipeline"
},
"custom-pipeline": {
"_value": false
},
"legacy-pipeline": {
"_value": false
}
},
"includeModules": [
"2d",
"3d",
"affine-transform",
"animation",
"audio",
"base",
"custom-pipeline",
"dragon-bones",
"gfx-webgl",
"gfx-webgl2",
"graphics",
"marionette",
"mask",
"primitive",
"rich-text",
"spine-3.8",
"tiled-map",
"tween",
"ui",
"ui-skew"
],
"noDeprecatedFeatures": {
"value": false,
"version": ""
},
"flags": {}
}
},
"globalConfigKey": "defaultConfig"
},
"macros": {}
}

View File

@ -0,0 +1,23 @@
{
"__version__": "1.0.1",
"information": {
"customSplash": {
"id": "customSplash",
"label": "customSplash",
"enable": true,
"customSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?sid=2b0ac12b109fc800ed73554fa2355859"
}
},
"removeSplash": {
"id": "removeSplash",
"label": "removeSplash",
"enable": true,
"removeSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?sid=2b0ac12b109fc800ed73554fa2355859"
}
}
}
}

View File

@ -0,0 +1,3 @@
{
"__version__": "1.0.4"
}

View File

@ -0,0 +1,18 @@
{
"__version__": "1.0.6",
"physics": {
"gravity": {
"x": 0,
"y": -10,
"z": 0
}
},
"general": {
"designResolution": {
"width": 750,
"height": 1334,
"fitWidth": true,
"fitHeight": false
}
}
}

View File

@ -0,0 +1,112 @@
/**
* Node smoke tests for sim layer (no Cocos runtime).
* Run: node tests/sim-world.test.mjs
*/
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, join } from 'node:path'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
const city = JSON.parse(readFileSync(join(root, 'assets/data/city-prototype.json'), 'utf8'))
const economy = JSON.parse(readFileSync(join(root, 'assets/data/economy.json'), 'utf8'))
function formatClock(minutes) {
const m = ((minutes % 1440) + 1440) % 1440
const h = Math.floor(m / 60)
const mm = m % 60
return `${String(h).padStart(2, '0')}:${String(mm).padStart(2, '0')}`
}
function advanceMinutes(current, day, delta) {
let minutes = current + delta
let d = day
while (minutes >= 1440) {
minutes -= 1440
d += 1
}
return { minutes, day: d }
}
function applyAction(stats, action) {
if (!action) return { ok: false, stats, message: '未知互动' }
if (action.cashDelta < 0 && stats.cash + action.cashDelta < 0) {
return { ok: false, stats, message: '现金不足' }
}
if (action.energyDelta < 0 && stats.energy + action.energyDelta < 0) {
return { ok: false, stats, message: '精力不足' }
}
let next = {
...stats,
cash: Math.max(0, Math.round(stats.cash + action.cashDelta)),
energy: Math.min(
stats.maxEnergy,
Math.max(0, Math.round(stats.energy + action.energyDelta)),
),
}
const t = advanceMinutes(next.minutes, next.day, action.minutesDelta)
next = { ...next, minutes: t.minutes, day: t.day }
return { ok: true, stats: next, message: action.message }
}
function nearest(x, z) {
let best = null
let bestD = Infinity
for (const it of city.interactables) {
const d = Math.hypot(it.x - x, it.z - z)
if (d <= it.radius && d < bestD) {
best = it
bestD = d
}
}
return best
}
// --- assertions ---
assert.equal(city.structures.length >= 6, true, 'city has prototype buildings')
assert.ok(city.interactables.find((i) => i.action === 'work_remote'))
assert.ok(economy.actions.sleep)
let stats = {
cash: economy.startCash,
energy: economy.startEnergy,
maxEnergy: economy.maxEnergy,
minutes: 7 * 60 + 10,
day: 1,
}
const nearBed = nearest(-9.2, -8.2)
assert.equal(nearBed?.action, 'sleep')
const slept = applyAction(stats, economy.actions.sleep)
assert.equal(slept.ok, true)
assert.ok(slept.stats.energy > stats.energy)
stats = slept.stats
const broke = applyAction(
{ ...stats, cash: 10 },
economy.actions.shop,
)
assert.equal(broke.ok, false)
const work = applyAction(stats, economy.actions.work_remote)
assert.equal(work.ok, true)
assert.ok(work.stats.cash > stats.cash)
assert.equal(formatClock(0), '00:00')
assert.equal(formatClock(7 * 60 + 10), '07:10')
const dayRoll = advanceMinutes(23 * 60, 1, 120)
assert.equal(dayRoll.day, 2)
console.log('sim-world.test.mjs OK')
console.log(
JSON.stringify(
{
structures: city.structures.map((s) => s.id),
cashAfterWork: work.stats.cash,
clock: formatClock(work.stats.minutes),
},
null,
2,
),
)

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2015",
"module": "ES2015",
"strict": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"types": [],
"lib": ["ES2015", "DOM"]
},
"include": ["./assets/scripts/**/*.ts", "./assets/data/**/*.json"]
}

7
apps/minigame-godot/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.godot/
build/
wxgame/
*.translation
export_presets.cfg.bak
.mono/
data_*/

View File

@ -0,0 +1,18 @@
# Nomadro Minigame — Godot 4.7 → WeChat
Scheme C. Procedural Chiang Mai block + boy/girl NPCs. Export pack replaces `engine/empty-tips.bin` in the godothub 4.7 WeChat template.
## Dev
```bat
godot_console.exe --path apps\minigame-godot
```
## Export → DevTools SoT (`apps/minigame`)
```bat
godot_console.exe --headless --path apps\minigame-godot --export-pack "Web" apps\minigame-godot\build\web\nomadro.pck
copy /Y apps\minigame-godot\build\web\nomadro.pck apps\minigame\engine\empty-tips.bin
```
AppID: `wx2900cac0858ca7dc`

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://4lbpt0u3aora"
path="res://.godot/imported/Fox.glb-7594cf48a751e1250da09b460a82f915.scn"
[deps]
source_file="res://art/chars/Fox.glb"
dest_files=["res://.godot/imported/Fox.glb-7594cf48a751e1250da09b460a82f915.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dwvw68u48pip0"
path="res://.godot/imported/Fox_0.png-1e5c1f02f9d8d8f457a5675a9cac53f5.ctex"
metadata={
"vram_texture": false
}
generator_parameters={
"md5": "132bf1e341c44f47a0b4e87b884c734e"
}
[deps]
source_file="res://art/chars/Fox_0.png"
dest_files=["res://.godot/imported/Fox_0.png-1e5c1f02f9d8d8f457a5675a9cac53f5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bhq8jq0tslvtq"
path="res://.godot/imported/RobotExpressive.glb-39d0bb1a6e0212dee2d19007a63dd91f.scn"
[deps]
source_file="res://art/chars/RobotExpressive.glb"
dest_files=["res://.godot/imported/RobotExpressive.glb-39d0bb1a6e0212dee2d19007a63dd91f.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://b6ncv8uxxl0nb"
path="res://.godot/imported/Soldier.glb-3d0bb4f6d5e176e3420f4b61f428401c.scn"
[deps]
source_file="res://art/chars/Soldier.glb"
dest_files=["res://.godot/imported/Soldier.glb-3d0bb4f6d5e176e3420f4b61f428401c.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

View File

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://fhdd8lqo1byv"
path="res://.godot/imported/Soldier_file2.jpg-e47a9a34107418339701ba5913392ab1.ctex"
metadata={
"vram_texture": false
}
generator_parameters={
"md5": "a6b63d88a0ce6549dd221d1b4c57c50b"
}
[deps]
source_file="res://art/chars/Soldier_file2.jpg"
dest_files=["res://.godot/imported/Soldier_file2.jpg-e47a9a34107418339701ba5913392ab1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

View File

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://blvxugm4f7x8a"
path="res://.godot/imported/Soldier_vanguard_vanguard_diffuse_tga.jpg-8698946a5419ac1dc1e1d8b35265b81e.ctex"
metadata={
"vram_texture": false
}
generator_parameters={
"md5": "2d39e920a2aed14fb81f0cd25c7937bd"
}
[deps]
source_file="res://art/chars/Soldier_vanguard_vanguard_diffuse_tga.jpg"
dest_files=["res://.godot/imported/Soldier_vanguard_vanguard_diffuse_tga.jpg-8698946a5419ac1dc1e1d8b35265b81e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://ral53ooupw0q"
path="res://.godot/imported/building-garage.glb-43842bf032fc0536df76013a95fa4060.scn"
[deps]
source_file="res://art/city/building-garage.glb"
dest_files=["res://.godot/imported/building-garage.glb-43842bf032fc0536df76013a95fa4060.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://b7d4346let6cl"
path="res://.godot/imported/building-small-a.glb-87d9a008889b7a7908e7fce5a9ee0af6.scn"
[deps]
source_file="res://art/city/building-small-a.glb"
dest_files=["res://.godot/imported/building-small-a.glb-87d9a008889b7a7908e7fce5a9ee0af6.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://emajlc4on05"
path="res://.godot/imported/building-small-b.glb-b024ca1a9bcce3456dee35db54cb7cf7.scn"
[deps]
source_file="res://art/city/building-small-b.glb"
dest_files=["res://.godot/imported/building-small-b.glb-b024ca1a9bcce3456dee35db54cb7cf7.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

View File

@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://daobv7w2l6ntm"
path="res://.godot/imported/building-small-c.glb-cbe55c094dee4838c6b1c4f6768f4e12.scn"
[deps]
source_file="res://art/city/building-small-c.glb"
dest_files=["res://.godot/imported/building-small-c.glb-cbe55c094dee4838c6b1c4f6768f4e12.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More