godot-kit 1.0.1774034713 → 1.0.1774076948
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/lib/cli-game.js +2 -2
- package/lib/dashboard.js +8 -7
- package/lib/templates.js +9 -0
- package/package.json +1 -1
package/lib/cli-game.js
CHANGED
|
@@ -85,13 +85,13 @@ function registerGameCommands(program) {
|
|
|
85
85
|
|
|
86
86
|
gm.command('call <path> <method> [args...]').description('Call a method on a node')
|
|
87
87
|
.action((path, method, args) => run(async () => {
|
|
88
|
-
let parsedArgs = []; if (args && args.length) { try {
|
|
88
|
+
let parsedArgs = []; if (args && args.length) { try { const p = JSON.parse(args[0]); parsedArgs = Array.isArray(p) ? p : [p]; } catch { parsedArgs = args; } }
|
|
89
89
|
pj(await gamePost('/call', { path, method, args: parsedArgs }));
|
|
90
90
|
}));
|
|
91
91
|
|
|
92
92
|
gm.command('signal <path> <sig> [args...]').description('Emit a signal on a node')
|
|
93
93
|
.action((path, sig, args) => run(async () => {
|
|
94
|
-
let parsedArgs = []; if (args && args.length) { try {
|
|
94
|
+
let parsedArgs = []; if (args && args.length) { try { const p = JSON.parse(args[0]); parsedArgs = Array.isArray(p) ? p : [p]; } catch { parsedArgs = args; } }
|
|
95
95
|
pj(await gamePost('/signal', { path, signal: sig, args: parsedArgs }));
|
|
96
96
|
}));
|
|
97
97
|
|
package/lib/dashboard.js
CHANGED
|
@@ -22,16 +22,16 @@ function dims() {
|
|
|
22
22
|
return { W, H, HALF: Math.floor(W / 2), TREE_H: H - LOG_H - 4 };
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
function renderTree(node, lines, depth, max) {
|
|
25
|
+
function renderTree(node, lines, depth, max, half) {
|
|
26
26
|
if (lines.length >= max) return;
|
|
27
27
|
const indent = ' '.repeat(depth);
|
|
28
|
-
lines.push(truncate(`${indent}[${node.class}] ${node.name}`,
|
|
29
|
-
(node.children || []).forEach(c => renderTree(c, lines, depth + 1, max));
|
|
28
|
+
lines.push(truncate(`${indent}[${node.class}] ${node.name}`, half - 4));
|
|
29
|
+
(node.children || []).forEach(c => renderTree(c, lines, depth + 1, max, half));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function renderPerf(perf) {
|
|
32
|
+
function renderPerf(perf, half) {
|
|
33
33
|
const keys = ['fps','process_ms','physics_ms','memory_static','objects','nodes','draw_calls','video_mem'];
|
|
34
|
-
return keys.map(k => truncate(`${k}: ${typeof perf[k] === 'number' ? perf[k].toFixed(1) : (perf[k] || 'N/A')}`,
|
|
34
|
+
return keys.map(k => truncate(`${k}: ${typeof perf[k] === 'number' ? perf[k].toFixed(1) : (perf[k] || 'N/A')}`, half - 4));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async function runDashboard() {
|
|
@@ -45,13 +45,14 @@ async function runDashboard() {
|
|
|
45
45
|
|
|
46
46
|
async function refresh() {
|
|
47
47
|
try {
|
|
48
|
+
const { HALF, TREE_H } = dims();
|
|
48
49
|
const [tree, perf, logs] = await Promise.all([
|
|
49
50
|
gameGet('/tree').catch(() => null),
|
|
50
51
|
gameGet('/perf').catch(() => null),
|
|
51
52
|
gameGet('/logs').catch(() => null),
|
|
52
53
|
]);
|
|
53
|
-
if (tree && tree.tree) { treeLines = []; renderTree(tree.tree, treeLines, 0, TREE_H - 2); }
|
|
54
|
-
if (perf) perfLines = renderPerf(perf);
|
|
54
|
+
if (tree && tree.tree) { treeLines = []; renderTree(tree.tree, treeLines, 0, TREE_H - 2, HALF); }
|
|
55
|
+
if (perf) perfLines = renderPerf(perf, HALF);
|
|
55
56
|
if (logs && logs.logs) {
|
|
56
57
|
logs.logs.forEach(l => { if (!seenLogs.has(l)) { seenLogs.add(l); logLines.push(l); } });
|
|
57
58
|
if (logLines.length > LOG_H - 2) logLines = logLines.slice(-(LOG_H - 2));
|
package/lib/templates.js
CHANGED
|
@@ -665,6 +665,9 @@ func _physics_process(delta: float) -> void:
|
|
|
665
665
|
|
|
666
666
|
signal player_hit
|
|
667
667
|
|
|
668
|
+
func _ready() -> void:
|
|
669
|
+
\tbody_entered.connect(_on_body_entered)
|
|
670
|
+
|
|
668
671
|
func _on_body_entered(body: Node2D) -> void:
|
|
669
672
|
\tif body is CharacterBody2D:
|
|
670
673
|
\t\tplayer_hit.emit()
|
|
@@ -683,6 +686,9 @@ signal collected
|
|
|
683
686
|
|
|
684
687
|
var _collected := false
|
|
685
688
|
|
|
689
|
+
func _ready() -> void:
|
|
690
|
+
\tbody_entered.connect(_on_body_entered)
|
|
691
|
+
|
|
686
692
|
func _on_body_entered(body: Node2D) -> void:
|
|
687
693
|
\tif _collected:
|
|
688
694
|
\t\treturn
|
|
@@ -696,6 +702,9 @@ func _on_body_entered(body: Node2D) -> void:
|
|
|
696
702
|
|
|
697
703
|
signal level_completed
|
|
698
704
|
|
|
705
|
+
func _ready() -> void:
|
|
706
|
+
\tbody_entered.connect(_on_body_entered)
|
|
707
|
+
|
|
699
708
|
func _on_body_entered(body: Node2D) -> void:
|
|
700
709
|
\tif body is CharacterBody2D:
|
|
701
710
|
\t\tlevel_completed.emit()
|
package/package.json
CHANGED