Jump to content

Unity.Rea.Chain/BIBLE

From MindAttic Docs

Unity.Rea.Chain: Project Bible

The single source of truth for what Unity.Rea.Chain is, the rules that keep the rebuild faithful, how the code is organised, and every place it does not play exactly like the original, with the reason. README.md says how to build and run it; RECONSTRUCTION.md is the full reverse engineering of the original and the build order to parity; chain-physics.md is the spring algorithm and its tuning.

Every behaviour of the original is on main, fixed or recorded here (U.CHN-T63, RECONSTRUCTION §8); V4 and V12 are settled (U.CHN-T76). Nothing is claimed as built that is not.

1. The one sentence

A mouse-steered angel flies an endless arena swinging a spiked mace on a spring chain, knocking down, grappling and throwing a flock of enemies that home in on it, rebuilt from the 2005 VB.NET / DirectX 9 Chain Game (itself a port of Philip Winston's 2000 Elastic Trail script) as a modern Unity 6 game.

2. The product promise

  • The chain is the game. Every link is a Hookean spring with drag and gravity, so the mace lags, swings and whips; circling the mouse winds it up like a flail, and the overhead boost keeps it from drooping when swung high.
  • Hit, grab, throw. A mace hit knocks an enemy back by the mace's velocity over its mass and scores the damage x 1000. Hold the button and the mace grabs instead; release and the enemy flies off at the mace's velocity, bowling over any enemy it touches.
  • One arena, one loop. 14 enemies seek the angel, 30 HP drains one touch at a time, one heart drifts down for +10, and at zero the light fades and the round resets itself.
  • Every knob of the original. The [ ] chain length, the live spring, drag and gravity keys, gem link skins, backgrounds, lighting, screen shake, debug views and the script console all come across (all on main, see RECONSTRUCTION §6).

3. What it is not

  • Not a redesign. No new modes, levels, enemies or progression. The scope is the original, played as it was meant to play (see §4 rule 1), and the repo is finished when the last reconstruction story is.
  • Not a line-by-line port. The code is rebuilt from scratch to current Unity practice; only the behaviour is kept.
  • Not frame-rate dependent. The original's per-frame numbers are converted to a fixed step.

4. Design rules

The owner's rebuild standard is in AGENTS.md; these are its rules as they apply here.

Gameplay matches the original; broken things are fixed

Every value, unit and behaviour comes from the original source (R:\...\Chain Game\), never from a guess. Where the original is plainly broken (a random that is not random, a draw call commented out, a feature that can never be reached, sound that ships switched off) the rebuild plays the way the game was clearly meant to, and the fix is a row in §7 Fixed defects. Everything that works matches exactly. Anything else that differs is a row in §8 Deliberate deviations with its reason. A difference with no row is a bug.

Reverse-engineer before rebuilding

A module is read in full and recorded in RECONSTRUCTION.md before its rebuild starts.

Core is pure C#

The rules live in an engine-free Core assembly ( oEngineReferences, no UnityEngine) tested with dotnet test`. State changes only through commands, which produce events; presentation reads state and plays events and never mutates the game.

Hard assembly boundaries

Core, Runtime, Editor and Tests are separate asmdefs with one-way references (see §5).

Content and tuning are data

Every tuning number lives in a data file or the settings registry and is validated on load (see §6).

Built in code

The scene, UI and objects are composed in code (SceneBuilder, PlayerBuilder), never wired by hand in the Inspector. Regenerate Main.unity rather than editing it.

Modern Unity only

Unity 6, URP behind a pipeline-agnostic layer, the Input System through an action asset, UI Toolkit or the shared MindAttic components, Unity.Shared profiles and settings, and multiplayer-ready seams: commands carry a player id, one authority holds the state, no global current-player singleton, built on the Unity.Multiplayer kit.

Done means seen working

Core tests green, a build that launches, and the feature seen in play (a screenshot or a scripted run) before a ticket closes.

5. Architecture

5.1 Target

 Unity 6000.4.3f1 · Assets/Scenes/Splash.unity (the loading picture) then Main.unity, both generated by SceneBuilder
 ┌────────────────────────────────────────────────────────────────────────────────────┐
 │ Unity.Rea.Chain.Runtime  (MonoBehaviours, presentation, input, audio, HUD)              │
 │   reads Core state, plays Core events, turns input into Core commands               │
 └──────────────▲───────────────────────────────────────┬─────────────────────────────┘
                │ events / state                         │ commands (with player id)
 ┌──────────────┴───────────────────────────────────────▼─────────────────────────────┐
 │ Unity.Rea.Chain.Core  (noEngineReferences)                                              │
 │   ChainSimulation, AngelFlight, EnemyBrain, flocking, heart, GameState, clock,      │
 │   script language, settings registry, data loading and validation                   │
 └────────────────────────────────────────────────────────────────────────────────────┘
 Unity.Rea.Chain.Online  → Runtime, Core, Unity.Multiplayer (+ .UI)   (ChainPlayer, ChainWorldSync, ChainOnline, ChainBot)
 Unity.Rea.Chain.Editor  → Online, Runtime, Core, Unity.Multiplayer.Editor   (SceneBuilder, OnlineBuilder, PlayerBuilder)
 Tests/Core.Tests    → Core            (NUnit, dotnet test, outside Unity)
 Unity.Rea.Chain.EditMode/PlayMode.Tests → Runtime, Core (Unity Test Framework, adapters and the scene)

References only point down: Runtime → Core, Editor → Runtime/Core, tests → what they test. Core references nothing Unity.

5.2 Where it is today

Assembly Folder Contents Status
Unity.Rea.Chain.Runtime Assets/Unity.Rea.Chain/Runtime/ Presentation and input: UI/GameSession (the one authority: holds and steps the GameWorld, seats players, takes their commands, raises the world's events), Input/ChainControls (the one InputActionAsset, built in code: keyboard, mouse and gamepad bindings), Input/SeatInput (a seat's actions as its commands), Player/AngelController (the steer and pause as commands; draws the angel), Chain/ (ChainController draws the chain, MaceController sends the [/] commands and draws the mace), Grapple/GrappleController (the grapple button as commands), Enemies/ (Enemy views, EnemySpawner making them from events), Items/ (HeartPickup), Lighting/ (SceneLight), Level/ (LevelBounds, CameraRig), UI/ (GameHud, HudText, ConfigScreen, ScripterConsole: Form1.vb's scripter on the HUD, setting the session's InputGate), Audio/ (ChainAudio plays the world's events), Adapters/CoreConvert (the one place Vector2/Rect become Core's Vec2/Rect2), Settings/SettingsStore (loads the registry from StreamingAssets) References Core one way; holds no rule that Core could own, and changes the world only by commands
Unity.Rea.Chain.Online Assets/Unity.Rea.Chain/Online/ Online play on the Unity.Multiplayer kit (U.CHN-T26, §5.4): ChainPlayer (the Player Prefab's NetEntity carrying its seat; the seat's commands to the authority), ChainWorldSync (the authority's WorldSnapshots to every peer, keyed chain:world), ChainOnline (the kit's front end beside local play), ChainAuthority (which GameSession a peer's game is), ChainBot (the [NetBotDriver]) in place: the seats, commands and snapshots, and a client drawing them (U.CHN-T73)
Unity.Rea.Chain.Online.Tests Assets/Unity.Rea.Chain/Tests/Online/ PlayMode tests on the kit's NetSessionTest and NetBotTest in place
Unity.Rea.Chain.Editor Assets/Unity.Rea.Chain/Editor/ OnlineBuilder (the network prefabs and their list, the kit's Add Front End on Main, ChainOnline), SceneBuilder (generates Splash.unity, Main.unity and the build settings, Splash first), RenderPipelineBuilder (the URP 2D pipeline asset and renderer, assigned in GraphicsSettings and every quality level), PlayerBuilder (Windows player) in place
Unity.Rea.Chain.EditMode.Tests Assets/Unity.Rea.Chain/Tests/EditMode/ NUnit tests of the rules and components in place; the component tests stay here, the pure rule tests now live in Tests/Core.Tests (dotnet test)
Unity.Rea.Chain.PlayMode.Tests Assets/Unity.Rea.Chain/Tests/PlayMode/ MainSceneSmokeTests in place
Unity.Rea.Chain.Core Assets/Unity.Rea.Chain/Core/
oEngineReferences: World/(GameWorld, GameCommand, GameEvent, PlayerId, EnemyId, PlayerEntity, EnemyEntity, Sweep),Maths/(Vec2, Rect2, Calc),Chain/(ChainSimulation, ChainFollow),Player/(AngelFlight),Enemies/(EnemyBrain),Grapple/(Grapple, IGrappleTarget, GrappleState),Items/(HeartFloat),Game/(GameState),Level/(CameraFraming, PlayArea, ScreenShake),Lighting/(LightingState),Script/(ScriptLine, ScriptRunner, ScriptEffect: Script.vb's language; Scripter, the console's key handling; ScriptEffects, putting a script's effects into the camera and the light),Input/(SteerInput: the stick as mouse counts, the J toggle; InputGate, what the scripter holds back),Audio/(SwingSoundTrigger, ClipPicker),Settings/` (GameSettings, the registry and its data records; OriginalSpace, the one mapping; ISettingsSource and TuningOverrideSource; SettingsReader, the validation; Json; PlayerPreferences and IPreferencesStore, the player's own options) Its rules are tested by Tests/Core.Tests with dotnet test

The URP 2D pipeline is committed (Assets/Unity.Rea.Chain/Rendering, built by Editor/RenderPipelineBuilder, UNI-T18); the player's own options are a Unity.Shared profile (UNI-T36, §6); the UI Toolkit HUD in UNI-T37 and the multiplayer kit in U.CHN-T26 (§5.4).

5.3 Commands, events and the one authority

The whole game is one GameWorld (Core): the session rules (GameState), every seated player (PlayerEntity: their AngelFlight, ChainSimulation, mace link and Grapple) and every enemy (EnemyEntity: an id, its EnemyBrain, its position and radius). One authority holds it, GameSession, and nothing else changes it:

  • Commands in. A player's input becomes a GameCommand carrying that player's PlayerId: SteerAngel (mouse delta, applied on arrival so steering is as smooth as the display), ArmGrapple, ReleaseGrapple, ChangeChainLength, ToggleFollow (the F key), SkinLinks (the U key), ToggleMaceMode (the M debug key), TuneChain (the live-tuning keys), ChangeGameSpeed (Minus/Equals, held), Pause, TogglePause, ResetGame. GameSession.Submit hands it to GameWorld.Submit. Commands are plain immutable data, so a networked player's NetEntity can carry them to the authority unchanged.
  • One step. GameSession.FixedUpdate is the only caller of GameWorld.Step: chains swing from their angels' hands, enemies seek the nearest angel, flock and (thrown) knock each other, grapples arm, catch, carry and throw, each mace hits what its swept circle touched, enemies touching an angel cost HP, and a finished game fades and resets itself. Every step runs at the world's GameSpeed (V20): it plays that many fixed steps' worth of game time, in sub-steps no longer than one fixed step (TimeScale). Contacts are circle tests in Core (Sweep, EnemyEntity.Overlaps), not Physics2D queries, so all of it runs and is tested under dotnet test. The world holds the hearts too (GameWorld.AddHeart, a HeartFloat each): it moves them, checks them against the angels (CheckHearts, CollectHeart) and resets them; HeartPickup only draws one.
  • Events out. Everything that happens is a GameEvent, in order: EnemySpawned, EnemyRemoved, EnemyHit, EnemyKnocked, EnemyKilled, GrappleChanged, Grabbed, Thrown, ChainLengthChanged, FollowChanged, LinksSkinned, MaceModeChanged, ChainTuned, GameSpeedChanged, AngelHurt, AngelHealed, PauseChanged, GameOver, WorldReset. GameSession.EventRaised passes them on after each command and step; EnemySpawner makes and kills enemy views from them, ChainAudio plays its player's hits, catches and throws, and the session freezes time on PauseChanged.
  • No current player. Each seat is a PlayerId; GameSession.Join seats an angel and its chain, and each of those components holds its own id. Nothing looks up "the" player. Two seats already play side by side in the world (each with its own angel, chain and grapple; a hit is credited to the mace that landed it).
  • Tuning is data (§6): the authority seats each player from the settings registry (GameSession.Settings, loaded from StreamingAssets/Settings), and a component can only override a figure at run time (live tuning, tests), which goes to the world through GameSession.Retune.

While paused the camera shows only the backdrop's layer (AreaBackdrop.Layer, "Backdrop"): oneFrameRender draws only renderCube, renderBackground and the banner then, so the play field disappears until the game resumes (CameraRig.ApplyPauseView, U.CHN-T78).

Where the world departs from the earlier component wiring: pausing now freezes the angel too (Engine.vb renders and moves the angel only while not paused; the port had kept flying it), and a finished game resets the world in place instead of reloading the scene (V15).

5.4 Online: the Unity.Multiplayer kit (U.CHN-T26)

The game is built on the shared kit (Unity.Multiplayer, MindAttic Components for its menus, Unity.Shared for the player's name and colour; Packages/manifest.json, NGO under testables, MINDATTIC_NGO_TESTABLE committed in ProjectSettings.asset). Its one rule is the game's own (§5.3): one authority holds the state, players send what they want to happen.

  • Local play is unchanged. Main opens straight into play as before; the NetworkManager's NetBootstrap never starts a session by itself (autoStart off, serveWhenHeadless off, so batch-mode runs play locally), the kit's menus stay hidden, GameSession applies its own commands and Escape quits (V8).
  • The front end beside it. O (V26) opens the kit's NetFrontEnd: Host, Join by IP, Join by code, Settings (the player's name and colour), Play alone (back to local play) and Quit. Host shows the lobby with the join code (or the LAN address when no code service is set up) and the roster; Start begins. While a session runs, Escape opens the kit's in-game menu (Resume, Invite, Settings, Leave or End game) instead of quitting (GameSession.HoldsQuit). While a menu is open the game's input is held back (InputGate.SetMenuOpen), the cursor is free, and on the main menu outside a session the local game is paused, as behind the config screen (V21).
  • Players carry their seat. Every connection gets a ChainPlayer (NetEntity, the Player Prefab). The server gives it the connection's seat from the roster ([Synced] Seat, stable across a reconnect), and the seat is its PlayerId: the host's own seat is the scene's angel; any other seat the authority adds to its world (GameSession.AddRemotePlayer, tuned as its own angel) and takes out when the player is gone (RemoveRemotePlayer). A dedicated server (-mode server) seats its first player on the scene's angel.
  • Commands into the server. On a client, ChainPlayer sets its screen's GameSession.Forward: every command the input readers make (the same SeatInput, AngelController, grapple, mace and HUD code as local play) goes to the server as CommandCodec bytes ([ToServer] Send) instead of changing the client's world, which is no longer stepped. The server decodes them as the sender's seat, whatever id the bytes name, refuses anything malformed, and submits them to its GameSession. QuitGame is never sent.
  • State back for presentation. The server writes each seat's angel and mace to ChainPlayer ([Synced]), drawn as a marker in the player's roster colour where the peer has no angel of its own for that seat, and ChainWorldSync (spawned by key, chain:world, when a server's session starts) sends the whole world 20 times a second as a Core WorldSnapshot (HP, score, pause, game over, every seat's angel, chain and mace, the enemies and the hearts, plus the round clock and each enemy's radius since wire version 2), which every peer keeps as Latest.
  • A client draws the authority's game (U.CHN-T73). Every frame the owning client's ChainPlayer hands Latest to its screen's GameSession.ShowAuthority with its seat (Shown, ShownSeat; dropped the moment the screen stops forwarding). The views then read it in place of the frozen local world: the angel, chain and mace draw that seat's entry (position, facing, flap frame, the links hand to mace, the mace link, skin and armed grapple), the EnemySpawner keeps one view per snapshot enemy and hides the local flock, each heart draws the authority's heart at its own place in the world's list, and the HUD, the light and the camera show its HP, score, clock, game speed, pause, game over and fade. Every other seat is drawn by its ChainPlayer marker: the angel sprite in the roster colour with its chain line and mace (from the authority's world on the host, from Latest on a client). Not carried, so not drawn from the snapshot: the gem link skins (hidden over the shown chain), the live-tuning readout and the grappled enemy's HP (both the screen's own), and the sounds (played from local events). Snapshots are drawn as they arrive, 20 a second, with no interpolation between them.
  • Bots and tests. ChainBot is the game's [NetBotDriver] (-bot A): it waits for its seat, steers and swings with the same commands, and passes once the authority has moved its angel. Tests/Online runs on the kit's NetSessionTest (a host and a client: seats, forwarding as the sender's seat, refused bytes, snapshots, leaving) and NetBotTest (a dedicated server and two bots joining by code). The wire formats are dotnet tested (NetWireTests).

6. Data files

The original had none. Its Jet .mdb databases are commented out and loadTerrain reads an unset DataRow; every number is a field in code. The only persisted data is the registry (HKCU\Software\MindAttic\Engine read, ...\War written) with Width, Height, ColorDepth and Fullscreen.

The rebuild (UNI-T33) keeps every tuning figure in JSON files in Assets/StreamingAssets/Settings/, one per concern, read by Core's settings registry (Core/Settings/GameSettings) through an interface (ISettingsSource; the build reads the folder with DirectorySettingsSource, Runtime's SettingsStore holds the loaded registry). Nothing tunes the game from the Inspector any more.

  • The files hold the original's figures in its own units, named as its source names them (segLength, springK, Ratio3D, seekSpd, floatSPD, ...): screen space, where -0.5..0.5 is the screen height, and per frame. A figure the original never had (a circle radius where it tested rectangles, the camera rig, the swing whoosh) sits in that file's port object, in world units and seconds, and is never mapped. Keys starting with _ are notes.
  • One mapping turns them into the port's: space.json (lengthScale, framesPerSecond) read into OriginalSpace, which GameSettings.Map applies to each figure by kind (length, speed, acceleration, rate, frames). It is the only place a figure changes units. lengthScale is 9 (UNI-T66): the original's screen height (1.0) is the 9 world-unit height of the 16 x 9 arena, so every position, size, speed and acceleration is the same fraction of the screen as in the original. The original ran 4:3 (Camera.vb, 640 x 480); x uses the same scale, so the wider arena is simply more room at the sides. Port-only figures (radii, hand offset) were re-checked against the scaled rectangles: hit 0.3, catch 0.35, enemy 0.3, angel contact 0.4, hand (0.3, 0).
  • Validated on load: every key must be present, of its type and in range, unknown keys are reported (a typo is not silently ignored), and cross-checks hold (Mace within maceMin..maceMax, seekCap no more than the enemies, hangBackFar beyond hangBackNear). One load reports every problem, each with its file, key and line (SettingsException); the game logs them and does not start on bad data. Tests/Core.Tests/GameSettingsTests loads the shipped files.
File Holds Original source
space.json the original-to-port mapping (length scale, frame rate) (the port; D9)
chain.json maxLinks, segLength, springK, resistance, gravity, stopVel/stopAcc, overhead boost and linkSize, link mass, Mace and its 1-12 range, followMouse and the 3.5x mace scale (UNI-T47); skins: Textures.vb's link pictures by name and file, the plain link and Form1.vb's U gems by link index (UNI-T41, V25); maceSkins: the mace's starting skin (mode, Chain.vb's theMaceMode) and each skin's picture (UNI-T43, D4); tuning: the live-tuning keys' steps (Form1.vb's 0.001, 0.00001, 0.001) and the port's limits, in the file's own units (UNI-T51, V19); port: wall bounce, hit, catch and throw, damage per speed Chain.vb, Form1.vb
angel.json Ratio3D, hoverMax/hoverRate, flapRate and frames, maxHP, hurtDelay, angelSize and its hit rectangle, angelOffset (where the quad is drawn) and linkOffsetX (where the hand hangs, U.CHN-T93), checkBounds' boundsX (-0.6..0.5) and boundsY (-0.6..0.4), U.CHN-T86; port: arenaBounds (off: the arena inset by the bounds margin is an option only), bounds margin, contact radius Angel.vb
enemies.json maxEnemy, seekSpd, resistSPD, flockSpd, mass range, load and reset HP, Cautious's 6 x seekSpd, enemySize (the 0.3 quad an enemy is drawn on, U.CHN-T93); port: radius, the Seek cap (14, every enemy, D18) and the hang-back band hangBackNear/hangBackFar (screen units, mapped; D18) Enemy.vb, Root.vb
item.json the heart's size, fall, sway (floatSPD, floatAcc, floatMaxSPD), start, wrap, heal and hit rectangle Item.vb
game.json score per damage, HP per contact, the gameSpeed every round starts at (1.0), gameSpeedStep: Minus/Equals' 0.01 a held frame (UNI-T52, V20) Engine.vb, Root.vb, Input.vb
lighting.json day length (the original's 1e10 s, D6; 1440 s is the option), tint step Lights.vb
camera.json Fov (pi / 4), aspect (4 / 3), camZ (-1), the debug camera's steps a held frame: camSPD (0.012, numpad plus/Enter and 4/6), moveStep (0.02, numpad 8/2), isometricStep (0.25, X/Z) (UNI-T57); shakeAmount (the 0 key's 0.02, UNI-T49); port: the rig's mode (Original, Camera.vb's own view, U.CHN-T86; FitLevel and Follow options), padding, follow size, dead zone, sharpness, and minDistance (0.012, the debug eye's nearest to the plane, D26) Camera.vb, Chain.vb, Form1.vb
audio.json musicVolume, sfxVolume, ambientVolume (hundredths of a dB), rndMusicPos; port: the swing whoosh Sound.vb
hud.json the original window (512x448), the status box (0, 0, 96x48), each HUD line's anchor, pixel position, Write colour [alpha, red, green, blue], font size (points) and weight (the round clock's clock at (300, 5) in yellow, UNI-T53), fpsSampleMs (100), drawFps (on); menu: Gui.vb's menu panel at (10, 10), 255x255, its lines' colour (255, 255, 255, 64), font and each line's spot (UNI-T55); zone: Zone.vb's hit box, bZone (on), loadZone's left/right/top/bottom (0, 0.05, 0, -0.05 screen units), the enemy and mace corners renderZone moves it to, texZone's colour (0, 128, 255), port: the line width (UNI-T56); port: the pause dim, the game-over banner, the text shadow (UNI-T50), all off by default as the original draws none of them (U.CHN-T79) Gui.vb, Engine.vb, Root.vb
area.json Background.vb's quad: bgWidth (1.2) from its left edge, bgHeight (0.415) above and below, bgOffset (-0.56, 0); texBackground (beach, Textures.vb's start), keyB (beach) and keyN (utopia), Form1.vb's B and N; areas: every gfx/area picture by name, the five unused ones too; cube: Cube.vb's 67 x 55 size, 38 depth and brick.jpg (UNI-T40, V24) Background.vb, Textures.vb, Cube.vb, Form1.vb
input.json bJoystick, the joystick's joyRange (1000) and joyOutsideDeadZone (250); port: stickSpeed, the mouse counts a second a full stick steers by (D14) Input.vb

Still in code, by design: the game-over fade step and floor (GameState), the audio clip list (ChainAudio, UNI-T20) and the arena size (LevelBounds, UNI-T66).

Player options live in the player's profile (UNI-T36): the shared MindAttic profile's settings.json (the Unity.Shared package, Profiles.Current.Settings), read and written through Core's IPreferencesStore (Runtime's ProfilePreferencesStore; PlayerProfile holds the loaded PlayerPreferences, PlayerProfile.Save() keeps them). Its common block holds the music and sound-effect volume and mute and reduce motion, shared with every MindAttic game; Chain's game block holds resolution ({"width", "height"}), windowMode (windowed, borderless, fullscreen, maximized, put into effect before the first scene in a build by DisplayPreferences) and tuning, keys per data file laid over the stock files by TuningOverrideSource ({"chain.json": {"springK": 0.3}}) and validated like them; overrides that fail are logged and the stock figures used. MusicPlayer and ChainAudio play at the profile's volumes and mutes and have none of their own. The original's volumes (audio.json: music 0 dB, sound effects -10 dB) are the stock ones: a profile this game has not given them to (game.stockVolumes unset) takes them in place of the shared package's defaults, and the profile's own figures win from then on. The options screen is frmConfig.vb's (UNI-T59): F12 and the menu's "F12 - Configure Video" open ConfigScreen (a UI Toolkit panel the HUD builds in code over a Core ConfigForm, laid out from hud.json's config), whose Submit writes the window mode, resolution, music and sound-effect volumes into the profile and Chain's own game.ambientVolume (the shared block has no ambient volume; nothing plays on it yet, as nothing did in the original; audio.json's -1500 is its stock figure).

