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>
37 lines
891 B
TypeScript
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)
|
|
}
|
|
}
|