nomadro/apps/minigame-cocos/assets/scripts/scene/InteractableZone.ts
Eric 58a845db32 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>
2026-11-06 20:17:14 +08:00

37 lines
891 B
TypeScript

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)
}
}