Server-side: sg_mcp_debug.cpp — 20 debug/RCON commands for entity inspection, player manipulation, weapon spawning, button simulation, and networking stats. Client-side: sg_mcp_debug_client.cpp — 15 commands for VGUI panel tree inspection, material diagnostics, cursor/keyboard simulation, and client entity queries. VPC: Register both files in server_hl2mp.vpc and client_hl2mp.vpc Stargate folders. Gitignore: Exclude source-engine-runtime/ (separate Rust workspace with its own git history).
5.7 KiB
OpenCode Loop Prompt
You are working in a repo whose goal is to build a Rust Source-compatible runtime alongside or from this Source Engine codebase.
Project goal: Create a Rust engine/runtime that can load Source Engine content well enough to run maps with compatible BSP geometry, VPK-mounted assets, VMT/VTF materials, simple game entities, a Source-like console/CVar system, and a menu/VGUI-like UI.
You must work incrementally. Do not attempt broad rewrites. Do not invent large systems unless the current task requires them.
State Files
Use these files as persistent memory between runs:
PROJECT_STATE.md: current status, architecture decisions, known limitations.ROADMAP.md: ordered milestones and task backlog.COMPATIBILITY.md: supported Source formats/entities/features.TASKS.md: active, queued, blocked, and completed tasks.DEVLOG.md: append-only progress log.DECISIONS.md: append-only architectural decisions.TESTING.md: how to run tests and what currently passes/fails.
Before Doing Any Work
- Read all state files if they exist.
- Inspect the repo structure.
- Identify the next smallest unblocked task from
TASKS.mdorROADMAP.md. - If no state files exist, create them with an initial plan.
Work Loop
- Pick exactly one small task.
- State the selected task in
DEVLOG.md. - Implement only that task.
- Add or update tests/fixtures where practical.
- Run formatting and relevant tests.
- Update
PROJECT_STATE.md,TASKS.md,COMPATIBILITY.md, andTESTING.md. - Append a short
DEVLOG.mdentry with:- task completed
- files changed
- commands run
- tests passing/failing
- next recommended task
- Stop.
Engineering Rules
- Prefer small, testable crates/modules.
- Prefer parsing/dump tools before runtime features.
- Use Rust 2021 or newer.
- Avoid
unsafeunless absolutely necessary and documented inDECISIONS.md. - Do not fake compatibility. If something is placeholder, mark it clearly in
COMPATIBILITY.md. - Do not implement unrelated features.
- Do not delete user work.
- Do not make sweeping formatting changes outside files touched for the task.
- Treat the original Source Engine code and tools as reference material, not as something to port wholesale in one pass.
Suggested Architecture
crates/source_mathcrates/source_bspcrates/source_vpkcrates/source_vmtcrates/source_vtfcrates/source_entitycrates/source_rendercrates/source_vguicrates/source_consolecrates/source_app
Preferred Libraries
glamfor mathwgpufor renderingwinitfor window/inputeguifor early menu/debug UIserdefor structured dumps/testsclapfor CLI toolstracingfor logginginstaor JSON fixtures for snapshot-style parser tests
Initial Milestone Order
- Workspace/crate layout.
- BSP header and lump directory parser.
- BSP entity lump parser.
- BSP planes, vertices, edges, surfedges, faces.
- Basic map dump CLI.
- VPK filesystem mounting.
- VMT KeyValues parser.
- VTF loading or placeholder texture path.
- Render BSP world geometry.
- Free camera.
info_player_startandworldspawnsupport.- Console and CVar registry.
- Basic Source-like menu.
- Player controller with BSP collision.
trigger_once/trigger_multiple.- Entity I/O outputs.
func_button/func_door.- HUD basics.
Task Size Rule
A task should usually be completable in under 1-2 hours and should leave the repo in a runnable or testable state.
If uncertain:
- Prefer adding a dump/inspection tool.
- Prefer parser tests over runtime guesses.
- Prefer documenting a limitation over pretending it works.
Starter TASKS.md
If TASKS.md does not exist, create this:
# Tasks
## Active
- [ ] Create Rust workspace layout for Source-compatible runtime.
## Queue
- [ ] Add `source_math` crate with `Vec3`, `QAngle`, planes, bounds helpers using `glam`.
- [ ] Add `source_bsp` crate and parse BSP header.
- [ ] Parse BSP lump directory.
- [ ] Add `bsp_dump` CLI that prints header/lump metadata as JSON.
- [ ] Parse BSP entity lump as KeyValues-style entities.
- [ ] Add entity dump command.
- [ ] Parse planes lump.
- [ ] Parse vertices lump.
- [ ] Parse edges and surfedges.
- [ ] Parse faces.
- [ ] Resolve texinfo and texdata.
- [ ] Add placeholder renderer with `wgpu`.
- [ ] Render untextured BSP world geometry.
- [ ] Add VMT parser.
- [ ] Add VTF texture path/loading placeholder.
- [ ] Render textured BSP faces.
- [ ] Add free camera.
- [ ] Add console and CVar registry.
- [ ] Add Source-like main menu.
- [ ] Implement `worldspawn`.
- [ ] Implement `info_player_start`.
- [ ] Implement basic player movement.
- [ ] Implement BSP collision traces.
- [ ] Implement `trigger_once`.
- [ ] Implement Source-style entity output dispatch.
## Blocked
## Done
Starter PROJECT_STATE.md
If PROJECT_STATE.md does not exist, create this:
# Project State
## Goal
Build a Rust Source-compatible runtime capable of loading and running Source maps with compatible assets, basic entities, menu UI, console/CVars, and game-layer behavior.
## Current Focus
Early engine foundation: workspace, parsers, dump tools, tests.
## Architecture
The project is split into small crates for formats, rendering, entity/game logic, UI, and application runtime.
## Compatibility Target
Initial target: Source SDK 2013 Singleplayer-style BSP maps and assets.
## Non-Goals For Now
- Full Source multiplayer networking
- Full NPC AI
- Full Source shader parity
- Save/load
- Demo playback
- Complete VGUI port
- Direct C++ game DLL compatibility
## Current Limitations
Everything is initially incomplete until implemented and tested.
Agent Instruction
Now begin the loop.