rust rewrite design doc #11
Labels
No labels
burndown-2026-08
autonomy
async-consult
autonomy
epic
autonomy
headless
autonomy
live-collab
c#
priority
P0
priority
P1
priority
P2
priority
P3
priority
P4
role/advocate
role/director
role/exec
role/frontend
role/gamedev
role/human
role/platform
role/qa
role/science
role/sysadmin
state
ambient
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
coilyco-gaming/factory-game-v3#11
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Handoff:
coilysiren/factory-game-v2Revival ContextUser / project intent
Kai has revived
coilysiren/factory-game-v2. The current working thesis is that this repo is a strong candidate for a programming-first factory/logistics simulation, not merely a Unity game prototype.The conversation leading into this was about games that are closer to “software engineering as gameplay”: Desynced, Screeps, Stationeers, The Farmer Was Replaced, JOY OF PROGRAMMING, etc. Kai’s stated discomfort with Factorio-like circuit networks is that they remain too visual/manual; she is interested in something closer to actual programming, autonomous agents, logistics protocols, simulation state, schedulers, control loops, and testable systems.
She then showed
factory-game-v2, and the repo looked more aligned with that desire than expected.Current strategic read
The repo’s structure appears to be “begging for Rust,” but the precise recommendation is not “rewrite the whole game in a Rust game engine immediately.”
The better formulation:
The likely best next project shape is:
The key idea is to treat the game as:
not:
Repo facts observed
The repo is
coilysiren/factory-game-v2, default branchmain. It was public and previously showed as archived when inspected; Kai has since said she revived it, so verify current archive status before making GitHub write assumptions.It is a Unity project using Unity 6000.0.36f1.
The repo contains a separate
tests.csprojtargeting .NET 8 and using xUnit / OpenTelemetry packages. It also explicitly references Unity DLL paths, including local-machine-specific paths such as/Applications/Unity/...andX:\unity-editor\....The
.gitignoreignores generated.csprojfiles but explicitly un-ignorestests.csproj, which indicates an intentional external/unit-test project alongside Unity.Existing architecture
The repo already separates many concepts into
CoreandUnitynamespaces. This is the most important architectural signal.WorldObjectCoreholds simulation/game state: movement, battery, resources, resource inserters, dispatchers, dispatch receivers, deployments, production, power, power lines, mining, GUID, type, target info, Unity backref, mobility flags, alerts, and grid position.WorldObject : MonoBehaviourwrapsWorldObjectCore, projects grid position into Unity transform position, handles visual naming, and creates/initializes the core object.Interpretation: this is not a normal Unity “everything is a MonoBehaviour” prototype. It is already halfway toward a headless simulation with Unity as a frontend adapter.
Game loop / simulation model
GameControllerCoreowns the world-object grid and mutation queues:queuedForDeletion,queuedForSpawn, andqueuedForMovement.Unity
GameController.Update()runs a tick loop when ready, ticks all world objects, then applies queued delete/move/spawn operations, regenerates pathfinding if needed, stops telemetry, increments tick count, and updateslastTick.Interpretation: this is already using deferred mutation, which maps very naturally to Rust command buffers or ECS-style system scheduling.
Domain model
GameContent.Itemis already pure-ish data: name, weight, volume, craft time, craft input/output behavior, stack size, ingredients, spawnability, and create-from-nothing flag.Factory content includes resources such as iron ore, copper ore, coal, and stone; products such as iron bars, copper bars, building materials, motors, circuits, and frames; and spawnables such as storage warehouse, coal plant, factory, and mining drill.
Interpretation: content should probably move to data files eventually: RON, TOML, YAML, JSON, or another serde-friendly format if rewritten in Rust.
Resource system
ResourcesComponentCoreis substantial and should be treated as one of the first core systems to port or preserve.It models:
Relevant lines: resource fields and reserved-capacity comments. Resource creation capacity behavior. Give-resource transfer behavior. Retrieve-resource behavior.
Interpretation: this wants typed
Result<T, ResourceError>semantics in Rust rather than exception-driven partial operations.Potential Rust error model:
Dispatch / logistics system
The dispatch system is probably the conceptual heart of the game.
DispatchComponentCoredefines a small logistics grammar:These verbs and keywords are explicit in the code.
The dispatcher:
Important target/receiver matching behavior appears here.
Interpretation: the interesting game is not belts and inserters. It is a distributed job-assignment protocol among autonomous world objects. Preserve this design axis.
Production system
ProductionComponentCorehas product, quantity, requests/intermediates, current craft progress, power usage, reserved-capacity setup, inserter resource assignment, and tick-based crafting. It consumes inputs, uses battery, advances craft progress, and force-creates product output when a craft completes.Interpretation: production is already deterministic/tick-based and should port cleanly.
Movement / pathfinding
MovementComponentCorekeeps a path and path index, checks target position from dispatch receiver state, computes distance, recalculates path when needed, and queues movement through the controller.Interpretation: movement should be extracted behind a pathfinding interface. Do not bind the simulation to Unity map/grid types.
Known sharp issues
1. Core still leaks Unity
IGameControllerexposes Unity-adjacent or host concerns such asSpriteMapComponent Map, logger,ActivitySource,WorldObjectTickActivity, and mutation queue methods.Recommendation: split this interface into smaller simulation services:
In Rust, this might become explicit resources passed into systems, or plain services owned by
GameState.2. Tests are promising but brittle
tests.csprojis clearly intentional, but it depends on absolute Unity install paths.Recommendation: remove Unity dependencies from the core sim. If Unity references are unavoidable for now, use documented local configuration rather than hardcoded paths.
3. Credential-shaped OTEL/Honeycomb value is committed
GameControllerCorecontains static OpenTelemetry/Honeycomb configuration including an auth-header-shaped value. Logging setup sends OTLP logs with that header.Recommendation: rotate/delete any exposed token, even if archived/revived status changed. Move telemetry config to environment variables or local config.
4. Hand-rolled component bag wants ECS or typed tables
WorldObjectCorecurrently has many optional component fields.Recommendation: if staying in C#, consider Arch/Flecs.NET/DefaultECS or a plain data-table system. If moving to Rust, consider Bevy ECS later, but start with a pure Rust sim crate first.
Recommended next step
Do not immediately port the entire game.
Port or rebuild the smallest closed loop:
Desired CLI target:
Desired output shape:
This converts the project from “Unity game prototype” into “simulation lab with a possible game frontend.”
Recommended Rust stack
Use Rust first, Bevy later.
Suggested crates / layers:
Important product/design interpretation
The most promising direction is not “make Factorio again.” It is:
The existing dispatch system already points in this direction. Treat that as the seed crystal.
Suggested immediate agent task
First agent task should be an architecture extraction pass, not feature work:
Coreclasses and their Unity dependencies.GameContent.Item,ResourcesComponentCore, and a tinyGameState.Avoid starting with Unity editor cleanup or Bevy visualization. That will recreate engine gravity before the sim kernel exists.