feat: screenshot API, camera control, pipe/wire crossing detection
New endpoints: - POST /api/action/screenshot: capture screenshot to file - GET /api/screenshot/latest: serve PNG binary - POST /api/action/camera: move camera to (x,y) + set zoom - GET /api/state/camera: get current camera position/zoom Pipe/Wire crossing intelligence: - build_pipe/build_wire now detect existing pipes/wires at each cell - mode='line' (default): new pipe merges with existing - mode='cross': auto-places bridges at intersections to avoid connection - mode='single': one segment CLI: snapshot [file.png], camera <x> <y> [zoom], camera_status All high-level commands: auto pause, execute, resume
This commit is contained in:
@ -141,13 +141,14 @@ def cmd_fix_overload(args):
|
||||
|
||||
|
||||
def cmd_build_pipe_line(args):
|
||||
"""铺设管道路径。"""
|
||||
"""铺设管道路径(带交叉模式)。"""
|
||||
if len(args) < 5:
|
||||
print("Usage: build_pipe_line gas|liquid <x1> <y1> <x2> <y2> [bridge]")
|
||||
print("Usage: build_pipe_line gas|liquid <x1> <y1> <x2> <y2> [mode]")
|
||||
print(" mode: 'line'(默认,与已有管线合并) | 'cross'(跨接器跳过) | 'single'(单段)")
|
||||
return
|
||||
ptype = args[0]
|
||||
x1, y1, x2, y2 = int(args[1]), int(args[2]), int(args[3]), int(args[4])
|
||||
bridge = len(args) > 5 and args[5] == 'bridge'
|
||||
mode = args[5] if len(args) > 5 else 'line'
|
||||
|
||||
pause_before()
|
||||
|
||||
@ -157,11 +158,15 @@ def cmd_build_pipe_line(args):
|
||||
|
||||
result = api_post('/api/action/build_pipe', {
|
||||
"type": ptype, "x1": x1, "y1": y1,
|
||||
"x2": x2, "y2": y2, "bridge": bridge
|
||||
"x2": x2, "y2": y2, "mode": mode
|
||||
})
|
||||
if result.get('success'):
|
||||
segs = result.get('data', {}).get('segmentCount', 0)
|
||||
d = result.get('data', {})
|
||||
segs = d.get('segmentCount', 0)
|
||||
bridges = d.get('bridgesPlaced', 0)
|
||||
print(f"[OK] {ptype} pipe: {segs} segments from ({x1},{y1}) to ({x2},{y2})")
|
||||
if bridges > 0:
|
||||
print(f" {bridges} bridges placed at crossings (mode={mode})")
|
||||
else:
|
||||
print(f"[!] Failed: {result.get('errorMessage', 'unknown')}")
|
||||
|
||||
@ -295,8 +300,20 @@ COMMANDS = {
|
||||
'emergency_o2': cmd_emergency_o2,
|
||||
'build_pipe_line': cmd_build_pipe_line,
|
||||
'build_wire_line': cmd_build_wire_line,
|
||||
'snapshot': cmd_snapshot,
|
||||
'camera': cmd_camera,
|
||||
}
|
||||
|
||||
def cmd_snapshot(args):
|
||||
"""Take screenshot + view. Usage: snapshot [name]"""
|
||||
from oni_api import cmd_snapshot as api_snapshot
|
||||
api_snapshot(args)
|
||||
|
||||
def cmd_camera(args):
|
||||
"""Move camera. Usage: camera <x> <y> [zoom]"""
|
||||
from oni_api import cmd_camera as api_camera
|
||||
api_camera(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
cmd = sys.argv[1] if len(sys.argv) > 1 else 'help'
|
||||
|
||||
@ -316,11 +333,15 @@ if __name__ == '__main__':
|
||||
print(" expand_base <x> <y> <w> <h> 挖掘+建造墙壁(一键拓展房间)")
|
||||
print()
|
||||
print("=== Pipe / Wire Lines ===")
|
||||
print(" build_pipe_line <t> <x1> <y1> <x2> <y2> [bridge]")
|
||||
print(" t: gas | liquid")
|
||||
print(" build_wire_line <t> <x1> <y1> <x2> <y2> [bridge]")
|
||||
print(" build_pipe_line <t> <x1> <y1> <x2> <y2> [mode]")
|
||||
print(" t: gas | liquid | mode: line(merge) | cross(bridge)")
|
||||
print(" build_wire_line <t> <x1> <y1> <x2> <y2> [mode]")
|
||||
print(" t: regular | heavy | conductive | heavy_conductive")
|
||||
print()
|
||||
print("=== Screenshot / Camera ===")
|
||||
print(" snapshot [file.png] Take screenshot")
|
||||
print(" camera <x> <y> [zoom] Move camera view")
|
||||
print()
|
||||
print("All high-level commands auto-pause/resume the game.")
|
||||
else:
|
||||
COMMANDS[cmd](sys.argv[2:])
|
||||
|
||||
Reference in New Issue
Block a user