7. Fixed defects

Places where the original's code is plainly broken. The rebuild plays the way the game was clearly meant to. Status: fixed (on main) or settled; none is still planned (U.CHN-T63).

# Defect in the original Where What the rebuild does Status
D1 Enemies spawn only at the four corners: getRndNum(-1, 1) returns the integers -1, 0, 1 and 0 is rejected, so every "random" spawn is (+/-1, +/-1) and all 14 start stacked Enemy.vb loadEnemy, Root.getRndNum spawns each enemy at a real random point in the arena (GameWorld.RandomPositions), on the first wave and on every Reset (R or game over), which runs the same loadEnemy loop fixed (UNI-T48 settles the reset path); with the integers fixed the draw is still X and Y each from -1..1 minus the gap -0.5..0.05, so every enemy starts in -1..-0.5 or 0.05..1 on both axes (mostly beyond the screen), and the rebuild spawns in that range (enemies.json spawnMin/spawnMax/spawnGapMin/spawnGapMax x lengthScale 9, X plus half the quad as it is the quad's left edge; GameWorld.SpawnRange), not anywhere in the 16x9 arena (U.CHN-T87)
D2 The game is silent: bSound and bMusic default to False and playSFX is never called, though every clip is loaded Sound.vb sound and music on by default; swing, hit and death play their clip sets (ChainAudio), music loops (MusicPlayer) fixed (UNI-T20: the clips are imported and assigned)
D3 No HUD text is drawn: Root.Write has its DrawText commented out, so HP, score, grappled HP, readouts, clock and FPS never appear (earlier backups drew them) Root.vb Write draws the HUD (GameHud, UI Toolkit) where and in the colours the backups' Write calls put it, from hud.json fixed (UNI-T37, UNI-T50, UNI-T53)
D4 The magnet mace can never be reached: Chain.vb declares theMaceMode (SpikeBall, Magnet) and maceMode = SpikeBall, but no line of the original reads or sets maceMode, no key or menu selects it, and Textures.vb never even loads magnet.PNG (it loads only mace as texMace and mace2 as texMaceGrapple; the picture only ships, as Chain.vbproj Content), so the original had no way at all to show the magnet Chain.vb, Textures.vb the magnet is a mace skin: MaceMode (Core) on each player (PlayerEntity.MaceMode), starting in chain.json's maceSkins.mode (SpikeBall, the original's default; Magnet starts on the magnet), and the Player map's ToggleMaceMode (M, a debug key the rebuild adds) sends ToggleMaceMode -> MaceModeChanged, spike ball to magnet and back, paused too; no reset or retune changes it. MaceController swaps the mace visual's picture (maceSkins.files: mace.png, magnet.png, 32 x 32 at the same 3.5x); nothing in the rules reads the mode, so the hit, catch and throw are identical fixed (UNI-T43)
D5 A throw is overwritten the frame it starts: checkThrowImpact loops over every enemy, the thrown one included, and rectIntersect of a rectangle with itself is true, so the released enemy divides its own velocity by its mass and turns Hurt that same frame and every frame until the next press: it stops within a few frames and stays stunned (immune to the mace, never seeking), stunning whatever touches it. Skipping only the self-hit leaves the written Thrown state with no drag and no end state, so the enemy would leave the arena for good Engine.vb checkThrowImpact, Input.vb getMouse, Enemy.vb renderEnemy the thrown enemy does not hit itself; it goes Hurt at the mace's velocity, knocks the enemies it touches while it flies, decelerates like a knocked one, then seeks again (EnemyBrain.Throw, HurtDeceleration/RecoverSpeed both enemies.json's own resistSPD, the rate A_near_B decelerated at) fixed (rate confirmed against resistSPD, U.CHN-T45; the self-hit recorded, U.CHN-T89)
D6 The day cycle never advances: dayLength is 1e10 s, so Day, Dusk, Night and Morning never change in play Lights.vb the original's 1e10 s day is the default (lighting.json dayLength, LightingState.Settings.Default): the scene stays in Day all session, and only a script (RUN NIGHT, CHANGE TIME DAYPERIOD) moves the period on, whose Dusk, Night and Morning tints walk 1 unit a frame as Lights.vb's do. UNI-T46's 24-minute day (LightingState.Settings.TwentyFourMinuteDay, dayLength 1440: Day 8 min, a red Dusk 4, a blue Night 8, Morning 4, timed on lit play) is a data option only (set lighting.json dayLength to 1440 to play it) settled (U.CHN-T82): the huge day length reads as a deliberate setting, not a defect, so the original's still day is kept. Spike U.CHN-T91 judged the 1440 s day against it and it plays worse: the tint walks each period's colour in 4.25 s and then holds it, so the scene is a bare red for ~236 s of Dusk and a bare blue for ~476 s of Night, about half of lit play in one colour channel; under the red Dusk the zone overlay's 0, 128, 255 lights black, and under the blue Night the red-and-green sprites go dark, which costs the read of enemies, items and hit zones the game is played on, and it buys no rule (no period changes spawns, scoring or the chain). It stays a data option, never the default unless the owner says otherwise (LightingStateTests.Spike_TwentyFourMinuteDay_LightsHalfOfPlayInASingleChannel)
D7 The chain is pulled from one side: the port turned the JS original's two Ifs into If / ElseIf, so only the previous link's spring ever fires Chain.vb renderChain a data setting (ChainSimulation.Settings.PullBothNeighbors, chain.json's port.pullBothNeighbors): false by default, matching Chain.vb's own If/ElseIf (l only ever runs 1..maxLinks, so the If always takes the first branch and the ElseIf is dead code, so the port's own chain was pulled from the previous link only); true pulls both neighbours as Elastic Trail did (ChainSimulation), kept only where asked for explicitly settled as a data default (U.CHN-T45): the original's own behaviour is the default
D8 The mace drifts: link(Mace).X/Y += maceOffset is added every frame, cumulatively, instead of once as a sprite offset; a stray link(1).Y -= 0.0004 "fix" does the same Chain.vb renderChain two data settings (ChainSimulation.Settings.MaceOffsetPerSecond and Link1DropPerSecond, chain.json's own maceOffset and link1DropPerFrame, mapped to world units a second): zero by default (the offset is render-only, no fudge term); chain.json maps the original's own figures onto them so the shipped game carries both drifts, as the original does. The stray line re-runs once per drawn link up to the mace in the original (so as shipped it drops link 1 by 0.0004 x (Mace + 1) a frame); ChainSimulation.Step reproduces that literally too, applying the figure ActiveLinkCount times a step settled as a data default (U.CHN-T45): the shipped game matches the original; a zero figure (or Settings.Default) is the fudge-free alternative
D9 Speed depends on the machine: every number is per frame with no time step and no frame cap Form1 loop, all modules a fixed step; per-frame figures converted at 60 fps (OriginalSpace, space.json's framesPerSecond). GameWorld.Settings.PhysicsStepRate (60 by default, from the same figure) feeds GameWorld.Step's own fixed-step accumulator: it banks real time (x GameSpeed) and runs as many whole 1 / PhysicsStepRate-second sub-steps as that has filled, carrying any leftover to the next call, so the chain's discrete per-frame integration keeps the original's feel at any host frame rate -- including ones that are not an exact multiple of it (144, 90, 50 Hz, ...), not only at exactly 60 fps fixed (U.CHN-T45 replaced a per-call rounding of sub-step count, wrong off an exact multiple, with a true accumulator)
D10 Off-by-one HP: the HUD draws HP + 1 bars and the game ends below zero, so 30 HP takes 31 hits Engine.vb renderDisplay, GameOver a data setting (GameState.Settings.HpOvershoot): 1 by default, matching the original exactly (the HUD shows Hp + 1 bars, HudText.Hp's bonus; game over once Hp < 1 - HpOvershoot, i.e. below zero); 0 draws exactly Hp bars and ends the game at 0, kept only where asked for explicitly settled as a data default (U.CHN-T45): the original's own behaviour is the default
D11 Some swings do no damage: damage is abs(dX + dY/2), which cancels to zero on certain diagonals Engine.vb checkMaceImpact a data setting (EnemyBrain.MaceDamageFormula, chain.json's port): Original by default, the original's own abs(dX + dY/2) of the mass-divided impact velocity (PlayerSetup.VelocityToOriginalScale, OriginalSpace.ToOriginalSpeed, converts the world-units-a-second velocity back to the formula's own per-frame screen-space units), cancelling to zero on the same diagonals the original did; SpeedTimesFactor is damage from mace speed x DamagePerSpeed (GameWorld, EnemyBrain.Hit), kept only where asked for explicitly settled as a data default (U.CHN-T45): the original's own behaviour is the default
D12 Fast swings pass through enemies: one AABB at the mace link per frame Engine.vb checkMaceImpact rectMace swept along the move from the last position to this one (Sweep.RectCast, sampled at a quarter of the smaller rectangle side), tested against Enemy.vb's rectangle with rectIntersect; the swept circle (hitRadius) is the earlier choice, kept only as a data option (chain.json port.hitShape Circle) fixed (circle by default until U.CHN-T88, which restored the rectangle and swept it)
D13 Game speed does nothing: Minus/Equals change gameSpeed and the HUD shows it, but it is never applied Engine.vb renderDisplay, Input.vb getKeyboard game speed is the world's time scale: Minus and Equals move it 0.01 a held frame (game.json's gameSpeedStep), never below 0, the HUD shows it with two decimals, and every step runs at it (V20) fixed (UNI-T52)
D14 The joystick binds nothing: getJoystick acquires and polls the stick, sets every axis to -1000..1000, tests it against joyOutsideDeadZone 250 and reads every button, and every branch is empty, so a plugged-in joystick does nothing (and Form1.vb's J flips a joystickToggle nothing reads) Input.vb getJoystick, Form1.OnKeyDown a gamepad drives the same actions as the keyboard and mouse: its left stick steers like the mouse delta (past the original's 250-in-1000 dead zone, at input.json's stickSpeed mouse counts a second, so Ratio3D turns it into distance as it does the mouse), right trigger or A grapples, the shoulders change the chain, Y follows, Start pauses, Back resets; J switches the stick off and on, starting on as bJoystick does (SteerInput, ChainControls, SeatInput) fixed (UNI-T34)
D15 The background toggle key is unreachable: a second Case Keys.B (bBackground = Not bBackground) sits below the first, which takes the key Form1.OnKeyDown B and N both reach their backgrounds (beach and utopia, area.json keyB/keyN, AreaBackdrop); the toggle is not ported: even reached it would flip bBackground, which nothing reads (renderBackground draws regardless), and B cannot both pick the beach and toggle settled, not ported (UNI-T40)
D16 The lighting toggle freezes instead of switching off: with bLighting false renderLight just stops updating the device, so the last ambient and tint stay on screen (and the game-over fade stops showing); and Reset has a stray b = True among its flags that snaps blue to 255 mid-cycle Lights.vb renderLight, Root.vb Reset L off shows the scene untinted, still dimmed by the game-over fade, with the cycle held where it is; a new round turns lighting back on and leaves the time of day running, as Reset otherwise does; the stray b = True is not ported (UNI-T48) fixed (UNI-T46)
D17 With F (followMouse) off the mace keeps an invisible hit box where it was: renderChain stops rebuilding rectMace, but checkMaceImpact still tests enemies against the stale rectangle, so enemies that wander into that spot are hit and caught by a mace that is somewhere else Chain.vb renderChain, Engine.vb checkMaceImpact with follow off the mace neither hits nor catches (ChainFollow.MaceHits); the springs go slack and the mace draws at link size, as in the original fixed (UNI-T47)
D18 Cautious and Align can never be reached: renderEnemy codes them, but loadEnemy, Reset and the Hurt recovery only ever set Seek; and Cautious, meant to hang back, negates getSlope's already-outward vector, so as written it would charge at 6 x seekSpd Enemy.vb loadEnemy, renderEnemy; Root.vb Reset, getSlope every enemy seeks, as the original: all 14 close on the angel together (enemies.json seekCap 14, the enemy count). UNI-T65's hang-back stays a data option only: a lower seekCap lets that many Seek while the rest wait in a band around their angel (Align stalks in at seekSpd on each axis to hangBackNear, Cautious backs off, its sign fixed, at 6 x seekSpd x distance / mass out to hangBackFar), the nearest waiting enemy taking a freed slot (EnemyBrain, GameWorld.AllocateSeekSlots). Spike U.CHN-T90 weighed it headlessly (Core GameWorld on the shipped data, seekCap 14 against 6, 4 and 2, 60 seeds each, scripted angels: still, slow orbit, kiting orbit, fast orbit, wide fast kite): it does not play better. The 0.25 s hurtDelay gates contact damage, so HP drains at one per 0.25 s whether one enemy touches or fourteen; thinning the pile-up (mean enemies within hangBackNear 10.1 to 4.4 for a still angel) saves no HP, and the band waiting at hangBackNear meets a moving angel sooner (first hurt 1.8 s to 1.5 s on the slow orbit) and kills it sooner (19.0 s to 13.4 s). Only the wide kite outlived it (died 58/60 to 34/60), by stalling the round: kills fell from 5.2 to 2.6 and mace hits from 1.6/s to 0.7/s; the fast orbit was even on survival with fewer kills (5.8 to 4.5) settled (U.CHN-T81): the original's all-seek rush is the default; nothing in the original selects the two states, so they are not wired in by default. U.CHN-T90 (bots, not a human playtest) keeps it so: the hang-back stays a data option, never the default unless the owner says so
D19 The shake key never shakes: shakeScreen(0.02) draws with getRndNum(0, 0.02), which is Random.Next(0, 1.02 + 1) narrowed to integers, Next(0, 1), so every draw is 0 and the look target never moves Root.vb shakeScreen, getRndNum; Form1.OnKeyDown each of the four draws is a real random 0..shakeAmount (0.02 of the screen, 0.18 u), two to the right and two down; every other press puts the view back, the first one first (shake starts False), and Reset recentres it but leaves the flag (ScreenShake, CameraRig.ShakeScreen, the Debug map's ShakeScreen on 0) fixed (UNI-T49)
D20 The frame rate reads double: renderFPS is called twice a frame (at the top of oneFrameRender and again at its end), so iCurrCnt counts every frame twice Engine.vb oneFrameRender, Gui.vb renderFPS each drawn frame counts once; every 100 ms of real time the count x 10 becomes the readout (FrameRateCounter, hud.json fpsSampleMs) fixed (UNI-T50)
D21 F4 cannot hide the frame rate: with bDrawFPS off renderFPS stops counting but still writes the last iFrameRate, so F4 freezes the readout instead of hiding it (the menu's own line reads "F4 - Hide FPS") Gui.vb renderFPS F4 hides it (and stops counting); a reset shows it again, as Reset's bDrawFPS = True does (GameHud.ToggleFps, the Debug map's ToggleFps) fixed (UNI-T50)
D22 The menu's F3 line is the wrong way round: IIf(bBackFaceCulling, "F3 - Enable Culling", "F3 - Disable Culling") offers to enable culling while it is on, where F1, F2 and F4 each name what their key does next; and, like the rest of the text, the menu's lines are never drawn (D3), only the menu.jpg panel Gui.vb renderMenu, Root.vb Write Tab shows menu.jpg with every line drawn; F3's reads "F3 - Disable Culling" while culling is on and "F3 - Enable Culling" while it is off (GameMenu.Line) fixed (UNI-T55)
D23 The hit box overlay never shows: Zone.vb's renderZone (E, bZone, on from the start) is never called, as oneFrameRender lists every other render call but not this one; and as written it would draw only maxZone + 1 = 6 boxes, so 9 of the 14 enemies would have none, and it moves box 0 to enemy 0 and then to the mace on every pass, so enemy 0 never gets one Zone.vb loadZone, renderZone; Engine.vb oneFrameRender drawn from the start and flipped by E: loadZone's 0.05 x 0.05 line strip (0.45 u) hanging from every enemy's centre and from each following mace's rectMace corner, in texZone's 0, 128, 255, lit by the scene's 2D light as the original's line strip took its ambient; with F off the mace hits nothing (D17), so it has no box; no reset touches bZone (HitZones, HitZoneOverlay, ViewOptions.Zones, hud.json zone, the Debug map's ToggleZones) fixed (UNI-T56)
D24 F2 never draws untextured: the useTextures setter is inverted and sets the fill mode, not the texture: turning textures off sets FillMode.Solid (no change, and it undoes F1's wireframe) and turning them back on sets FillMode.Point, so the second press leaves only dots; only renderCube reads bRenderTextures to drop its texture Root.vb useTextures, Cube.vb F2 off (the menu's "Use Shaded") draws every sprite, line and quad in its own colour without its texture, opaque, as the untextured cube is drawn; on draws textured; it never touches F1 (ViewRenderFeature, _Textured) fixed (UNI-T56)
D26 Numpad plus walks the eye through the plane it looks at: move_forward adds camSPD to cam.Z with no limit, so after 84 held frames the eye sits on its target (LookAtLH has no direction to look) and past it the camera turns round to face the scene's back, where the culling of D25 drops every sprite Camera.vb move_forward, initCamera the eye stops minDistance (0.012, one step) in front of the z 0 plane; numpad Enter backs it off again (DebugCamera.MoveForward, camera.json's port.minDistance) fixed (UNI-T57)
D25 F3 blanks the scene: every quad (setupVertex) is wound counter-clockwise as the left-handed camera sees it, which D3D treats as a back face, so the culling the key turns on (Cull.CounterClockwise) culls every sprite, link and panel, and the "off" state (Cull.Clockwise, which Form1.vb's Startup sets) is what culls the true back faces Root.vb backFaceCulling, setupVertex; Form1.vb Startup; Camera.vb LookAtLH F3 culls back faces: every sprite faces the camera and stays, a mirrored one (the angel flipped to face left) turns its back and drops out; off, nothing is culled, as the 2D renderer draws sprites (ViewRenderFeature, _Cull) fixed (UNI-T56)
D27 The settings form can never be opened: Gui.vb's menu labels F12 "F12 - Configure Video", but Form1.vb's F12 only sets toggleScreen (flip fullscreen, restart), and nothing ever shows frmConfig Form1.vb OnKeyDown, Startup; Gui.vb renderMenu; frmConfig.vb F12 and the menu's Video line open frmConfig's screen (ConfigScreen, GameHud.ToggleConfig), which holds the windowed/fullscreen switch among its settings (V21); its 16/32-bit Color Depth is not ported, as a Unity build has no colour depth to pick fixed (UNI-T59)
D28 frmConfig's Sound group does nothing: fraSound.Enabled = False, and its three scroll bars (Music, Sfx, Ambient Volume) have no handlers, so nothing reads or saves them frmConfig.vb the Music, Sfx and Ambient Volume sliders are live 0-1 gains, loaded from and submitted to the profile with the rest of the form: music and sound effects into the shared common block (played at once), ambient into Chain's game.ambientVolume (stock Sound.vb's -1500, nothing plays on it yet). Default leaves them alone, as btnDefault_Click never touched them fixed (UNI-T59)
D29 No script can change the light: isScriptOkay's CHANGE list has HERO, ENEMY, chain, TIME, SCRIPT and CAMERA but not LIGHT, so every CHANGE LIGHT is thrown away and cmdChangeLight (AMBIENT, RED, GREEN, BLUE, the commented Fade2Black/Turn2Black examples) can never run Script.vb isScriptOkay, Execute CHANGE LIGHT passes the check (ScriptLine.IsOkay); the words are matched without regard to case, so the C P shortcut's chain and a typed CHAIN are the same fixed (UNI-T60)
D30 Script arithmetic is wrong or throws: AMBIENT r,g,b is read only when the second character is a comma (a one-digit red), any other colour falls into the add branch with the whole string as a number; Color.FromArgb and the Byte tints throw past 0-255 with the Try commented out; isArithmetic turns a +n/-n step whose result leaves 0..max (100 for the camera, heroHP's range) into an assignment of the signed number (red 250 +10 becomes 10), and GREEN and BLUE check red's value Script.vb cmdChangeLight, cmdChangeCamera, isArithmetic r,g,b is any a,b,c (each floored, as Int()); every channel is held to 0-255; +n/-n is always relative (the camera unbounded, a tint held to 0-255), a bare number assigns; each tint is stepped from its own channel (ScriptRunner) fixed (UNI-T60)
D31 A malformed script runs someone else's fields: divideScript writes its module-level Command/Type/Item/Parameter only for four or two parts, so any other line (and a two-part line that is not RUN) runs with the last script's leftovers; and a parameter that is not a number throws out of Execute, taking the game down Script.vb divideScript, Execute a line is four parts, or two for RUN, or it is invalid and ignored (ScriptLine.TryParse); a parameter that is not a number changes nothing fixed (UNI-T60)
D32 RUN HEAVEN runs half of itself: Execute's one lastEventCheck is stamped by the first nested line, so its second line (CHANGE HERO Y +1) fails Time > lastEventCheck + 0 in the same instant Script.vb Execute, cmdRunScript the increment throttle is per script: the same script inside its increment is ignored, any other runs (ScriptRunner.Execute) fixed (UNI-T60)
D33 A stray key writes its name into the script, and nothing typed is ever seen: scripter mode's Case Else appends e.KeyCode.ToString for any key it does not list, so F5, NumPad7, Capital or Return's neighbours type F5, NumPad7, Capital; and showScripter's Write is the body-less one of D3, so the console's line never shows Form1.vb OnKeyDown; Script.vb showScripter; Root.vb Write only the keys it lists type: the letters (their upper-case name), the top-row digits, Space and its punctuation; any other key does nothing (Scripter.Press). The line `/ > text (\ > text with the I-beam off, every half second) is drawn at hud.json'sscripter (50, iHeight - 50, fontMenu) in the script colour while open and not paused (ScripterConsole`)
D34 A dead enemy keeps hurting: checkAngelHit tests every enemy's Rect, dead ones too, but renderEnemy skips a dead enemy and stops moving its rectangle, so an invisible hit box stays where it died and costs the angel HP whenever it flies through Engine.vb checkAngelHit, Enemy.vb renderEnemy a dead enemy is out of the world and hurts no one; every live enemy touching the angel costs HP, a held (Grabbed) one included, as checkAngelHit tests every enemy whatever its AI (GameWorld.CheckContact) fixed (U.CHN-T83)

Not restored, on purpose: stubs with no body (ExtraLife, Health5, Health20, Money items; Center and Wander motions; the Wander, Retreat, Limbo, Death AI states; angelAI.Hurt; bRicochet; the terrain lines (dead code: Terrain.vb's loadTerrain walks the child rows of a DataRow that is never set, the .mdb read being commented out, and nothing calls it or renderTerrain, whose bTerrain starts False with no key to flip it; recorded by UNI-T56, not ported); the cursors; renderTime, renderDate, levelText; SetupLights). Restoring them would mean inventing the behaviour, not fixing it. Cautious and Align had code but no rule for when they apply, so by default they stay unreached, as in the original; UNI-T65's rule for them is a data option (D18).

8. Deliberate deviations

Working behaviour of the original the rebuild does differently, and why. Status: kept (the deviation stays), to settle (a ticket brings it back in line or decides), temporary (an intermediate step until the ticket). None are still to settle (V4 and V12 settled by U.CHN-T76).

# Original Rebuild Why Status
V1 45 degree perspective camera at z -1, fixed 4:3, rebuilt every unpaused frame from cam and target, which Input.vb's numpad, X and Z move an orthographic CameraRig showing exactly what Camera.vb's lens sees of the play plane by default (camera.json mode Original, U.CHN-T86): centred on the origin, tan(22.5) x 1 = 0.414 screen units (3.73 world) either side vertically, 4:3, with black bars beside or above it on any other screen shape (CameraFraming.Viewport), so the backdrop fills the view and the sprites stand as large as in the original; the port's earlier fit of the whole 16 x 9 arena (FitLevel) and a dead-zone Follow stay data options (spike U.CHN-T92 judged the arena fit against this view and kept Original the default, §8.1). Camera.vb's lens and start are kept as data (camera.json, the rig's Perspective) and its cam and target as a Core DebugCamera (the rig's View) laid on top of the framing: numpad plus/Enter move the eye's z by camSPD (0.012) a held frame, the orthographic size scaling with the eye's distance to its target as the perspective's view of the plane does; numpad 6/4 (strafe_left/strafe_right) move eye and target by +/-0.012 on x, 8/2 by +/-0.02 on y; X/Z (isometric/deisometric) move the eye alone by +/-0.25 on x and y, so the camera turns to look back at the target at that slant (shown with the orthographic projection, so the plane is foreshortened but not converging). Timed in real seconds (a 60 fps frame per step), read paused too as Input.vb polls them, but shown only while the game runs, as initCamera is called only unpaused; the 0 key's restore puts the target back under the eye (target = cam) and every reset recentres both 2D in Unity: an orthographic view of the one plane everything is drawn on looks the same as the perspective's kept (UNI-T57); the view settled to the original's (U.CHN-T86)
V2 Units are the camera's NDC-like plane (half-height 0.414) world units: the data files hold the original's figures and one mapping (space.json, OriginalSpace) converts them; it scales screen height 1.0 to the arena's 9 units (length scale 9, UNI-T66), so the chain, the angel, the enemies and the heart move at the original's on-screen speeds (UNI-T33; before it the chain and angel used guessed world-unit figures) Unity physics, sprites and cameras work in world units kept, UNI-T66
V3 All 25 links simulate; only 0..Mace are drawn a data setting (ChainSimulation.Settings.SimulateAllLinks, chain.json's port.simulateAllLinks): true by default, matching the original exactly (animateChain always loops every link, 1..maxLinks, regardless of Mace; only renderChain's draw loop stops at Mace); false parks the inactive tail on the mace and pays it out from there when lengthened, kept only where asked for explicitly (it is also what PullBothNeighbors, D7, needs if ever opted into without this: an undrawn, both-pulled tail would otherwise drag the mace) settled as a data default (U.CHN-T45): the original's own behaviour is the default, following D7's own default
V4 Chain wall bounce commented out none by default, as the original (chain.json's port.keepInArena is false); keepInArena: true bounces links off LevelBounds at wallBounce 0.5, kept as a data option Elastic Trail bounced; the bounce kept the mace on screen settled (U.CHN-T76): the owner approved the ticket without choosing to keep the deviation, so the original's behaviour is the data default, with a Core test (Shipped_ChainDoesNotBounceOffTheWalls_AsChainVbsCheckBoundsIsCommentedOut) and the old bounce reachable through the data. Spike U.CHN-T77 weighed it headlessly (Core GameWorld on the shipped data, the scene's 16 x 9 LevelBounds as the arena, keepInArena false against true, 60 seeds each, scripted angels: still, slow orbit, fast orbit, wide kite, top edge, side edge, floor hug, a catch-and-throw orbit): it does not play better. The arena's walls (x +/-8, y +/-4.5) all lie outside the original's 4:3 view (x +/-4.97, y +/-3.73), so the bounce never keeps the mace in sight: time with the mace off screen is unchanged (wide kite 39.5% to 39.4%, side edge 39.7% to 40.4%); it only stops the mace sinking past the unseen floor. Survival, kills and mace hits are identical for the still, orbit and catch-and-throw angels, and within noise on the kite and the edges. Where it does act it plays worse: checkBounds lets the angel fly to y -5.4, below the arena's floor, and there the bounce pins the chain on the floor above the hand, so the mace slows (10.9 to 6.7 u/s) and grinds enemies with a stream of tiny hits (0.07 to 14.9 hits a second at 0.004 damage each) while the angel dies sooner (29.2 s to 19.2 s)
V5 Angel contact rectangle X..X+0.06 by Y+0.03..Y+0.15 the original's own rectangles: Angel.vb's, Enemy.vb's (X + size/2 - 0.025..+0.04 by Y - 0.03..Y + 0.05, from the centre) and Chain.vb's rectMace, through Root.vb's rectIntersect (only A's edges inside B's) for angel contact, mace hits, flocking and throw impacts (HitBox, HitShape); the circle (contact radius plus the enemy's radius) is the earlier choice, kept only as a data option (angel.json port.contactShape, chain.json port.hitShape, enemies.json port.shape, each Circle) the original's contact feel; the circle fitted the sprite at any scale reverted to the original (U.CHN-T88); circles never the default
V6 Flocking pushes 0.0005 per axis per frame, and each overlapping pair is visited twice a frame (0.001 per neighbour) 0.54 world units per second per neighbour (0.0005 x 2 x 60 fps x the length scale 9, D9) the original's figure at the fixed step; the commented-out flockRange test means any overlap pushes, as before kept, UNI-T35, scaled UNI-T66
V7 The heart is gone after a pickup until Reset the same: consumed on touch, drawn again by Reset (the first guess had it respawn at the top) matches Item.vb exactly (UNI-T44) in the original's own figures, scaled by the one mapping (V2, length scale 9): start (0, 3.6), wrap 4.5 to -4.5, so it drifts the whole arena height as -0.5..0.5 was the whole screen in the original. turnAround survives Reset as in the original kept, UNI-T66
V8 Pause is the Pause key; Escape quits (bRunning = False) the Pause key pauses and Escape quits, as in the original (Escape ends the player, or stops play mode in the Editor, through a Core QuitGame command raising QuitRequested); P and the gamepad's Start pause as extras. Until UNI-T54 the rebuild paused on Escape too and could not be quit from the keyboard; that is undone the Pause key is missing on many modern keyboards, so P stays; Escape is the original's quit kept (UNI-T34, UNI-T54)
V9 - PAUSE - and HUD as plain D3D text at fixed pixels of a 512x448 window; the pause text's top-left corner at the window's centre a UI Toolkit GameHud laid out from hud.json in those pixels, scaled to the screen's height (right-hand text kept its distance from the right edge on wider screens); the pause banner is centred on the centre. The port's extras, a thin text shadow, a dim behind the pause banner and a game-over banner over the fade (hud.json port: textShadow, pauseDim, gameOverBanner), are off by default, as the original draws none of them, and stay data options modern screens are wider and taller than 512x448; the pause text was plainly meant to sit in the middle kept (UNI-T37, UNI-T50); the extras settled to the original, off (U.CHN-T79)
V10 Swing whoosh, hit, death; no catch or throw sounds adds a catch sound (defend.wav); the swing fires on mace speed relative to the hand. No throw sound plays, as in the original: throw.wav (UNI-T71, an original clip synthesized in pure-Python stdlib, white noise through a swept bandpass, 0.32 s at 11025 Hz, since the original has none and no licensed library was available) stays wired to ChainAudio's GrappleThrow but plays only when audio.json's port.throwSound is on flying with a trailing mace is not a swing; a catch needed feedback swing (sword_swing_1-7), impact (sword_hit_1-3), death (death_1-4) and catch (defend.wav) kept: clips imported and assigned (UNI-T20); throw settled to the original (U.CHN-T80): off by default, the invented clip a data option only
V11 music.wma the same track converted to music.ogg (ffmpeg, libvorbis) and imported as a streamed AudioClip on MusicPlayer Unity cannot import WMA kept (UNI-T20)
V12 640x480 borderless form titled *** UNDER DEVELOPMENT ***, options in the registry a 640x480 borderless windowed form by default (game.json's windowFrame: Borderless, stripped by WindowFrameBehaviour on Windows standalone; OsFrame keeps the OS title bar and border as a data option); the title stays Unity.Rea.Chain (Unity shows productName; ProjectSettingsBuilder, UNI-T38), the original's own never finished (a placeholder, not a name worth keeping); WindowAspectLockBehaviour keeps 4:3 if the window is resized; options in a Unity.Shared profile the original's title was never finished so the rebuild's own name replaces it; the profile is the modern settings standard, kept on purpose frame settled (U.CHN-T76): the borderless form is the default, tested as data (Shipped_WindowIsForm1sBorderlessForm_AndOsFrameStaysReachable), the native strip is not exercised by a test (no Unity run); window size and title UNI-T38; the options screen is frmConfig's, kept in the profile (UNI-T59, V21)
V13 Input by exclusive DirectInput mouse delta and key polling one Input System InputActionAsset built in code (ChainControls: a Player map per seat, a Debug map for the scene's toggles), read by each seat's SeatInput and sent as that seat's commands the modern Unity input stack; per-seat maps are the seam for device pairing (UNI-T26) kept (UNI-T34)
V14 F1-F3 switch D3D wireframe, textures and culling the keys and Root.vb's flags are ported (the Debug map's ToggleWireframe/ToggleTextures/ToggleCulling flip GameHud.Options, a Core ViewOptions, which the menu shows and every reset puts back, UNI-T55); while any is off its start, ViewRenderFeature, a renderer feature on the 2D renderer (added by RenderPipelineBuilder), clears the game camera and redraws everything it sees in the 2D renderer's order with Hidden/MindAttic/Chain/ViewOptions, an unlit sprite shader: F1 with the device's wireframe state, F2 off untextured (D24), F3 culling back faces (D25). The redraw is unlit, so the day's tint and the game-over fade do not show while it is on; the UI Toolkit HUD is drawn after the camera and stays solid; the Editor's scene view is left alone the D3D render states are not switches in URP: a renderer feature is where URP lets a game redraw its scene another way, and SetWireframe is the same device state D3D's FillMode.WireFrame was kept (UNI-T55, UNI-T56)
V15 Game over then Reset in place the same fade, then the world resets itself in place through the one GameWorld.Reset the R key's ResetGame also runs: score, the round clock (RoundTime), the fade, game speed 1.0 and pause; each angel at full HP and home, its chain on the hand with the data files' spring, resistance and gravity; a fresh flock at Reset's HP 1.0, seeking, at real random points (D1); the world's hearts back at y 0.4 x 9, swaying left at floatSPD 0.001 x 9; then WorldReset recentres the camera (CameraRig.Recenter), jumps the music (MusicPlayer.JumpToRandomPoint, rndMusicPos) and turns lighting on (SceneLight). Reset's bDrawFPS = True shows the frame rate again (GameHud, UNI-T50), and its bRenderWireframe = False, bRenderTextures = True, bBackFaceCulling = False and bMenu = False put the menu's flags back and close it (ViewOptions.Reset, UNI-T55); its other flags (layers, side scroll, windowed) have nothing to switch back until their tickets port them (UNI-T59), bTerrain belongs to dead code (§7, UNI-T56) and it never sets bZone (D23), and its Bounce = 1.5 only feeds wall bounces that are commented out in Chain.vb, so it restores nothing matches matches (UNI-T32, UNI-T48)
V16 The ambient and tint light D3D materials a URP 2D global light carries ambient x tint (SceneLight) onto the sprites' Sprite-Lit-Default material under the committed 2D pipeline (Rendering/ChainURP, Chain2DRenderer); the HUD draws the game-over fade as an overlay only when no URP pipeline is active, so it is never applied twice there is no D3D material lighting in URP kept (UNI-T18)
V17 SFX at sfxVolume -1000 (-10 dB), music at 0 dB, music from a random point (rndMusicPos) the same, from audio.json (the port had played SFX at 0.8 and music at 0.6 from the top) matches matches (UNI-T33)
V18 Windows.Forms.Cursor.Hide() plus the mouse device's exclusive, foreground DirectInput cooperative level CursorPolicy hides the cursor and sets CursorLockMode.Confined from the first frame of a player build; AngelController's own CursorLockMode.Locked (while it is enabled) layers a tighter, centred lock on top for steering Unity has no "exclusive raw device" mode as such; Confined is the baseline the rest of the app (menus, the loading screen, UNI-T58) runs under, Locked is what steering already used kept (UNI-T38)
V19 Insert/Delete, Home/End and PageUp/PageDown add to resistance, gravity.Y and springK with no limit (Chain.vb changeResistance, changeGravity, changeSpring), so drag or a spring pushed below zero, or a stiff enough spring, blows the chain apart the same steps, each press one TuneChain command, but each figure stops at chain.json's tuning limits: resistance 0..1, gravity's y -0.01..0.0025, spring 0.001..0.25 (ChainTuning); a figure already past a limit (a profile override) is never pulled to it. Works paused, as Form1.vb's key handler does; a reset (or the game-over reset) puts the data files' figures back, a retune keeps the live ones a key that wrecks the simulation is no tuning; the limits are data kept (UNI-T51)
V20 gameSpeed is polled every frame, paused or not: Minus -0.01 and Equals +0.01 per frame held, floored at 0, no upper limit, 1.0 again on Reset; it is drawn with two decimals and applied to nothing (D13) the same keys, step and floor, timed in real seconds (0.01 a 60 fps frame, 0.6 a second, at any frame rate; Minus and Equals together cancel), each frame held one ChangeGameSpeed command raising GameSpeedChanged, working paused. Applied as the Core's time scale: GameWorld.Step plays the fixed step x GameSpeed of game time, cut into TimeScale.Substeps (one at 1.0 or below, ceil(speed) above it, at most 64) so no sub-step is longer than the fixed step and the chain's springs stay stable; what the original did once a frame (mace sweep, grapple, hurt check, game-over fade) runs once a sub-step, so below 1.0 the fade is not slowed; a game-over reset ends the step there. At 0 nothing moves and steering waits too, as if paused, until Equals raises it. The round clock, the hurt delay, the heart, the angel's hover and wing beat run on game time; the mouse moves the angel as far at any speed; presentation that runs on Unity's own clock (the camera, the time of day, the music) is not scaled the original plainly meant the keys to change the speed; a sub-stepped time scale is the safe way to apply it kept (UNI-T52)
V22 strafe_left/strafe_right also move link(0).X, the chain's anchor, by camSPD the chain is left on the hand Input.vb runs before oneFrameRender, whose renderChain sets link(0) back on the angel's hand before animateChain reads it (and nothing else reads link 0), so the original's chain never moved either: the line is dead matches (UNI-T57)
V23 Startup sets the form's BackgroundImage to gfx/gui/load/load640_<getRndNum(1, 12)>.jpg, calls Me.Show(), builds the Engine and sets the image back to Nothing just before the first oneFrameRender, all inside the form's Load handler the player opens on the Splash scene (SceneBuilder): SplashScreen picks the picture (LoadingScreen.Pick, rndNum.Next(1, 12 + 1) from a clock-seeded Random; the count is hud.json loading.pictures), draws it stretched over the whole window on a UI Toolkit panel of its own (sorting over the HUD, black behind, as the form's BackColor), keeps it up for at least one rendered frame, loads Main under it and takes it down the moment Main has loaded, so Main's first frame is the first without it. The pictures are under Resources/UI/Load, lowercased (load640_10.JPG and the rest were mixed case) Unity cannot show a picture on a window while a scene is built synchronously; the splash scene is the Unity way to cover the load. Whether the form ever painted the picture before the loop's first DoEvents depended on WinForms; the port makes sure it is drawn. Playing Main directly in the Editor skips it kept (UNI-T58)
V24 renderCube draws Cube.vb's 67 x 55 x 38 brick cube around the eye (z -1), so through the 45 degree perspective the far wall (z 19) fills everything the backdrop quad does not cover the room is its far wall as that eye sees it, projected onto the play plane: a brick.jpg sprite a twentieth of 67 x 55 screen units (distance to the plane over distance to the wall, 1 / 20), centred at 0.95 of the eye's offset, placed every frame from the rig's eye (Backdrop.FarWall, AreaBackdrop, area.json cube), so it drifts behind the backdrop at the perspective's parallax when the debug camera moves; behind it the camera clears white, as oneFrameRender does. The side walls, floor and ceiling are not drawn the rig draws orthographically (V1), where a real cube shows only its far face, at full size; the projection is what the original showed. The side walls only come into the original's view after strafing more than 20 screen units kept (UNI-T40)
V25 Form1.vb's U sets link(1)..link(5).texture to the gems whatever Mace is, so with the mace on link 1-5 ([ from 6) U overwrites the mace's own texMace with a gem, drawn at the mace's 3.5x; and [/] set link(Mace).texture = texMace on the new mace link without giving the old one its texture back, so a link the mace leaves keeps the ball picture U puts links 1-5 into aqua, emerald, teardrop, tablet and pearl (chain.json skins.keyU), the rest keep link; each gem stays on its link index, but the mace's link is always drawn as the mace and a link the mace moves off shows its own skin again (PlayerEntity.LinkSkin, LinkSkinView). U works paused, as Form1.vb's key handler does; no reset, retune or second U takes the gems off (SkinLinks -> LinksSkinned, the Player map's SkinLinks). Each gem is drawn one link wide (the chain line's width) on the drawn link over the line, later links over earlier ones, as renderChain draws 0..Mace in order the mace is drawn and tested apart from the links (MaceController); the ticket keeps it the mace, and a link keeping a stale mace picture was never a skin kept (UNI-T41)
V21 F12 (the menu's "F12 - Configure Video") sets toggleScreen and ends the loop; Startup then flips isFullscreen, saves it to the registry (saveOptions) and builds a new Engine, so the screen mode changes and the whole game starts over F12 and the menu's Video line open frmConfig.vb's screen (D27; ConfigScreen, GameHud.ToggleConfig); its Submit saves the window mode, resolution and volumes to the profile, as saveOptions and btnSubmit_Click saved to the registry and video.cfg, and puts them into effect at once (DisplayPreferences.Apply, the volumes through PlayerProfile.Changed) where frmConfig said "Settings will not take effect UNTIL next restart"; the round goes on. While the screen is open the world is paused and the cursor freed to work its controls, then both are put back; F12 again or its close box closes it keeping nothing. The Resolution list is enabled only in fullscreen as in frmConfig, but a Unity window takes the chosen size too (the original's windowed engine kept its form's own) the restart only rebuilt the D3D device for the new mode; Unity switches in place. A form over a running game cannot be worked with the mouse that steers it, so it pauses kept (UNI-T55, UNI-T59)
V26 Single player only; O is unbound O opens the Unity.Multiplayer kit's online menu (Host, Join by IP, Join by code, Settings, Play alone, Quit) over a paused local game; online, Escape opens the kit's in-game menu instead of quitting (§5.4). With the menu never opened the game plays exactly as before the rebuild is online-ready on the shared kit (AGENTS.md rule 9); a key no original key uses keeps every original binding as it was kept (U.CHN-T26)

8.1 Spike U.CHN-T92: the 16 x 9 arena fit against the original's 4:3 view

The question: does the port's earlier wide play space (camera.json port.mode FitLevel with angel.json port.arenaBounds true, so the angel roams GameWorld.DefaultArena, 16 x 9 world units inset by boundsMargin 0.5 x 0.6) play better than the original's fixed 4:3 screen (Original with checkBounds, the default since U.CHN-T86)? Both are reachable today through those two data figures alone, with no code change. The comparison below was worked from the shipped data and the rig's framing code (CameraRig, CameraFraming, GameSettings), not from a playtest in Unity, so it is the case for the owner to try against, not a verdict on feel.

Original (default) FitLevel + arenaBounds
View (world units) 9.94 x 7.46 (Camera.vb's +/-0.552 x +/-0.414, x 9), barred to 4:3 on any screen the whole arena: 16 x 12 in the default 640x480 window (WindowAspectLockBehaviour keeps 4:3, so the 16 wide arena sets the size and 1.5 units of nothing sit above and below it), 16 x 9 on a 16:9 full screen
Sprite size against the original 100% 62% in the 4:3 window, 83% on 16:9 (the angel's 0.3 screen-unit quad is 2.7 world units either way)
Where the angel can fly checkBounds: x -5.4..4.5, y -5.4..3.6 (9.9 x 9.0), a little past the screen on the left and well past it at the bottom, as the original lets it x -7.5..7.5, y -3.9..3.9 (15 x 7.8): half as wide again, but 1.2 units less height, and never off the screen
The backdrop (area.json's 1.2 x 0.83 quad at -0.56) fills the view (x -5.04..5.76, y +/-3.73 world) covers 56% of the arena on 16:9 and 42% of the 4:3 window's view; the rest is the brick far wall (V24)
Enemies that start in sight (enemies.json spawn -1..-0.5 or 0.05..1 on each axis, screen-relative, unchanged by the arena) about 1 in 10; the rest fly in from off screen about 1 in 4 on 16:9 and nearly half in the 4:3 window: they appear in the open instead of arriving
Enemy approach seekSpd 0.006 a frame (3.24 world units a second) from the same spawn field the same, but the angel can stand 2-3 units further out to the side, so the wave on that side arrives later and the far side's earlier
The mace (chain.json keepInArena false, V4) leaves the screen on a long swing, as the original's did stays in sight more often, the view being 6 units wider

What the wide fit gains: more room to the sides to swing and dodge, the whole flock and the mace in sight more often, and no bars on a 16:9 screen. What it costs: every sprite and hit rectangle drawn at 62-83% of the size the original's art and rectangles were made for (V5), the picture the game is set in shrunk to an island in the brick wall, less vertical room than checkBounds gives, and the spawn field, which the original placed just off its screen, turned into enemies popping into the open. Making it good would need more than the camera: the backdrop, the spawn ranges and the vertical clamp rescaled to the arena, each a new departure from the original's data.

Judgement: it does not play better enough to outweigh LAW-1. Original stays the default; FitLevel (with arenaBounds) stays a data option only, as the ticket asks, until the owner chooses otherwise after playing both.

Keeping these tables current

Every ticket that changes how the rebuild plays relative to the original updates §7 or §8 in the same commit: add a row for a new difference, change a row's status when it is settled, and delete nothing (a settled row says matches). A difference found with no row is a bug: file a ticket.

9. Documents

File What it is
README.md what the game is, status, layout, how to build and test
RECONSTRUCTION.md the original, module by module, its assets and inputs, the standards audit, the build order
chain-physics.md the spring algorithm, the game layers on top of it, the tuning table
USER_STORIES.md generated from the ticket database; never edit by hand
AGENTS.md the rebuild standard and where the original lives

Artifacts follow HOUSE-LAW-12 in MindAttic.HouseRules.md.

10. Glossary

  • Link: one point of the chain; link 0 is pinned to the angel's hand.
  • Mace: the heavy end link at index Mace (1..12, default 6), drawn 3.5x.
  • Grapple: holding the button turns a mace hit into a grab; release throws.
  • Hurt: an enemy's knocked-back state; it decelerates, then seeks again.
  • Thrown: a Hurt enemy launched by the grapple; it knocks over the enemies it touches.
  • Reset: the original's full round restart (score, timer, light, angel, enemies, heart, music).
  • The original: the VB.NET / DirectX 9 Chain Game at R:\...\Chain Game\.
From Unity.Rea.Chain/docs/BIBLE.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.