Implement verified Grappler body camera and helpers in VR08
This commit is contained in:
1 parent
ffea678e90
commit
43806fe862
39 files changed
+2429
-40
No files matched your search
@@ -46,16 +46,16 @@ changes. Current gadget controls/resources/primary-fire findings belong in
|
||||
docs/gameplay/. Distinguish static recovery, implementation, port tests and original
|
||||
runtime evidence. Main owns integration/runtime; gadget investigators have
|
||||
exclusive named files, not shared directories.
|
||||
Latest gadget continuation: docs/gameplay/grappler-query.md. GrapplerMotion,
|
||||
GrapplerGeometry and boundedVR08 GrapplerRay remain outside live simulation:
|
||||
72 copied-original observations,10 managed/18 Python groups,11 camera groups,
|
||||
13 Rocketship groups and main build pass. ActualVR08 ray/material tests pass;
|
||||
lab GPU readback unchanged and VR08 preview validates. Aim rejection ends active
|
||||
input before the attachment leaf; do not implement a hidden-cursor bypass.
|
||||
Shared body context/base contact, camera and helper presentation/lifetime
|
||||
remain gates before liveVR08. Source and REA artifacts are retained under
|
||||
artifacts/grappler-{ray,motion,resources,scalars,query}/; all ownership returned after
|
||||
investigator usage limits. No approximate hook/pull mechanic is enabled.
|
||||
Latest gadget continuation: docs/gameplay/grappler-live.md. BoundedVR08 is now
|
||||
live: source body/shared sphere context, camera, exact rope/SWING/cursor/audio,
|
||||
selection/companion/control cleanup, explicit RETURN and retained scalar memory.
|
||||
113 original-component observations,13 managed live groups,40 Python checks and
|
||||
9-phase native Linux SDL replay support it; validation enabled, zero errors.
|
||||
Whole-original/native Windows comparison, general dynamic pairs, other levels
|
||||
and arbitrary ordinary attached LOAD continuity remain open. Source/REA evidence
|
||||
is under artifacts/grappler-{body,camera,assets}-live; all ownership is primary.
|
||||
Next gadget candidate is Scooter; close source support/wheel/contact contracts
|
||||
in scooter.md before vehicle implementation. Preserve parked collision gates.
|
||||
The user clarified orbit's remaining issue was inverted Left/Right; Left/A and
|
||||
Right/D azimuth mappings are corrected, Up/Down unchanged. Playable packages
|
||||
identify clean70cba65; native input/resize/validation passes. See docs/orbit-camera.md.
|
||||
|
||||
@@ -20,7 +20,7 @@ VR04 and the bounded VR01/VR07 tutorials use recovered static body response/supp
|
||||
numeric references. Lab/outside retain the capsule until special contacts and
|
||||
dynamic collision are recovered; see [body implementation](docs/checkpoint/collision-body-implementation.md).
|
||||
|
||||
**Current milestone: VR02 Rocketship, Baseball, Bubble, Invisible, shrink ray and their gadget screen.**
|
||||
**Current milestone: VR08 Grappler, VR02 Rocketship, Baseball, Bubble, Invisible, shrink ray and their gadget screen.**
|
||||
Tab/Space selects owned gadgets and their practice levels; the default device
|
||||
fires on Enter/Ctrl/left mouse and supports actual VR04 soldier shrink/restore
|
||||
with original morphs and score effects. Invisible uses the recovered recharge,
|
||||
@@ -96,6 +96,13 @@ and climbs; Down brakes and descends; Left/Right banks. **Enter/T** performs a
|
||||
when unmounted. Source camera, aircraft body and Jimmy/Goddard/flame visuals are
|
||||
included. Other levels and special mission/hazard sequences remain unfinished.
|
||||
|
||||
Grappler is live in **VR08**. Select its Practice tile, then equip it there or
|
||||
use **F1 → Player → Give/Select Grappler**. Aim Jimmy toward a surface until the
|
||||
target appears; **Enter/Ctrl/left mouse** attaches and reels, arrows steer,
|
||||
and **Shift/Insert/right mouse** detaches when fire is released. Tab/Space
|
||||
unequips. Original rope, SWING morph, cursor, sounds, camera and contact response
|
||||
are connected. Other levels and special camera/contact policies remain open.
|
||||
|
||||
**F2** toggles a compact live debug overlay without pausing play. It shows frame
|
||||
timing, position/velocity, movement, control/force state, tasks, camera/clipping
|
||||
and error counters. F1 also has a Live Overlay toggle. Visibility stays selected
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
Compilation, native runtime, original behavior and full feature completion are
|
||||
separate evidence categories. **The game is not fully reconstructed/playable yet.**
|
||||
|
||||
Current Grappler scope is liveVR08: source ordinary body/shared sphere context,
|
||||
recovered camera, original rope/SWING/cursor, sounds and selection/RETURN cleanup.
|
||||
113 original-component observations;13 managed live/40 Python checks pass. Native
|
||||
Linux GTX1070 and headless replay pass9 phases with zero Vulkan validation errors.
|
||||
Exact art/capture and package evidence: gameplay/grappler-live.md. Whole-original
|
||||
VR08, native Windows, other levels and general dynamic pairs remain unverified.
|
||||
|
||||
Historical component-only status (superseded for boundedVR08):
|
||||
|
||||
Grappler query/constraint checkpoint:42 new copied-original observations (72
|
||||
total),10 managed/18 Python groups,11 camera/13 Rocketship groups and main build
|
||||
pass. ActualVR08 ray/filter/material integration works in tests. Lab gameplay
|
||||
|
||||
@@ -283,3 +283,12 @@
|
||||
detach. Native aim/constraint/post-base suffix probes do not establish the
|
||||
full body context, base contact, camera or helper lifecycle; close those
|
||||
contracts before liveVR08. See gameplay/grappler-query.md.
|
||||
|
||||
48. **Bound Grappler's shared collision and persistent helper state.** Reuse the
|
||||
preceding source-body sphere context in attached47B4B0, including stale last
|
||||
polygon callbacks; support/ray metadata is separate. Keep scalar memory at
|
||||
session scope and helper/audio state at scene scope. Explicit RETURN cleanup
|
||||
is recovered; ordinary reconstructed-scene disposal is a modern safety
|
||||
boundary. Preserve first geometry scale across reattach/reequip/load. Camera
|
||||
offsets are locals consumed by separate ground/air branches, not world poses.
|
||||
Exact SWING uses its own source-pivot draw. See gameplay/grappler-live.md.
|
||||
@@ -0,0 +1,58 @@
|
||||
# Grappler shared body/contact composition
|
||||
|
||||
2026-11-04. Original EXE SHA256 f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8.
|
||||
Static VAs in this report map to file offset VA−400000. Source ranges/hashes,
|
||||
relocation allowlist and generator: `tools/binary/grappler_body.py`;
|
||||
`artifacts/grappler-body-live/source.json`. Reuses REA47B4B0
|
||||
`ev_d45e078c585d3773494c0e0dfb1696178dd0b8ce8b696caf133892ff070e552e`
|
||||
and43AA40 `ev_4f2a6aa666451db831efd46f5c587573e22d8072315626b8bc2f844f9c6f0cae`.
|
||||
This checkpoint adds execution of copied components, not new whole-original play.
|
||||
|
||||
## Recovered ownership and order
|
||||
|
||||
479BC0..479D1B traverses enabled body integration before ordinary object callbacks.
|
||||
479D20 initializes shared sphere state once: last polygon695D4C=NULL,
|
||||
nearest face695D5C=130000, nearest edge5CFBE0=radius. Sphere hit point is5CFBE8.
|
||||
Body motion invokes47B4B0; callback370 handles normalY<=−.7 and374 handles
|
||||
normalY>−.7. Support47B890→47C6E0 and ray47C210 use selected polygon695D54 /
|
||||
hit5CFC60 instead. They preserve all four sphere state fields.
|
||||
|
||||
429D00's attached branch invokes47B4B0 at42A016 without resetting that sphere
|
||||
context. Therefore movement *away* from a previously accepted wall can replay
|
||||
374 even when the new movement accepts no polygon. Zero delta skips dispatch.
|
||||
A fresh context on each attached move would silently lose this callback.
|
||||
|
||||
Jimmy374→42A660 first invokes full Player43AA40. For the bounded VR08 material
|
||||
IDs0/2/3/4, all probed grounded/mature combinations leave the body unchanged.
|
||||
The derived suffix clears horizontal swing globals4F82BC/C0, then detaches
|
||||
strictly when their incoming magnitude exceeds60; equality60 stays attached.
|
||||
The action latch is set by this same fast-contact branch. Detach429C10 zeros
|
||||
velocity, selects FALL, damps swing .96 and stops loop34; it adds no impulse.
|
||||
Ordinary ceiling370→472690 clears positive Y velocity and acceleration separately.
|
||||
Attached input later clears Vy unconditionally. After an attached callback the
|
||||
429D00 tail still executes, including swing publication and pre-collision rope root.
|
||||
Normal frame/player update still runs after input returns.
|
||||
|
||||
## Copied-original observations
|
||||
|
||||
`artifacts/grappler-body-live/probe/wine.log` ends
|
||||
GRAPPLER_BODY_COMPONENT_COMPLETE; private Wine32 probe exit0. Generated code
|
||||
uses copied original body/support/ray/static dispatcher, synthetic grid and
|
||||
callback counters. Its8 chained observations cover body wall+floor, support/ray
|
||||
preservation, stale replay, zero delta and the −.7 boundary.32 cases execute full
|
||||
43AA40 then42A660 across four materials ×grounded ×mature ×fast/slow swing.
|
||||
A final case checks ceiling's independent positive-Y rules.41 observations and
|
||||
input/log hashes are retained in `tests/GamePort.GrapplerLiveTests/original-body-reference.json`.
|
||||
These are original-component execution with synthetic inputs, not whole-game,
|
||||
original scheduler, historical hardware or original render evidence.
|
||||
|
||||
## Implemented bridge and limits
|
||||
|
||||
OriginalBodyPhysics retains its mutable StaticCollisionContext. MoveAttached
|
||||
requires the preceding body phase and reuses that object. LabSimulation invokes
|
||||
370/374 after publication, feeds attached contact back to GrapplerGadget and
|
||||
continues ordinary player update. Normal physics wall callbacks also reach it.
|
||||
Bounded live admission adds only VR08, whose materials are independently guarded.
|
||||
Other actors/global sphere-context interleavings, dynamic pairs, special-material
|
||||
callbacks and other levels remain outside this integration. The per-player
|
||||
context is a bounded adapter, not a recovered general scene-global scheduler.
|
||||
@@ -0,0 +1,125 @@
|
||||
# Grappler follow camera: local fields, consumers and live adapter
|
||||
|
||||
2026-11-03. Static recovery against Neutron.exe SHA256
|
||||
`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`.
|
||||
Originals remain untouched. All VAs below have PE file offset VA−400000 at
|
||||
the guarded sites. `tools/binary/grappler_camera.py` emits actual mapped offsets,
|
||||
span hashes, virtual targets and constants to
|
||||
`artifacts/grappler-camera-live/source.json`. Its twelve tests exercise a bounded
|
||||
Python projection, not original game execution or a live camera comparison.
|
||||
|
||||
## State writers are not camera poses
|
||||
|
||||
Jimmy complete+7C8/7CC/7D0 stores local eye XYZ; +7D8/7DC/7E0 local look XYZ;
|
||||
+854/858/85C stores follow gains. These fields feed shared viewport eye
|
||||
+44/48/4C and pitch/yaw +50/52 through the active follow callback. They are not
|
||||
ready-to-use world coordinates or camera height/distance parameters.
|
||||
|
||||
| State / original writer | Eye local | Look local | Stored gains XYZ |
|
||||
|---|---|---|---|
|
||||
|Normal defaults437740..43778D, complete170|0,200,−350|0,80,0|1.6,1,1.6|
|
||||
|Equip42981A..429844|0,50,−350|0,150,80|**Unchanged**|
|
||||
|Attach426D59..426D7F|X unchanged,400,−650|**Unchanged**|.8,1,.8|
|
||||
|Attached detach429C34..429C74|0,50,−350|0,130,100|1.6,1,1.6|
|
||||
|Cleanup4287FC..42880A|Detach then normal defaults|Detach then normal defaults|Normal defaults|
|
||||
|
||||
Detach429C10 is a strict no-op when attached4F8210 is already false. Cleanup
|
||||
still calls437740 in that case. Equip does not clear attachment or first rope
|
||||
length in its selected branch. Higher-level selection/cleanup order owns those
|
||||
transitions. Attaching again after detach retains look(0,130,100); equipping
|
||||
again restores look(0,150,80). Always rebuilding a generic "attached camera"
|
||||
would erase this observable difference.
|
||||
|
||||
## Ordinary walking follow
|
||||
|
||||
Complete124→438BC0 uses the normal subpath439625..4398EF when special camera
|
||||
flag828 is false. The source adjustment complete84C defaults to10 and normal
|
||||
walking resets it to10 at438CC6 when its enclosing camera/gadget conditions
|
||||
permit; Grappler raw7 is not the special raw6 exception.
|
||||
|
||||
The effective points are:
|
||||
|
||||
```
|
||||
eye = root + fullEulerRotate(eyeX, eyeY − 2*adjustment, eyeZ)
|
||||
look = root + fullEulerRotate(lookX, lookY + 1.9*adjustment, lookZ)
|
||||
gain = (storedX, storedY + .2, storedZ)
|
||||
```
|
||||
|
||||
439652 and4396DA invoke game384→472980, the full logical Euler point
|
||||
transform, using the source negative Z/X/Y table rotation. Thus equipped normal
|
||||
eyeY is30 and lookY169 at zero rotation; attached eyeY380. Neither is a direct
|
||||
substitution into the port's existing ordinary hardcoded follow offsets.
|
||||
439658..439686 caches desired eye at complete804..810. Normal4397B1..4397F8
|
||||
multiplies each delta by its effective gain, obstacle gain and dt; there is no
|
||||
final interpolation-factor clamp in this path.
|
||||
|
||||
Flag828 can instead choose a different transformed/cached eye and uniform
|
||||
gains; flag851 selects fixed .2 smoothing independent of the normal branch.
|
||||
These are explicit excluded branches, not proven absent from every level.
|
||||
|
||||
## Ordinary airborne follow
|
||||
|
||||
Complete128→439900 captures OLD viewport eye at439E33.439E38..439E6B
|
||||
passes raw eye locals to complete120→43A5D0. This helper does **not** add120
|
||||
to Y:120 is a virtual-slot coordinate. At43A5EA it reads logical Euler, then
|
||||
43A5F0..43A67B uses pitch0, yaw=`AddAxis(logicalYaw, complete6D4)`, and logical
|
||||
roll. The helper applies the table rotation, reads root310 at43A6FB, and adds
|
||||
root XYZ. Complete6D4 is the source turning accumulator, not a camera-local Y
|
||||
offset. Negative yaw addition follows the previously recovered truncation/360
|
||||
seam from `RocketOrientation.AddAxis`.
|
||||
|
||||
439E81..439EAA transforms unadjusted look locals using game384 full Euler.
|
||||
For ordinary movement mode other than2,43A03C..43A06C uses **fixed**
|
||||
gains(1.2,2,1.2), multiplied by obstacle gain and dt. It never reads stored
|
||||
854..85C there. Attached air therefore uses eyeY400, with look150/80 on first
|
||||
attach or130/100 after detach/reattach. Body pitch affects the look but not air
|
||||
eye pitch; body roll affects both. Turn accumulator affects only air eye yaw.
|
||||
Movement mode2 has separate Bubble gains and flag851 still selects its special
|
||||
.2 branch. Do not claim these ordinary Grappler formulas cover those branches.
|
||||
|
||||
## Shared obstruction and old-eye orientation
|
||||
|
||||
Both paths call complete16C→43B820 after computing points. Its caller supplies
|
||||
look by value and desired eye by pointer; the two preliminary actor310 reads
|
||||
are not additional point offsets.47C210(false) traces look→eye with original
|
||||
static grid/order/filter semantics. On hit43B884..43B8F4 writes:
|
||||
|
||||
```
|
||||
desiredEye = look − .75*(look − hit) = .25*look + .75*hit
|
||||
obstacleGain = 1.5 # miss returns1
|
||||
newEye = oldEye + (desiredEye − oldEye) * gain * obstacleGain * dt
|
||||
aim = look − oldEye # deliberately NOT look − newEye
|
||||
```
|
||||
|
||||
Walking captures old eye in complete714/718/71C before this path and uses it
|
||||
at439830..439865. Air captures old eye in locals and uses it at43A09F..43A0CE.
|
||||
OMT vector `angles` IAT48D108 yields signed14-bit orientation; subsequent
|
||||
viewport delta arithmetic gives the new quantized pitch/yaw. Reusing the Rocket
|
||||
orientation helper is justified; using its gain2 obstacle callback instead of
|
||||
the Jimmy gain1.5 is not. See [camera-ray-predicate.md](../checkpoint/camera-ray-predicate.md)
|
||||
for the independently recovered obstruction query.
|
||||
|
||||
## Adapter recommendation and verification boundary
|
||||
|
||||
Keep a small mutable source-local camera state with the exact writers above.
|
||||
For bounded VR08, dispatch ground versus air with the stored movement-mode
|
||||
decision recovered in438A60, then use full source transforms and one source
|
||||
camera ray. Preserve shared viewport history and compute aim from old eye.
|
||||
Do not use support alone to pick a camera branch, reset look on each attach,
|
||||
apply stored gains to air, or post-correct with a second collision query.
|
||||
Resetting camera state at a reconstructed scene boundary must follow the actual
|
||||
PostLoad/default/control event; the persistent-state report is separate.
|
||||
|
||||
REA was used through the existing local launcher on a generated EXE copy.
|
||||
The first new helper request mistakenly supplied VA as a numeric file offset;
|
||||
the corrected file offset3A5D0 mapped to43A5D0 but Ghidra12.1.4 had no recognized
|
||||
procedure there. Both complete failures are retained in
|
||||
`artifacts/grappler-camera-live/rea-eye*/`. No pseudocode success is claimed and
|
||||
no unchanged failed request was repeated. Existing successful REA evidence for
|
||||
437740 is ev_d2502f41c45731b86d4365634fbc6f0d1b3b70d880fd5741275fd36f1d585aa4;
|
||||
47C210 is ev_ff5aab3bdc275e6626753743a3567a556f698209ad9f65689cf49a4b5f56107d.
|
||||
Guarded disassembly supplies the missing follow/eye entries.
|
||||
|
||||
Unresolved: runtime original-versus-port VR08 camera comparison; flag828/851
|
||||
transitions outside the bounded normal case; complete scene-entry shared-camera
|
||||
cache continuity. No new copied-original camera probe was run in this chunk.
|
||||
@@ -0,0 +1,132 @@
|
||||
# Grappler lifecycle and retained state
|
||||
|
||||
2026-11-03. Static source contract, EXE SHA256
|
||||
`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`.
|
||||
Preferred-base VAs map to raw file offset VA−400000 at the guarded code sites.
|
||||
Source guards/projection tests are recorded in grappler-camera-live/source.json
|
||||
and python.log. No original gameplay was executed for this investigation.
|
||||
|
||||
## State ownership and reset boundaries
|
||||
|
||||
Jimmy complete owns rope+B0C, cursor+B14, companion+A1C and sound handle+1E04.
|
||||
Raw selected gadget4F0588 and Grappler globals are process storage, not fields
|
||||
serialized into the TSK inventory. Retained Jimmy is reused by ordinary loads;
|
||||
its constructor must not be simulated on every scene entry.
|
||||
|
||||
| Storage | Fresh Jimmy constructor | Attach | Detach / selected cleanup |
|
||||
|---|---|---|---|
|
||||
|attached4F8210|422761→false|426C7F→true|429C28/428810→false|
|
||||
|anchor index4F82CC, first anchor XYZ4F8214..1C|422767..422782→zero|Current ray hit copied to indexed anchor|No clear|
|
||||
|first length4F82B4|422796→0|426C24 tests0;426C6B writes current length only on zero sentinel|**Preserved**|
|
||||
|current length4F82B8|42278C→0|426C1E stores distance−100|Preserved; reel/swing own later updates|
|
||||
|swingX/Z4F82BC/C0|4227A0/AA→0|426CE2/EC→0|429C7E..CA5 multiply each by float.96|
|
||||
|elapsed4F82C4|4227B4→0|426D2E→0|Preserved|
|
||||
|fast target4F82C8|No explicit constructor write; process zero-fill initially|426D4D→anchorY−rootY−200|Preserved|
|
||||
|complete864 action byte|Not renamed as generic control state|426C85→true|429C2E/428816→false|
|
||||
|loop34 handle complete1E04|4227CD→−1|Stop old, play new34, save handle|Stop if valid; store−1|
|
||||
|
||||
The complete EXE disassembly scan has only two direct writes to first lengthB4:
|
||||
constructor zero422796 and first-attach assignment426C6B. The inspected retained
|
||||
Init437890 and full PostLoad423610 route do not repeat that constructor reset;
|
||||
the global writes in equip/detach/cleanup are bounded above. This supports
|
||||
retaining B4 across ordinary retained-player loads and re-equips. It does not
|
||||
establish a disk save/load serialization contract or arbitrary indirect memory
|
||||
write absence. First attachment's length/600 scales owned rope Z only whenB4=0;
|
||||
recreating the port visual requires preserving/reconstructing that first scale
|
||||
as an implementation bridge, not rescaling it from each current length.
|
||||
|
||||
Constructor reset is tied to a newly constructed Jimmy, not just a new game
|
||||
screen. Current length and swing state also survive the listed cleanup paths,
|
||||
but attach always assigns/reset them. Session storage is appropriate for these
|
||||
globals; a scene-local active attachment/query reference still needs an explicit
|
||||
safe boundary in a modern adapter. Such teardown is not evidence that the
|
||||
original ordinary stage reset attachment.
|
||||
|
||||
## Equip, attach, detach and helper visibility
|
||||
|
||||
4297DD equip hides the companion via complete58(1), gameD0(0), game214(0)
|
||||
when present, writes camera locals and raw7. No attach/reset is implicit. The
|
||||
optional inventory/tutorial menu command9B is a separate branch.
|
||||
|
||||
426A70 attachment is reached only after429D00's enclosing aim/blocking gates.
|
||||
It stops prior +A3C audio, repeats its ray, stores length/anchor/first scale,
|
||||
sets attached/action, clears jump+7E8 and linked jump effect+6C0, plays one-shot
|
||||
31 and restarts loop34. It zeros swing scalars/time, preserves velocityXZ,
|
||||
writes velocityY100, sets fast target, and changes camera fields. The rope's
|
||||
non-null/resource-visible guard426D85..426D9D calls complete58(0) and records
|
||||
the visibility-related70 state. The exact owned-resource rendering is separate
|
||||
from the camera/lifecycle contract.
|
||||
|
||||
Held primary while attached reduces length by250*dt only while old length>250,
|
||||
ensuring loop34; the alternate branch stops that loop. Before raw7 dispatch,
|
||||
429D5D..429DBB maintains loop34 according to42A7A0 held-primary and attached.
|
||||
This prelude is not an unconditional loop: it stops a valid handle when the
|
||||
appropriate predicate fails. Fast reel950*dt and its target test are separate.
|
||||
Do not combine all sources into a forever-running equipped sound.
|
||||
|
||||
429C10 returns immediately if already unattached. Otherwise it clears attached
|
||||
and action, resets detached camera locals, damps residual swing.96, **sets body
|
||||
velocity XYZ0**, directly selects FALL, stops loop34 and marks−1, and hides rope
|
||||
via complete58(1). It does not supply launch velocity, reset first length, clear
|
||||
movement speed, rewrite jump/movement mode or erase pending impulse. Caller
|
||||
preparation may do some of those things independently.
|
||||
|
||||
Selected cleanup4287AC conditionally restores the companion if its+9E8 gate is
|
||||
zero: show58(0) only when visibility-related70 is nonzero, then gameD0(1) and
|
||||
game214(1). It calls detach204, ordinary camera170, clears attached/action again,
|
||||
hides cursor58(1), and sets raw−1 in common tail428832. The +9E8 guard prevents
|
||||
unconditional companion visibility restoration. Inactive detach is not an
|
||||
independent catch-all loop stop; valid source state keeps loop ownership aligned.
|
||||
The prior independent resource investigation owns exact helper retention/draw.
|
||||
|
||||
## SWING is protected from ordinary action requests
|
||||
|
||||
The controlled frame calls438A60 then429D00 before later primary426A70. A true
|
||||
429D00 return ends remaining426030 input only; normal Jimmy437940 still runs.
|
||||
An attached swing sets logical Euler pitch/roll0 while preserving yaw at429E4A..
|
||||
429E7C, then requests complete150(`SWING`) at429E84..429E8B before rope/body
|
||||
constraint work. Ordinary437940's movement/body publication must continue.
|
||||
|
||||
Complete150→43AFF0 first compares current action with the requested action and
|
||||
protected actions. Literal SWING4EF6D8 is checked at43B096..43B0B0; matching
|
||||
current SWING returns43B597 before RUN/STOP/LEFT/RIGHT conditional changes.
|
||||
Thus normal437940 requests do not overwrite SWING. Detach uses direct complete
|
||||
E0(`FALL`,1) and bypasses that conditional action guard. The air jump/FALL path
|
||||
in437F90 can directly request FALL only for jump modes3/4; attachment already
|
||||
clears jump mode0. A retained SWING render pose is justified while this contract
|
||||
holds; it must yield to direct scripted/hit/death action ownership rather than
|
||||
being a universal per-render override of every action.
|
||||
|
||||
## Control and transition events are different boundaries
|
||||
|
||||
Source [cutscene-preparation.md](../checkpoint/cutscene-preparation.md) recovers:
|
||||
|
||||
| Event | Proven operation affecting Grappler |
|
||||
|---|---|
|
||||
|CAM with NULL control|Jimmy438→42AE00→selected cleanup178, then410 speed/velocity preparation, orientation flatten, raw control clear|
|
||||
|Initial non-none MCA activation|410 first, orientation flatten, then438 selected cleanup and raw clear|
|
||||
|Later MCA shot|No repeated410/438/raw-clear preparation|
|
||||
|AI with NULL control|410 and raw clear; **no438 selected cleanup**|
|
||||
|Raw control owner changes alone|Controlled426030/437940 tail stops; no generic detach follows from that fact|
|
||||
|RETURN457FF7|Selected cleanup178 before return flags and staging|
|
||||
|Ordinary LOAD/practice stage43B5A0|No selected cleanup;148→429A00 only stops+A44, distinct from loop34|
|
||||
|Retained Init/PostLoad|No blanket first-length reset; specific scene/gadget/camera rules remain separate|
|
||||
|
||||
410→42AFC0 clears speed/velocity through43A750 and requests conditional STOP.
|
||||
When SWING is current,43AFF0 can preserve it; do not infer detach from STOP
|
||||
preparation alone. Menus pause or gate input under their existing phase rules.
|
||||
Debug noclip is a modern policy, with no source semantics. A chosen noclip/scene
|
||||
safety detach should be labeled as that adapter boundary and retain proven B4
|
||||
persistence. Debug force control likewise changes modern effective ownership;
|
||||
it must not erase already delivered authored selected-cleanup events.
|
||||
|
||||
## Remaining questions and claim boundary
|
||||
|
||||
The ordinary VR08 lifecycle is sufficiently specified for a bounded live
|
||||
adapter plus tests for first attach, held reel, jump release, high-contact
|
||||
detach, reattach, re-equip, CAM/MCA cleanup and RETURN. Save-file serialization
|
||||
of global first length is not recovered. Whole-original menu/control/render
|
||||
comparisons, malformed selected/attached/loop combinations and all other
|
||||
levels' special follow/action policies remain open. These are static facts and
|
||||
projection checks; managed compilation or VR08 smoke must be reported separately
|
||||
by the integrating primary, and Windows user testing remains runtime evidence.
|
||||
@@ -0,0 +1,91 @@
|
||||
# Live Grappler: bounded VR08
|
||||
|
||||
2026-11-04. Supersedes component-only status in grappler-query.md. Original
|
||||
EXE/DLL/assets remain authoritative and untouched. The playable orbit70cba65,
|
||||
lab69d0187 and parked collision35a2a66/0272f7b checkpoints remain preserved.
|
||||
All prior investigators returned ownership; primary integrated and verified.
|
||||
|
||||
## Coverage and implementation
|
||||
|
||||
| Contract | Original evidence | Current adapter / verification |
|
||||
|---|---|---|
|
||||
|Root/full-Euler first-hit ray, material/close gate|429D00 and enclosing426030;23 native aim cases|GrapplerRay/Geometry; actualVR08 and close-surface regression. Early input return still permits ordinary player update.|
|
||||
|Attach/reel/swing/detach scalars|426A70/429D00/429C10;30 native scalar +10 constraint cases|GrapplerGadget composes recovered components; no direct-pull replacement, reel clamp or launch impulse. Normal body and frame phases continue.|
|
||||
|Shared sphere/body/base contact|479D20→47B4B0,42A016,43AA40→42A660;41 new native cases|OriginalBodyPhysics retains mutable context; attached Move reuses it. Normal and attached wall callbacks both reach Grappler. Live actual-wall scalar/root fixture verifies high-contact detachment.|
|
||||
|Camera|438BC0/439900,437740, attach/equip/detach writers; guarded static/Python projection|GrapplerCamera dispatches by movement mode, uses distinct ground/air transforms/gains, obstruction gain and old-eye quantized aim. Managed checks and rendered replay; no original-camera runtime comparison.|
|
||||
|Rope/SWING/cursor|HIROPE/HISWING bindings, OMT shape-scale consumer,445580 final110 dimensions|Exact exported art, dedicated source-pivot morph; fixed first-length scale, pre-collision rope root, alpha cursor. Generic billboard remains modern renderer bridge.|
|
||||
|Selection/companion/control|427FF0→4287AC, CAM/MCA vs AI_NULL, RETURN457FF7|Normal selection and F1 grant; cleanup hides helpers/stops34/restores camera and eligible companion. Raw control loss alone does not detach. Actual intro and RETURN tests pass.|
|
||||
|Persistence|Ctor/first-attach-only B4 writes; source lifecycle in grappler-lifecycle.md|GrapplerMemory lives in Main across reconstructed scenes; helpers are scene-local. Retained scalars tested; not serialized into TSK.|
|
||||
|Debug policy|Modern tool boundary, not original recovery|F3 releases attachment/selection. R resets memory. GiveGrappler outsideVR08 retains practice selection but enables no unsupported live mechanics.|
|
||||
|
||||
State belongs to three scopes: process/session scalar memory (anchor, first/current
|
||||
length, reel target, swing), scene-local helper/controller state (equipped/attached,
|
||||
loop/cursor/pose), and LabSimulation body/shared viewport history. Cleanup releases
|
||||
attached motion, default camera, visuals and sound without erasing first scale.
|
||||
RETURN raises selected cleanup before the transition event. An ordinary modern
|
||||
scene teardown also releases scene-local resources before SceneAudio disposal;
|
||||
this is a modern safety boundary, **not** a claim that every original LOAD detaches.
|
||||
Retained scalar memory survives that boundary; scene-entry shared-eye continuity
|
||||
and arbitrary non-RETURN attached transitions remain unresolved.
|
||||
|
||||
On attach, clear jump word/effect only, set Vy100, preserve movement mode, hold,
|
||||
acceleration and pending impulse. Input runs before ordinary player apply on fresh
|
||||
entry and after it on retained entry. StepCamera precedes gadget input. SWING uses
|
||||
a separate source-pivot draw and preserves ordinary body publication. Collision
|
||||
may detach during attached movement; the source tail still updates swing/helper
|
||||
state using the unclipped constraint root. Surface aim is then recomputed; fire
|
||||
performs a fresh trace when unattached. No cached cursor-to-anchor substitution.
|
||||
|
||||
## Checks and captured evidence
|
||||
|
||||
-113 original-component observations total: prior72 scalar/aim/constraint/contact
|
||||
plus41 body/support/ray/full-contact cases. Native probe generation/log/reference
|
||||
hashes are retained; source execution uses copies under artifacts, never Original.
|
||||
-13 managed live groups (`tests/GamePort.GrapplerLiveTests`) cover fresh/retained
|
||||
input order, attachment/normal body, held reel/simultaneous fire+jump, detach/
|
||||
reattach/first-scale, strict60 impact, actual wall constraint collision, shared
|
||||
stale-contact replay/zero delta, camera consumers/transitions, ownership/intro,
|
||||
actual RETURN, noclip/reset/retained memory, helper art and close-surface gate.
|
||||
The actual-wall test explicitly positions Jimmy and sets rope/swing state;
|
||||
this is distinct from the unseeded input replay below.
|
||||
-40 Grappler Python checks: guarded original spans, camera projections, assets and
|
||||
saved native-body observations. The broader Python suite passed296 tests before
|
||||
adding the final source-presentation guard; its final total is297.
|
||||
-Existing managed suites,33-scene GPU/material audits and original hash check are
|
||||
driven by scripts/test.sh. Selected-source Patrol/Interaction projects needed
|
||||
explicit Grappler/heading dependencies; initial compile failures were fixed.
|
||||
-Headless llvmpipe1280×720 and native Linux GTX1070/private Xvfb1920×1080 replay
|
||||
pass all9 phases with enabled Vulkan validation, zero errors. SDL Left/Ctrl/Up/
|
||||
Shift/F3 events are received.120 extra ordinary ticks reuse received input;
|
||||
no root/velocity/rope scalar/timer is seeded. Capture stages include attach,
|
||||
original SWING/rope, detach, reattach, cutscene, noclip and reset. Images inspected.
|
||||
Logs `artifacts/grappler-live-{smoke,window}.log`; captures share those prefixes.
|
||||
-1920×1080 Player-page capture (`artifacts/grappler-debug-wide.ppm`) fits all32
|
||||
rows including Give/Select Grappler. Managed navigation/repeat/bounds checks pass.
|
||||
|
||||
Reproduce from GamePort with `source scripts/env.sh`, then:
|
||||
|
||||
```
|
||||
dotnet run --project tests/GamePort.GrapplerLiveTests
|
||||
dotnet run -- --scene artifacts/extracted/VR08/scene.json --level gam/VR08.gam \
|
||||
--smoke-grappler --headless --screenshot artifacts/grappler-check.ppm
|
||||
```
|
||||
|
||||
Native-window replay uses `--width 1920 --height 1080` without `--headless`,
|
||||
private Xvfb and SDL_AUDIODRIVER=dummy
|
||||
where no hardware output is available. Dummy audio verifies stream/lifecycle,
|
||||
not audible quality. Original whole-game VR08 and native Windows play remain
|
||||
unverified; cross-publishing is recorded separately below.
|
||||
|
||||
## Remaining work
|
||||
|
||||
Full scene-global body interleavings/dynamic pairs, other levels/material policies,
|
||||
special camera828/851/mode2, complete source renderer flags/lighting, arbitrary
|
||||
attached ordinary LOAD continuity and save serialization of globals remain open.
|
||||
These do not block the boundedVR08 implementation. Next gadget candidate is
|
||||
Scooter, whose support/wheel/contact contracts are explicitly unresolved in
|
||||
scooter.md; recover them before implementing its vehicle behavior. Preserve the
|
||||
parked general collision work and avoid expanding Grappler to other levels until
|
||||
those shared contracts and actual original comparisons support it.
|
||||
|
||||
Package/provenance results are appended after final local packaging.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Grappler source resources and helper presentation
|
||||
|
||||
2026-11-04. Exporter: `tools/extractors/grappler_resources.py`; generated manifest
|
||||
`artifacts/extracted/grappler/grappler.json`. Six source-file SHA256 values are
|
||||
checked before export; originals remain untouched. Export includes rope01.ASE,
|
||||
jimswing.ASE, jimstop topology, jimycarl pixels and RetainedSprites canvas8.
|
||||
|
||||
## Recovered bindings and consumers
|
||||
|
||||
EXE VAs map to file offset VA−400000 at these sites. HIROPE points to rope01.ASE;
|
||||
HISWING→jimswing.ASE and SWING are bound422BCC..422BDA. Source rope has6 indexed
|
||||
vertices/6 triangles, longitudinal Z0..600.9758 after the established ASE axis
|
||||
conversion. Init41F0FA..41F12E applies roll180; attached429D00 sets pitch/yaw
|
||||
from the quantized constraint offset and resets roll0. Render position is the
|
||||
unclipped constraint desired root+Y116, even when collision clips Jimmy elsewhere.
|
||||
First attachment426C63 mutates shape geometry through virtual34 using
|
||||
(firstLength/600) longitudinal scale. Original OMT2.dll10005970 (file5970) is
|
||||
OMedia3DShape::scale, not an actor transform or radius setter. Reeling does not
|
||||
repeat that geometry mutation. The modern renderer equivalently applies the
|
||||
retained first scale to fresh base vertices each render; it never accumulates it.
|
||||
|
||||
SWING has426 indexed vertices,814 faces, source samples0/480. Its absent UVs use
|
||||
jimstop's source topology and exact jimycarl atlas.43AFF0 protects SWING from
|
||||
ordinary conditional RUN/STOP requests; body integration is still active. The
|
||||
port draws a dedicated source-pivot morph and hides the ordinary standing draw.
|
||||
|
||||
Cursor4453B0 inherits SpriteSize150, but its init445580 (file45580), invoked by
|
||||
virtual40C, converts final signed words complete5E8/5EA=110 to world dimensions
|
||||
completeAC/B0. Thus the visible cursor is110×110.4645F0 sets alpha blend6/7 and
|
||||
center alignment3/3; canvas8 is64×64, decoded SHA256
|
||||
8d31014cb9b9661ebed902c864bf740f562460e74da3f6b86ed3d2be4d10f0ec.
|
||||
Flags248 and source constructor metadata remain in the manifest.
|
||||
|
||||
## REA and verification boundary
|
||||
|
||||
REA on generated copies retained complete replies/snapshots in
|
||||
`artifacts/grappler-assets-live/rea-{shape,sprite,bind}/`. Shape consumer Evidence
|
||||
`ev_e337ad879cea5877eb463324d48d15f860ceacf80c8225e66e9f35bc4b8ed660`;
|
||||
sprite replies include `ev_9af340590afc1e0c64a249af250a520b2f09eba484e95d097f134b3254b67a8d`,
|
||||
`ev_ab13438ec345f10472d10965048c34d31654e6d9303d729df98b65aa92d37a1e`,
|
||||
`ev_69c4b496b5da7846245164028f0cb994222b0f136d24bb5fa3da7fdf236b228d`.
|
||||
464430 was not recognized; failure retained, no decompilation success claimed.
|
||||
Disassembly and guarded byte spans supplement those results.
|
||||
|
||||
Six Python checks verify exact source samples/pixels, source binding/consumer
|
||||
spans, final cursor sizing and bounded output. Managed live tests verify constant
|
||||
first-scale rendering, helper cleanup and110-unit cursor dimensions. Native
|
||||
Linux VR08 captures show rope/SWING/cursor. Generic sprite billboarding uses the
|
||||
existing modern camera-facing bridge; full original flags/renderer behavior,
|
||||
lighting and original-versus-port visual comparison remain unresolved.
|
||||
@@ -1,3 +1,20 @@
|
||||
# Progress — 2026-11-04
|
||||
|
||||
## Live VR08 Grappler
|
||||
|
||||
Integrated shared body/sphere contact state, full bounded base callbacks, recovered
|
||||
follow camera, exact rope/SWING/cursor art, selection/audio/companion lifecycle
|
||||
and RETURN cleanup. Process scalar memory survives scene reconstruction; noclip/
|
||||
reset teardown is explicitly modern debug policy.113 copied-original component
|
||||
observations support the composition;13 managed live groups and40 Python checks
|
||||
pass. Native Linux GTX1070/private Xvfb1920×1080 input replay passes9 phases with
|
||||
zero enabled Vulkan validation errors; headless replay also passes.32-row Player
|
||||
debug page includes Grappler and fits widescreen. Details/limits and final build
|
||||
evidence: [grappler-live.md](gameplay/grappler-live.md). Whole-original comparison
|
||||
and native Windows gameplay remain pending.
|
||||
|
||||
Earlier component-only status follows chronologically.
|
||||
|
||||
# Progress — 2026-11-03
|
||||
|
||||
## Grappler ray, constraint and contact checkpoint
|
||||
|
||||
@@ -5,6 +5,11 @@ offsets, virtual addresses, API symbols or observed behavior. Decompiled output
|
||||
evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL
|
||||
probes and modern runtime checks are recorded separately.
|
||||
|
||||
- `gameplay/grappler-live.md`: boundedVR08 integration/coverage and runtime
|
||||
evidence. `grappler-body.md` records shared sphere context and41 native cases;
|
||||
`grappler-camera.md`, `grappler-resources.md`, `grappler-lifecycle.md` record
|
||||
consumer state, exact art/shape-scale source and cleanup/persistence. Original
|
||||
component execution and modern/native Windows evidence remain distinct.
|
||||
- `gameplay/grappler-query.md`: enclosing426030 early-return correction,
|
||||
VR08 static filter/selected-material metadata,42 copied-original aim/constraint/
|
||||
post-base contact cases and corresponding managed components. The attachment
|
||||
|
||||
+15
-2
@@ -46,10 +46,23 @@ compile, runtime and original-fidelity verification are separate.
|
||||
|
||||
## Immediate continuation
|
||||
|
||||
- [x] Bounded liveVR08 Grappler: shared body context/full base callback, follow
|
||||
camera, original rope/SWING/cursor/audio, ownership/RETURN/retained scalars,
|
||||
normal/debug selection.13 managed groups/40 Python checks and9-phase native
|
||||
Linux SDL replay pass. See gameplay/grappler-live.md for evidence and limits.
|
||||
- [ ] Native Windows and whole-originalVR08 comparison; shared dynamic pairs,
|
||||
special policies/other levels and non-RETURN attachment continuity remain open.
|
||||
- [ ] Next gadget: Scooter source wheel/support/contact contracts before live
|
||||
implementation. Preserve parked general collision continuation.
|
||||
|
||||
Historical Grappler gates below were closed for boundedVR08 by this checkpoint;
|
||||
component reports remain evidence, not current live status.
|
||||
|
||||
|
||||
- [x] Grappler aim/root-Euler ray/first-hit material, normalized constraint and
|
||||
post-base contact:42 additional original cases,72 total/10 managed/18 Python;
|
||||
actualVR08 query and existing camera/Rocketship/GPU regressions pass.
|
||||
- [ ] Grappler live gates: carry shared sphere/contact context through attached
|
||||
- [x] Grappler live gates: carry shared sphere/contact context through attached
|
||||
47B4B0 and43AA40; complete follow camera and rope/cursor presentation/lifetime,
|
||||
then actualVR08 attach/reel/swing/detach/control-loss/RETURN. See grappler-query.md.
|
||||
|
||||
@@ -57,7 +70,7 @@ compile, runtime and original-fidelity verification are separate.
|
||||
mapping while preserving correct Up/Down and gameplay controls.
|
||||
- [x] Grappler isolated attachment/reel/damping component:30 copied-original
|
||||
observations,5 managed/14 Python checks plus25 movement/15 gadget groups pass.
|
||||
- [ ] Grappler next: complete retained REA/source findings from
|
||||
- [x] Grappler next: complete retained REA/source findings from
|
||||
artifacts/grappler-{ray,motion,resources}/, close body/camera/helper contracts
|
||||
and compare original components before enabling boundedVR08. Investigators
|
||||
reached usage limits; all file ownership returned to primary.
|
||||
|
||||
+7
-1
@@ -23,6 +23,8 @@ for rid in linux-x64 win-x64; do
|
||||
cp -a artifacts/extracted/baseball/. "$out/scenes/baseball/"
|
||||
mkdir -p "$out/scenes/rocketship"
|
||||
cp -a artifacts/extracted/rocketship/. "$out/scenes/rocketship/"
|
||||
mkdir -p "$out/scenes/grappler"
|
||||
cp -a artifacts/extracted/grappler/. "$out/scenes/grappler/"
|
||||
mkdir -p "$out/scenes/effects"
|
||||
cp -a artifacts/extracted/effects/. "$out/scenes/effects/"
|
||||
cp artifacts/extracted/scene-catalog.json "$out/scenes/scene-catalog.json"
|
||||
@@ -47,7 +49,7 @@ for rid in linux-x64 win-x64; do
|
||||
printf 'packaged_utc=%s\n' "$(date -u +%FT%TZ)"
|
||||
} > "$out/BUILD-INFO.txt"
|
||||
cat > "$out/README.md" <<'NOTES'
|
||||
# Neutron lab story, gadgets and jet pack checkpoint
|
||||
# Neutron lab story and gadgets checkpoint
|
||||
|
||||
Linux: run ./launch-scene.sh. Windows: run launch-scene.cmd.
|
||||
Append --headless --frames 2 to render without a window, or --screenshot lab.ppm
|
||||
@@ -60,6 +62,10 @@ F1 opens debug tools: arrows navigate/change, Enter applies, Tab switches pages,
|
||||
F1/Escape closes. General/Player/Systems pages cover implemented runtime controls.
|
||||
The menu pauses gameplay/audio and provides diagnostics, camera/cutscene controls,
|
||||
energy/jetpack/task changes, level/start selection, reset and Force Control toggle.
|
||||
F1 -> Player -> Give/Select Grappler equips it in VR08. Its Practice tile opens
|
||||
that tutorial. Aim at a surface until the target appears; hold Enter/Ctrl/left
|
||||
mouse to attach/reel, arrows steer, release fire and jump to detach. Tab/Space
|
||||
unequips. Grappler is currently limited to VR08.
|
||||
Player/Systems add input ordering, jetpack availability, objective/practice, camera
|
||||
obstruction, audio category mutes and debug checkpoint save/load. Checkpoints save
|
||||
level/start/progression, not live position; see docs/debug-menu.md.
|
||||
|
||||
@@ -21,6 +21,7 @@ dotnet run --project tests/GamePort.BaseballTests
|
||||
dotnet run --project tests/GamePort.BaseballVisualTests
|
||||
dotnet run --project tests/GamePort.RocketFlightTests
|
||||
dotnet run --project tests/GamePort.RocketshipTests
|
||||
dotnet run --project tests/GamePort.GrapplerLiveTests
|
||||
dotnet run --project tests/GamePort.GrapplerTests
|
||||
dotnet run --project tests/GamePort.HeadingTests
|
||||
dotnet run --project tests/GamePort.BlendTests
|
||||
@@ -65,6 +66,7 @@ dotnet run --no-build -- --headless --scene artifacts/extracted/VR04/scene.json
|
||||
dotnet run --no-build -- --headless --scene artifacts/extracted/VR03/scene.json --level gam/VR03.gam --smoke-invisible --screenshot artifacts/test-invisible.ppm
|
||||
dotnet run --no-build -- --headless --scene artifacts/extracted/VR01/scene.json --level gam/VR01.gam --smoke-bubble --screenshot artifacts/test-bubble.ppm
|
||||
dotnet run --no-build -- --headless --scene artifacts/extracted/VR07/scene.json --level gam/VR07.gam --smoke-baseball --screenshot artifacts/test-baseball.ppm
|
||||
dotnet run --no-build -- --headless --scene artifacts/extracted/VR08/scene.json --level gam/VR08.gam --smoke-grappler --screenshot artifacts/test-grappler.ppm
|
||||
dotnet run --no-build -- --headless --scene artifacts/extracted/VR02/scene.json --level gam/VR02.gam --smoke-rocketship --screenshot artifacts/test-rocketship.ppm
|
||||
dotnet run --no-build -- --headless --skip-intro --write-save artifacts/test-checkpoint.tsk
|
||||
dotnet run --no-build -- --headless --load-save artifacts/test-checkpoint.tsk --skip-intro
|
||||
@@ -82,6 +84,7 @@ SDL_AUDIODRIVER=dummy dotnet run --no-build -- --scene-audio-smoke artifacts/ext
|
||||
SDL_AUDIODRIVER=dummy dotnet run --no-build -- --cutscene-audio-smoke artifacts/extracted/level1b/entities/entities.json
|
||||
python3 tools/recon/inventory.py ../Original --verify docs/original-manifest.json
|
||||
if [[ "${NEUTRON_WINDOW_TEST:-0}" == 1 ]]; then
|
||||
dotnet run --no-build -- --scene artifacts/extracted/VR08/scene.json --level gam/VR08.gam --smoke-grappler --width 1920 --height 1080 --screenshot artifacts/test-grappler-window.ppm
|
||||
dotnet run --no-build -- --scene artifacts/extracted/VR02/scene.json --level gam/VR02.gam --smoke-rocketship --width 1920 --height 1080 --screenshot artifacts/test-rocketship-window.ppm
|
||||
dotnet run --no-build -- --scene artifacts/extracted/VR07/scene.json --level gam/VR07.gam --smoke-baseball --width 1920 --height 1080 --screenshot artifacts/test-baseball-window.ppm
|
||||
dotnet run --no-build -- --scene artifacts/extracted/VR01/scene.json --level gam/VR01.gam --smoke-bubble --width 1920 --height 1080 --screenshot artifacts/test-bubble-window.ppm
|
||||
|
||||
@@ -8,7 +8,7 @@ public sealed record DebugScene(string LevelFile, string Code, string[] Starts);
|
||||
public enum DebugAction { None, Resume, Camera, SkipCutscene, RefillEnergy, GiveJetpack, ApplySceneTask, LoadScene, Reset, ForceControl, ToggleOverlay,
|
||||
Noclip, NoclipSpeed, StopMotion, ShowObjective, ReturnNoclipEntry, LevelAvailability, InputOrder, ApplyJetpackState,
|
||||
CameraObstruction, MuteMusic, MuteSpeech, MuteEffects, RestartMusic, StopEffects, SaveCheckpoint, LoadCheckpoint, Practice,
|
||||
GiveInvisible, UnequipGadget, GiveBubble, GiveBaseball, GiveAllGadgets, GiveRocketship }
|
||||
GiveInvisible, UnequipGadget, GiveBubble, GiveBaseball, GiveAllGadgets, GiveRocketship, GiveGrappler }
|
||||
public sealed record DebugMenuView(string[] Lines, int SelectedLine);
|
||||
public sealed record DebugStatus(string Level, string Start, Vector3 Root, float Yaw, float Speed,
|
||||
bool Grounded, float Energy, int Score, int SceneTask, string Cutscene, bool Controlled,
|
||||
@@ -31,6 +31,7 @@ public sealed record DebugSystems
|
||||
public bool Targetable { get; init; } = true;
|
||||
public string BubblePhase { get; init; } = "OFF";
|
||||
public string BaseballState { get; init; } = "OFF";
|
||||
public string? GrapplerState { get; init; }
|
||||
public string? RocketshipState { get; init; }
|
||||
public float BodyRadius { get; init; } = 60;
|
||||
public float BodyFactor { get; init; } = 1.265f;
|
||||
@@ -57,7 +58,7 @@ public sealed class DebugMenu
|
||||
public const int ItemCount = 12;
|
||||
public const int PageCount = 3;
|
||||
public int Page { get; private set; }
|
||||
public int PageItems => Page switch { 1 => 16, 2 => 9, _ => ItemCount };
|
||||
public int PageItems => Page switch { 1 => 17, 2 => 9, _ => ItemCount };
|
||||
private static readonly float[] FlySpeeds = [300, 600, 1200, 2400];
|
||||
private int flySpeedIndex = 1, jetpackStateIndex = 1;
|
||||
private static readonly int[] JetpackStates = [0, 1, 4];
|
||||
@@ -121,7 +122,7 @@ public sealed class DebugMenu
|
||||
5 => DebugAction.LevelAvailability, 6 => DebugAction.InputOrder,
|
||||
8 => DebugAction.ApplyJetpackState, 9 => DebugAction.RefillEnergy,
|
||||
10 => DebugAction.GiveInvisible, 11 => DebugAction.UnequipGadget, 12 => DebugAction.GiveBubble,
|
||||
13 => DebugAction.GiveBaseball, 14 => DebugAction.GiveAllGadgets,15=>DebugAction.GiveRocketship, _ => DebugAction.None
|
||||
13 => DebugAction.GiveBaseball, 14 => DebugAction.GiveAllGadgets,15=>DebugAction.GiveRocketship,16=>DebugAction.GiveGrappler, _ => DebugAction.None
|
||||
};
|
||||
if (Page == 2) return Selected switch
|
||||
{
|
||||
@@ -161,7 +162,7 @@ public sealed class DebugMenu
|
||||
$"OBJECTIVE {system.Objective} TIME {F(system.ObjectiveTime)} GADGET STATE {system.JetpackAvailability}",
|
||||
$"INVISIBLE {F(system.InvisibleRemaining)} RECHARGE {F(system.InvisibleRecharge)}/7 TARGETABLE {system.Targetable}",
|
||||
$"BUBBLE {system.BubblePhase} BODY R {F(system.BodyRadius)} FACTOR {system.BodyFactor.ToString("0.000",c)}",
|
||||
system.RocketshipState is{} rocket?$"ROCKET {rocket}":$"BASEBALL {system.BaseballState}"];
|
||||
system.GrapplerState is{} grapple?$"GRAPPLER {grapple}":system.RocketshipState is{} rocket?$"ROCKET {rocket}":$"BASEBALL {system.BaseballState}"];
|
||||
string[] items = Page == 1 ? [
|
||||
$"NOCLIP (F3): {system.Noclip} (ENTER TOGGLE)",
|
||||
$"FLY SPEED: {F(FlySpeed)} LIVE {F(system.NoclipSpeed)} (ENTER APPLIES)", "STOP MOTION / CLEAR QUEUED JUMP", "SHOW CURRENT OBJECTIVE",
|
||||
@@ -169,11 +170,11 @@ public sealed class DebugMenu
|
||||
$"INPUT AFTER PLAYER: {system.InputAfterPlayer} (TOGGLE)",
|
||||
$"JET PACK STATE: {JetpackState} (0 NONE / 1 OWNED / 4 DISABLED)", "APPLY JET PACK STATE", "REFILL ENERGY TO 100",
|
||||
"GIVE / SELECT INVISIBLE", "UNEQUIP CURRENT GADGET", "GIVE / SELECT BUBBLE", "GIVE / SELECT BASEBALL",
|
||||
"GIVE ALL GADGETS", "GIVE / SELECT ROCKETSHIP (VR02)"] : [
|
||||
"GIVE ALL GADGETS", "GIVE / SELECT ROCKETSHIP (VR02)", "GIVE / SELECT GRAPPLER (VR08)"] : [
|
||||
$"STATIC CAMERA OBSTRUCTION: {(system.CameraObstruction?.ToString() ?? "UNAVAILABLE")}",
|
||||
$"MUTE MUSIC: {system.MusicMuted}", $"MUTE SPEECH: {system.SpeechMuted}", $"MUTE EFFECTS: {system.EffectsMuted}",
|
||||
"RESTART SELECTED MUSIC", "STOP ALL EFFECTS / LOOPS", "SAVE DEBUG CHECKPOINT", "LOAD DEBUG CHECKPOINT", "SHOW JET PACK PRACTICE PROMPT"];
|
||||
return new([.. header, .. items, "", "TAB NEXT PAGE UP/DOWN SELECT ENTER APPLY",
|
||||
return new([.. header, .. items, "TAB NEXT PAGE UP/DOWN SELECT ENTER APPLY",
|
||||
Page == 1 ? "FLY: WASD/ARROWS SPACE/E UP CTRL/Q DOWN SHIFT FAST" : "CHECKPOINT: DEBUG-CHECKPOINT.TSK BESIDE EXECUTABLE",
|
||||
"F1 / ESC CLOSE - ACTIONS USE EXISTING SYSTEMS", Message], header.Length + Selected);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using GamePort.Game;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>Input replay on the authored VR08 start. Extra ordinary ticks reuse
|
||||
/// received input; no root, velocity, rope scalar or timer is seeded.</summary>
|
||||
public sealed class GrapplerSmoke
|
||||
{
|
||||
private readonly LabSimulation player;
|
||||
private readonly PlayerSceneBinding binding;
|
||||
private readonly SceneDirector director;
|
||||
private readonly SceneInteractions interactions;
|
||||
private GrapplerGadget G=>player.Grappler!;
|
||||
private PlayerInput last;
|
||||
private int extra;
|
||||
private float attachedLength,first;
|
||||
private readonly bool[] checks=new bool[9];
|
||||
public GrapplerSmoke(LabSimulation player,PlayerSceneBinding binding,SceneDirector director,SceneInteractions interactions)
|
||||
{
|
||||
this.player=player;this.binding=binding;this.director=director;this.interactions=interactions;
|
||||
interactions.Inventory.SetState(0,7,1);interactions.Inventory.SelectGadget(7);
|
||||
}
|
||||
public void BeforeFrame(int frame,Action<uint,bool> key,bool headless)
|
||||
{
|
||||
if(frame==0&&!headless)key(80,true);
|
||||
if(frame==1)
|
||||
{
|
||||
for(int i=0;i<360&&!G.CursorVisible;i++)Advance(1);
|
||||
if(!headless){key(80,false);key(224,true);}
|
||||
}
|
||||
if(frame==2)Advance(6);
|
||||
if(frame==3&&!headless){key(224,false);key(82,true);}
|
||||
if(frame==4){Advance(15);if(!headless){key(82,false);key(225,true);}}
|
||||
if(frame==5)
|
||||
{
|
||||
if(!headless){key(225,false);key(224,true);}
|
||||
interactions.Inventory.SelectGadget(7);
|
||||
}
|
||||
if(frame==6)
|
||||
{
|
||||
if(!headless)key(224,false);
|
||||
director.Trigger("gr");
|
||||
}
|
||||
if(frame==7)
|
||||
{
|
||||
director.Skip();interactions.Inventory.SelectGadget(7);
|
||||
if(headless)player.SetNoclip(true);else key(60,true);
|
||||
}
|
||||
if(frame==8)player.Reset();
|
||||
}
|
||||
public void Received(PlayerInput input)=>last=input;
|
||||
private void Advance(int count)
|
||||
{
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
binding.Step(last);interactions.UpdateEnergy(player.Energy);director.Step(FixedStepClock.Step);extra++;
|
||||
}
|
||||
}
|
||||
public void AfterFrame(int frame)
|
||||
{
|
||||
if(frame==0)checks[0]=G.Equipped&&player.GadgetMode==7;
|
||||
if(frame==1){checks[1]=G.Attached&&G.Attachments==1&&G.LoopPlaying;attachedLength=G.Memory.Length;first=G.Memory.FirstLength;}
|
||||
if(frame==2)checks[2]=G.Attached&&G.SwingPose&&G.Memory.Length<attachedLength&&player.PhysicsSteps>6;
|
||||
if(frame==3)checks[3]=G.Attached&&G.SwingPose&&!G.LoopPlaying;
|
||||
if(frame==4)checks[4]=!G.Attached&&!G.SwingPose&&!G.LoopPlaying&&G.Memory.FirstLength==first;
|
||||
if(frame==5)checks[5]=G.Attached&&G.Attachments==2&&G.Memory.FirstLength==first;
|
||||
if(frame==6)checks[6]=!G.Equipped&&!G.Attached&&!G.LoopPlaying&&player.GadgetMode==-1;
|
||||
if(frame==7)checks[7]=player.Noclip&&!G.Equipped&&interactions.Inventory.SelectedGadget==-1;
|
||||
if(frame==8)checks[8]=!player.Noclip&&!G.Attached&&G.Memory.FirstLength==0;
|
||||
}
|
||||
public bool Passed=>checks.All(v=>v);
|
||||
public string Report=>$"Grappler fixture: equip={checks[0]}, attach={checks[1]}, reel/swing={checks[2]}, release loop={checks[3]}, jump detach={checks[4]}, reattach/first={checks[5]}, cutscene={checks[6]}, noclip={checks[7]}, reset={checks[8]}, extra ordinary ticks={extra}.";
|
||||
public static PlayerInput Input(int frame)=>new(frame==3,false,frame==0,false,frame==4,Fire:frame is 1 or 2 or 5);
|
||||
public static string? StageName(int frame)=>frame switch{0=>"equip",1=>"attach",2=>"swing",3=>"release-loop",4=>"detach",5=>"reattach",6=>"cutscene",7=>"noclip",8=>"reset",_=>null};
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System.Numerics;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>HIROPE/HISWING use source pivots; target canvas8 is a centered
|
||||
/// 110x110 alpha quad. Billboarding uses the existing port sprite bridge.</summary>
|
||||
public sealed class GrapplerVisuals
|
||||
{
|
||||
private sealed record Clip(MorphAnimation Animation,int Offset,MeshDraw Draw);
|
||||
private readonly Clip rope,swing;
|
||||
private readonly int cursorOffset;
|
||||
private readonly MeshDraw cursor;
|
||||
public Mesh Mesh {get;}
|
||||
|
||||
public GrapplerVisuals(Mesh combined,string preparedRoot)
|
||||
{
|
||||
var root=Path.GetFullPath(Path.Combine(preparedRoot,"grappler"));
|
||||
using var doc=JsonDocument.Parse(File.ReadAllBytes(Path.Combine(root,"grappler.json")));
|
||||
if(doc.RootElement.GetProperty("schema").GetInt32()!=1)throw new InvalidDataException("Unknown Grappler resources");
|
||||
string Resource(string path)
|
||||
{
|
||||
var full=Path.GetFullPath(Path.Combine(root,path));
|
||||
if(!full.StartsWith(root+Path.DirectorySeparatorChar,StringComparison.Ordinal))throw new InvalidDataException("Grappler resource escapes root");
|
||||
return full;
|
||||
}
|
||||
Clip Load(string key)
|
||||
{
|
||||
var animation=new MorphAnimation(Resource(doc.RootElement.GetProperty(key).GetString()!));
|
||||
var offset=combined.Vertices.Length;var id=int.MinValue;
|
||||
while(combined.Textures.ContainsKey(id))id++;
|
||||
combined=animation.AppendTo(combined,id);var draw=combined.Draws[^1];draw.Visible=false;
|
||||
return new(animation,offset,draw);
|
||||
}
|
||||
rope=Load("ropeAnimation");swing=Load("swingAnimation");
|
||||
var entry=doc.RootElement.GetProperty("cursor");
|
||||
var rgba=File.ReadAllBytes(Resource(entry.GetProperty("path").GetString()!));
|
||||
if(entry.GetProperty("width").GetInt32()!=64||entry.GetProperty("height").GetInt32()!=64
|
||||
||rgba.Length!=64*64*4||Convert.ToHexStringLower(SHA256.HashData(rgba))!="8d31014cb9b9661ebed902c864bf740f562460e74da3f6b86ed3d2be4d10f0ec")
|
||||
throw new InvalidDataException("Grappler cursor differs from source canvas8");
|
||||
cursorOffset=combined.Vertices.Length;var firstIndex=(uint)combined.Indices.Length;var textures=new Dictionary<int,PngImage>(combined.Textures);
|
||||
var cursorId=int.MinValue;while(textures.ContainsKey(cursorId))cursorId++;
|
||||
textures.Add(cursorId,new(64,64,rgba));
|
||||
var vertices=combined.Vertices.ToList();
|
||||
vertices.AddRange([new(Vector3.Zero,new(0,1),Vector3.One),new(Vector3.Zero,new(1,1),Vector3.One),
|
||||
new(Vector3.Zero,new(1,0),Vector3.One),new(Vector3.Zero,new(0,0),Vector3.One)]);
|
||||
var first=(uint)cursorOffset;var indices=combined.Indices.ToList();
|
||||
indices.AddRange([first,first+1,first+2,first,first+2,first+3]);
|
||||
cursor=new(firstIndex,6,cursorId){Visible=false,Blend=MeshBlend.Alpha};
|
||||
Mesh=new(vertices.ToArray(),indices.ToArray()){Textures=textures,HasExplicitDraws=true,Draws=[..combined.Draws,cursor],
|
||||
CollisionPolygons=combined.CollisionPolygons,HasCollisionMaterialIds=combined.HasCollisionMaterialIds};
|
||||
}
|
||||
|
||||
public void Update(Mesh destination,GrapplerGadget gadget,Vector3 actorRoot,Vector3 rotation,double time,
|
||||
PlayerAppearance appearance,Vector3 eye,Vector3 target)
|
||||
{
|
||||
rope.Draw.Visible=gadget.Attached;swing.Draw.Visible=gadget.SwingPose;cursor.Visible=gadget.Equipped&&gadget.CursorVisible;
|
||||
if(rope.Draw.Visible)rope.Animation.Sample(0,destination.Vertices.AsSpan(rope.Offset,rope.Animation.Base.Vertices.Length),
|
||||
RocketOrientation.Model(gadget.RopeRotation,gadget.RopeRoot,new(1,1,gadget.Memory.RopeScaleZ)));
|
||||
if(swing.Draw.Visible)
|
||||
{
|
||||
swing.Animation.Sample(time,destination.Vertices.AsSpan(swing.Offset,swing.Animation.Base.Vertices.Length),
|
||||
RocketOrientation.Model(rotation,actorRoot,Vector3.One));
|
||||
PlayerGadgetMaterial.Apply(swing.Draw,appearance);var c=appearance.Color;
|
||||
for(var i=0;i<swing.Animation.Base.Vertices.Length;i++)destination.Vertices[swing.Offset+i].Color*=new Vector3(c.X,c.Y,c.Z);
|
||||
}
|
||||
if(!cursor.Visible)return;
|
||||
var direction=target-eye;direction=direction.LengthSquared()<.000001f?Vector3.UnitZ:Vector3.Normalize(direction);
|
||||
var right=Vector3.Cross(Vector3.UnitY,direction);right=right.LengthSquared()<.000001f?Vector3.UnitX:Vector3.Normalize(right);
|
||||
var up=Vector3.Normalize(Vector3.Cross(direction,right));var x=right*55;var y=up*55;var center=gadget.CursorPosition;
|
||||
destination.Vertices[cursorOffset]=new(center-x-y,new(0,1),Vector3.One);
|
||||
destination.Vertices[cursorOffset+1]=new(center+x-y,new(1,1),Vector3.One);
|
||||
destination.Vertices[cursorOffset+2]=new(center+x+y,new(1,0),Vector3.One);
|
||||
destination.Vertices[cursorOffset+3]=new(center-x+y,new(0,0),Vector3.One);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
public readonly record struct GrapplerCameraLocals(Vector3 Eye,Vector3 Look,Vector3 Gains)
|
||||
{
|
||||
public static GrapplerCameraLocals Default=>new(new(0,200,-350),new(0,80,0),new(1.6f,1,1.6f));
|
||||
public GrapplerCameraLocals Equip()=>this with{Eye=new(0,50,-350),Look=new(0,150,80)};
|
||||
public GrapplerCameraLocals Attach()=>this with{Eye=new(Eye.X,400,-650),Gains=new(.8f,1,.8f)};
|
||||
public GrapplerCameraLocals Detach()=>new(new(0,50,-350),new(0,130,100),new(1.6f,1,1.6f));
|
||||
}
|
||||
public readonly record struct GrapplerCameraResult(Vector3 Eye,Vector3 Target,Vector3 Look,Vector3 DesiredEye,float RayGain);
|
||||
|
||||
/// <summary>Ordinary438BC0/439900 follow branches. Excludes flags828/851 and
|
||||
/// Bubble mode2; aim is quantized from look minus OLD shared eye.</summary>
|
||||
public static class GrapplerCamera
|
||||
{
|
||||
public static GrapplerCameraResult Follow(GrapplerCameraLocals locals,Vector3 root,Vector3 rotation,
|
||||
float turnRate,int movementMode,Vector3 oldEye,float seconds,Func<Vector3,Vector3,SupportHit?>? ray)
|
||||
{
|
||||
GrapplerMotion.Time(seconds);GrapplerMotion.Finite(root);GrapplerMotion.Finite(rotation);GrapplerMotion.Finite(oldEye);
|
||||
if(movementMode==2)throw new NotSupportedException("Grappler camera excludes Bubble mode2");
|
||||
var eyeLocal=locals.Eye;var lookLocal=locals.Look;var eyeRotation=rotation;Vector3 gains;
|
||||
if(movementMode==0)
|
||||
{eyeLocal.Y-=20;lookLocal.Y=(float)(lookLocal.Y+1.9*10);gains=locals.Gains+new Vector3(0,.2f,0);}
|
||||
else {eyeRotation=new(0,RocketOrientation.AddAxis(rotation.Y,turnRate),rotation.Z);gains=new(1.2f,2,1.2f);}
|
||||
var desired=root+RocketOrientation.Rotate(eyeLocal,eyeRotation);
|
||||
var look=root+RocketOrientation.Rotate(lookLocal,rotation);float gain=1;
|
||||
if(ray?.Invoke(look,desired) is{} hit){desired=look-(look-hit.Position)*.75f;gain=1.5f;}
|
||||
var eye=oldEye+(desired-oldEye)*gains*(gain*seconds);
|
||||
var(pitch,yaw)=OriginalHeading.Angles(look-oldEye);
|
||||
var direction=RocketOrientation.Rotate(Vector3.UnitZ,new(pitch*.02197265625f,yaw*.02197265625f,0));
|
||||
return new(eye,eye+direction*200,look,desired,gain);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using System.Numerics;
|
||||
using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>Process globals owned by retained Jimmy; not TSK fields.</summary>
|
||||
public sealed class GrapplerMemory
|
||||
{
|
||||
public Vector3 Anchor;
|
||||
public float FirstLength,Length,ReelTarget;
|
||||
public float RopeScaleZ=1;
|
||||
public GrapplerSwing Swing;
|
||||
public void Clear(){Anchor=default;FirstLength=Length=ReelTarget=0;RopeScaleZ=1;Swing=default;}
|
||||
}
|
||||
public readonly record struct GrapplerMove(Vector3 Root,Vector3 Velocity);
|
||||
public readonly record struct GrapplerInputResult(Vector3 Root,Vector3 Rotation,Vector3 Velocity,bool NewAttachment,bool EndsActiveInput=false);
|
||||
|
||||
/// <summary>Owned raw7 controller, bounded to VR08. Body and input phases are
|
||||
/// placed by LabSimulation; shared globals survive reconstructed scene loads.</summary>
|
||||
public sealed class GrapplerGadget : IDisposable
|
||||
{
|
||||
private readonly GrapplerRay ray;
|
||||
public GrapplerMemory Memory {get;}
|
||||
public GrapplerCameraLocals Camera {get;private set;}=GrapplerCameraLocals.Default;
|
||||
public bool Equipped {get;private set;}
|
||||
public bool Attached {get;private set;}
|
||||
public bool SwingPose {get;private set;}
|
||||
public bool CursorVisible {get;private set;}
|
||||
public bool LoopPlaying {get;private set;}
|
||||
public Vector3 CursorPosition {get;private set;}
|
||||
public Vector3 RopeRoot {get;private set;}
|
||||
public Vector3 RopeRotation {get;private set;}=new(0,0,180);
|
||||
public int Attachments {get;private set;}
|
||||
public int Detachments {get;private set;}
|
||||
public int Contacts {get;private set;}
|
||||
public event Action<bool>? EquippedChanged;
|
||||
public event Action? Detached;
|
||||
public event Action<int,bool>? Sound;
|
||||
public event Action? LoopStopped;
|
||||
|
||||
public GrapplerGadget(Mesh world,string level,GrapplerMemory? memory=null)
|
||||
{ray=new(world,level);Memory=memory??new();}
|
||||
|
||||
public void Equip()
|
||||
{
|
||||
if(Equipped)Release();
|
||||
Equipped=true;Camera=Camera.Equip();EquippedChanged?.Invoke(true);
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
Detach();CursorVisible=false;Camera=GrapplerCameraLocals.Default;
|
||||
if(Equipped){Equipped=false;EquippedChanged?.Invoke(false);}
|
||||
SetLoop(false);
|
||||
}
|
||||
public void Reset()
|
||||
{Release();Memory.Clear();Attachments=Detachments=Contacts=0;RopeRoot=default;RopeRotation=new(0,0,180);}
|
||||
public void Detach()
|
||||
{
|
||||
if(!Attached)return;
|
||||
Attached=SwingPose=false;Detachments++;
|
||||
Memory.Swing=Memory.Swing with{X=Memory.Swing.X*.96f,Z=Memory.Swing.Z*.96f};
|
||||
Camera=Camera.Detach();SetLoop(false);Detached?.Invoke();
|
||||
}
|
||||
public void Contact()
|
||||
{
|
||||
if(!Attached)return;
|
||||
Contacts++;var response=GrapplerGeometry.Contact(Memory.Swing);Memory.Swing=response.Swing;
|
||||
if(response.Detach)Detach();
|
||||
}
|
||||
public GrapplerInputResult StepInput(Vector3 root,Vector3 rotation,Vector3 velocity,PlayerInput input,
|
||||
float seconds,Func<Vector3,GrapplerMove> move)
|
||||
{
|
||||
if(!Equipped)return new(root,rotation,velocity,false);
|
||||
SetLoop(Attached&&input.Fire);
|
||||
Memory.Length=GrapplerMotion.FastReel(Memory.Length,Memory.ReelTarget,seconds);
|
||||
if(GrapplerMotion.JumpDetaches(input.Jump,input.Fire,Attached))
|
||||
{Detach();return new(root,rotation,Vector3.Zero,false);}
|
||||
if(Attached)
|
||||
{
|
||||
rotation=new(0,rotation.Y,0);SwingPose=true;
|
||||
var constraint=GrapplerGeometry.Constrain(root,Memory.Anchor,Memory.Swing,Memory.Length,seconds);
|
||||
var body=move(constraint.DesiredRoot);root=body.Root;velocity=body.Velocity with{Y=0};
|
||||
//The callback can detach/clear scalars, but this source tail still runs.
|
||||
Memory.Swing=GrapplerMotion.Swing(Memory.Swing,seconds,constraint.Offset.X,constraint.Offset.Z,Memory.Length);
|
||||
var(pitch,yaw)=OriginalHeading.Angles(constraint.Offset);
|
||||
RopeRotation=new(pitch*.02197265625f,yaw*.02197265625f,0);
|
||||
RopeRoot=constraint.DesiredRoot+Vector3.UnitY*116;
|
||||
}
|
||||
var aim=ray.Aim(root,rotation,input.Fire,input.GrapplerEnter,Memory.Length,seconds);
|
||||
Memory.Length=aim.Length;CursorVisible=aim.CursorVisible;CursorPosition=aim.CursorPosition;
|
||||
if(aim.EndsActiveInput||!input.Fire)return new(root,rotation,velocity,false,aim.EndsActiveInput);
|
||||
if(Attached)
|
||||
{
|
||||
bool reeling=Memory.Length>250;
|
||||
Memory.Length=GrapplerMotion.HeldReel(Memory.Length,seconds);SetLoop(reeling);
|
||||
return new(root,rotation,velocity,false,true);
|
||||
}
|
||||
//426A70 performs a fresh query; a cursor position is not an anchor cache.
|
||||
if(ray.Trace(root,rotation) is not{} hit)return new(root,rotation,velocity,false,true);
|
||||
var attached=GrapplerMotion.Attach(root,hit.Hit.Position,velocity,Memory.FirstLength);
|
||||
Memory.Anchor=hit.Hit.Position;Memory.Length=attached.Length;Memory.FirstLength=attached.InitialLength;
|
||||
if(attached.RopeScaleZ is{} scale)Memory.RopeScaleZ=scale;
|
||||
Memory.ReelTarget=attached.FastReelTarget;Memory.Swing=default;
|
||||
Attached=true;Attachments++;Camera=Camera.Attach();
|
||||
Sound?.Invoke(31,false);SetLoop(false);SetLoop(true);
|
||||
return new(root,rotation,attached.Velocity,true,true);
|
||||
}
|
||||
public void Dispose()=>Release();
|
||||
|
||||
private void SetLoop(bool play)
|
||||
{
|
||||
if(LoopPlaying==play)return;LoopPlaying=play;
|
||||
if(play)Sound?.Invoke(34,true);else LoopStopped?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace GamePort.Game;
|
||||
|
||||
public readonly record struct PlayerInput(bool Forward, bool Backward, bool Left, bool Right, bool Jump,
|
||||
bool Rise = false, bool Descend = false, bool StrafeLeft = false, bool StrafeRight = false, bool Fast = false, bool Fire = false,
|
||||
bool RocketTurn = false, bool RocketRoll = false, bool RocketMouseRise = false);
|
||||
public enum PlayerPose { Idle, Run, Backpedal, Jump, Fall, Fly, Shoot }
|
||||
bool RocketTurn = false, bool RocketRoll = false, bool RocketMouseRise = false,bool GrapplerEnter=false);
|
||||
public enum PlayerPose { Idle, Run, Backpedal, Jump, Fall, Fly, Shoot, Swing }
|
||||
|
||||
/// <summary>
|
||||
/// Walking, airborne steering and jetpack checkpoint. Recovered arithmetic is described in
|
||||
@@ -35,6 +35,8 @@ public sealed class LabSimulation
|
||||
private Vector3 noclipEntry;
|
||||
private float noclipEntryYaw;
|
||||
private int gadgetMode = -1;
|
||||
private Vector3? grapplerCameraTarget;
|
||||
public GrapplerGadget? Grappler {get;private set;}
|
||||
public bool Noclip { get; private set; }
|
||||
public bool HasNoclipEntry { get; private set; }
|
||||
public float NoclipSpeed { get; set; } = 600;
|
||||
@@ -61,6 +63,7 @@ public sealed class LabSimulation
|
||||
if (gadgetMode == 0) ReleaseBubble();
|
||||
if (gadgetMode == 2) Invisible.Release();
|
||||
if (gadgetMode == 6) Baseball.Release();
|
||||
if (gadgetMode == 7) Grappler?.Release();
|
||||
gadgetMode = -1;
|
||||
if (value == 0)
|
||||
{
|
||||
@@ -74,6 +77,11 @@ public sealed class LabSimulation
|
||||
}
|
||||
if (value == 2 && !Invisible.Equip(Energy, IgnoresGadgetEnergy)) return;
|
||||
if (value == 6) Baseball.Equip();
|
||||
if(value==7)
|
||||
{
|
||||
if(Grappler==null)return;
|
||||
Grappler.Equip();
|
||||
}
|
||||
gadgetMode = value;
|
||||
}
|
||||
}
|
||||
@@ -110,6 +118,7 @@ public sealed class LabSimulation
|
||||
public float TurnRate { get; private set; }
|
||||
public bool Grounded { get; private set; }
|
||||
public PlayerPose Pose => Noclip ? Velocity.LengthSquared() > 0 ? PlayerPose.Fly : PlayerPose.Idle
|
||||
: Grappler?.SwingPose==true ? PlayerPose.Swing
|
||||
: GadgetMode == 0 ? bubblePose
|
||||
: pendingImpulse.Y > 0 ? PlayerPose.Jump
|
||||
: Grounded ? Shooting ? PlayerPose.Shoot : Speed < -1 ? PlayerPose.Backpedal : Speed > 1 ? PlayerPose.Run : PlayerPose.Idle
|
||||
@@ -128,7 +137,7 @@ public sealed class LabSimulation
|
||||
public Func<Vector3, Vector3, float, Vector3>? DynamicRootResolver { get; set; }
|
||||
public Vector3 ActorRoot => Position + Vector3.UnitY * rootHeight;
|
||||
public Vector3 CameraEye { get; private set; }
|
||||
public Vector3 CameraTarget => ActorRoot + new Vector3(0, 80 + 1.9f * Baseball.CameraPitch, 0);
|
||||
public Vector3 CameraTarget => grapplerCameraTarget??ActorRoot + new Vector3(0, 80 + 1.9f * Baseball.CameraPitch, 0);
|
||||
public Matrix4x4 Model => Matrix4x4.CreateRotationZ(-(TracksBubbleOrientation?Roll:0) * MathF.PI / 180)
|
||||
* Matrix4x4.CreateRotationX(-(TracksBubbleOrientation?Pitch:0) * MathF.PI / 180) * Matrix4x4.CreateRotationY(-Yaw * MathF.PI / 180)
|
||||
* Matrix4x4.CreateTranslation(Position - new Vector3(0, modelMinimumY, 0));
|
||||
@@ -163,6 +172,8 @@ public sealed class LabSimulation
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if(gadgetMode==7){GadgetMode=-1;DefaultGadgetRequested?.Invoke();}
|
||||
Grappler?.Reset();grapplerCameraTarget=null;
|
||||
if (gadgetMode == 0) { GadgetMode=-1; DefaultGadgetRequested?.Invoke(); }
|
||||
if (gadgetMode == 2) gadgetMode = -1;
|
||||
Invisible.Reset();
|
||||
@@ -282,6 +293,25 @@ public sealed class LabSimulation
|
||||
AdjustEnergy(-1);ScoreChanged?.Invoke(-1);CancelPoweredFlight();
|
||||
}
|
||||
|
||||
public void EnableGrappler(Mesh world,GrapplerMemory memory)
|
||||
{
|
||||
if(LevelCode!="VR08"||originalBody==null)throw new NotSupportedException("Live Grappler requires the VR08 source body");
|
||||
Grappler=new(world,LevelCode,memory);
|
||||
Grappler.Detached+=()=>{Velocity=Vector3.Zero;forceFall=true;};
|
||||
}
|
||||
|
||||
private GrapplerMove MoveGrappler(Vector3 desired)
|
||||
{
|
||||
var moved=originalBody!.MoveAttached(ActorRoot,desired,InteractionRadius);
|
||||
if(moved.CallbackPolygon is{} contact)
|
||||
{
|
||||
if(contact.StoredNormal.Y<=-.7f)
|
||||
{if(Velocity.Y>0)Velocity=Velocity with{Y=0};if(extraAirAcceleration>0)extraAirAcceleration=0;}
|
||||
else {WallHits++;Grappler!.Contact();}
|
||||
}
|
||||
return new(moved.Position,Velocity);
|
||||
}
|
||||
|
||||
public void StopForPrimaryFire() => Speed = 0;
|
||||
public void SetShooting(bool shooting) => Shooting = shooting;
|
||||
public void AdjustEnergy(float delta) => energy.Adjust(delta, LevelCode, id => EnergySound?.Invoke(id));
|
||||
@@ -343,6 +373,7 @@ public sealed class LabSimulation
|
||||
if (enabled == Noclip) return false;
|
||||
if (enabled)
|
||||
{
|
||||
if(gadgetMode==7){GadgetMode=-1;DefaultGadgetRequested?.Invoke();}
|
||||
if (gadgetMode==0) { GadgetMode=-1; DefaultGadgetRequested?.Invoke(); }
|
||||
noclipEntry = Position; noclipEntryYaw = Yaw; HasNoclipEntry = true;
|
||||
}
|
||||
@@ -426,6 +457,13 @@ public sealed class LabSimulation
|
||||
}
|
||||
Baseball.StepCameraInput(input);
|
||||
StepCamera(); //438BC0/439900 input path owns follow; still provisional geometry/state.
|
||||
if(Grappler is{Equipped:true} grappler)
|
||||
{
|
||||
var state=grappler.StepInput(ActorRoot,new(Pitch,Yaw,Roll),Velocity,input,dt,MoveGrappler);
|
||||
Position=state.Root-Vector3.UnitY*rootHeight;Pitch=state.Rotation.X;Yaw=state.Rotation.Y;Roll=state.Rotation.Z;Velocity=state.Velocity;
|
||||
if(state.NewAttachment){jumpState=jumpState with{JumpState=0,EffectRemaining=0};JetpackEffectVisible=false;}
|
||||
if(state.EndsActiveInput)return;
|
||||
}
|
||||
if (movementMode==2)
|
||||
{
|
||||
AdjustEnergy(-dt*.5f);
|
||||
@@ -548,7 +586,7 @@ public sealed class LabSimulation
|
||||
Grounded = result.Body.Supported;
|
||||
if (Grounded) forceFall = false;
|
||||
if (result.Landing != null) Landings++;
|
||||
if (result.Contact is { StoredNormal.Y: > -.7f }) WallHits++;
|
||||
if (result.Contact is { StoredNormal.Y: > -.7f }) {WallHits++;Grappler?.Contact();}
|
||||
Travel += Vector2.Distance(new(before.X, before.Z), new(Position.X, Position.Z));
|
||||
MaximumRise = Math.Max(MaximumRise, Position.Y - startFloor);
|
||||
}
|
||||
@@ -556,6 +594,12 @@ public sealed class LabSimulation
|
||||
private void StepCamera()
|
||||
{
|
||||
const float dt = FixedStepClock.Step;
|
||||
if(Grappler is{} grappler&&movementMode!=2&&!Noclip)
|
||||
{
|
||||
var follow=GrapplerCamera.Follow(grappler.Camera,ActorRoot,new(Pitch,Yaw,Roll),TurnRate,movementMode,CameraEye,dt,cameraRay);
|
||||
CameraEye=follow.Eye;grapplerCameraTarget=follow.Target;return;
|
||||
}
|
||||
grapplerCameraTarget=null;
|
||||
var desired = DesiredEye();
|
||||
var delta = (desired.Eye - CameraEye) * new Vector3(1.6f, 1.2f, 1.6f) * desired.Gain * dt;
|
||||
CameraEye = cameraRay == null ? collision.ClipCamera(CameraTarget, CameraEye + delta) : CameraEye + delta;
|
||||
|
||||
@@ -27,6 +27,7 @@ public enum BodyResponseProfile { Jimmy, Baseball, Rocketship }
|
||||
public sealed class OriginalBodyPhysics
|
||||
{
|
||||
private readonly OriginalStaticCollision collision;
|
||||
public StaticCollisionContext? LastStaticContext {get;private set;}
|
||||
|
||||
public OriginalBodyPhysics(OriginalStaticCollision collision, bool allowSpecialMaterials = false)
|
||||
{
|
||||
@@ -38,6 +39,14 @@ public sealed class OriginalBodyPhysics
|
||||
|
||||
public int? MaterialFor(SupportHit hit) => collision.MaterialFor(hit);
|
||||
|
||||
/// <summary>Attached47B4B0 inherits the sphere context from physics. Support
|
||||
/// and ray queries neither clear last polygon nor reset nearest distances.</summary>
|
||||
public StaticCollisionMove MoveAttached(Vector3 root,Vector3 desired,float radius)
|
||||
{
|
||||
if(LastStaticContext==null)throw new InvalidOperationException("Attached movement requires the preceding body phase");
|
||||
return collision.Move(root,desired-root,radius,LastStaticContext);
|
||||
}
|
||||
|
||||
public OrdinaryBodyStep Step(OrdinaryBodyState body, float seconds,
|
||||
float radius = OriginalBodySupport.JimmyRadius, float factor = OriginalBodySupport.JimmyFactor,
|
||||
float friction = .8f, float suppressionScale = .5f, bool geometryEnabled = true,
|
||||
@@ -68,6 +77,7 @@ public sealed class OriginalBodyPhysics
|
||||
var delta = RecoveredMotion.Integrate(ref velocity, ref impulse, body.Acceleration,
|
||||
RecoveredMotion.Gravity, seconds);
|
||||
var context = new StaticCollisionContext(radius);
|
||||
LastStaticContext=context;
|
||||
var horizontalFirst = delta.Y <= 0;
|
||||
var move = collision.Move(previous, horizontalFirst ? delta with { Y = 0 } : delta,
|
||||
radius, context, geometryEnabled: geometryEnabled);
|
||||
|
||||
@@ -61,7 +61,7 @@ public sealed class OriginalStaticCollision
|
||||
public static OriginalStaticCollision FromRouteScene(Mesh mesh, string level)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(mesh);
|
||||
if (level is not ("LV1B" or "VR01" or "VR02" or "VR04" or "VR07" or "LEV1"))
|
||||
if (level is not ("LV1B" or "VR01" or "VR02" or "VR04" or "VR07" or "VR08" or "LEV1"))
|
||||
throw new NotSupportedException("Original static game-filter recovery covers the route and VR01");
|
||||
if (mesh.Indices.Length % 3 != 0 || mesh.CollisionPolygons.Length != mesh.Indices.Length / 3)
|
||||
throw new InvalidDataException("Source static collision requires original polygon metadata");
|
||||
|
||||
@@ -27,6 +27,7 @@ public sealed class PlayerSceneBinding : IDisposable
|
||||
inventory.GadgetSelected += Selected;
|
||||
player.Invisible.EquippedChanged += InvisibleEquipped;
|
||||
player.Baseball.EquippedChanged += BaseballEquipped;
|
||||
if(player.Grappler!=null)player.Grappler.EquippedChanged+=InvisibleEquipped;
|
||||
player.DefaultGadgetRequested += DefaultGadget;
|
||||
Selected(inventory.SelectedGadget);
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public sealed class PlayerSceneBinding : IDisposable
|
||||
if (!string.Equals(actor.Tag, tag, StringComparison.OrdinalIgnoreCase)) return;
|
||||
//427FF0 switches raw mode, not display selection. A rejected Invisible
|
||||
//equip can leave display2 with raw mode-1; cleanup does not equip it.
|
||||
if (player.GadgetMode is 0 or 1 or 2 or 6 || inventory.SelectedGadget is -1 or 3)
|
||||
if (player.GadgetMode is 0 or 1 or 2 or 6 or 7 || inventory.SelectedGadget is -1 or 3)
|
||||
{ inventory.SelectGadget(-1); player.GadgetMode = -1; }
|
||||
else if (player.GadgetMode != -1) UnsupportedGadgetCleanups++;
|
||||
}
|
||||
@@ -131,6 +132,7 @@ public sealed class PlayerSceneBinding : IDisposable
|
||||
inventory.GadgetSelected -= Selected;
|
||||
player.Invisible.EquippedChanged -= InvisibleEquipped;
|
||||
player.Baseball.EquippedChanged -= BaseballEquipped;
|
||||
if(player.Grappler!=null)player.Grappler.EquippedChanged-=InvisibleEquipped;
|
||||
player.DefaultGadgetRequested -= DefaultGadget;
|
||||
if(Rocketship!=null)Rocketship.RiderHit-=player.RocketImpact;
|
||||
}
|
||||
|
||||
@@ -526,6 +526,11 @@ public sealed class SceneDirector
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleasePlayerGadget()
|
||||
{
|
||||
if(actors.TryGetValue("JIM1",out var jimmy))GadgetReleaseRequested?.Invoke(jimmy);
|
||||
}
|
||||
|
||||
private void DeactivateInvention(GamEntity source)
|
||||
{
|
||||
//Both CAM/MCA constructors default this property to true. The source
|
||||
|
||||
@@ -132,6 +132,7 @@ public sealed class SceneInteractions
|
||||
{ destination = ReturnLevel; start = ReturnStart; }
|
||||
if (string.Equals(destination, "none", StringComparison.OrdinalIgnoreCase))
|
||||
{ unsupported.Add("RETURN has no stored destination"); break; }
|
||||
if(returning)director.ReleasePlayerGadget(); //457FF7 selected cleanup precedes RETURN.
|
||||
Transition?.Invoke(new(destination, start, source.Number("FadeTime"), source.Integer("FadeType"), returning));
|
||||
break;
|
||||
}
|
||||
|
||||
+63
-13
@@ -21,9 +21,10 @@ internal static class Program
|
||||
var returning = false;
|
||||
var diagnostics = new DebugDiagnostics { Enabled = args.Contains("--debug-overlay") };
|
||||
var energy = new PlayerEnergy();
|
||||
var grapplerMemory = new GrapplerMemory();
|
||||
while (true)
|
||||
{
|
||||
var result = Run(args, carriedSave, carriedPlayer, returning, diagnostics, presentation, energy, out var continuation);
|
||||
var result = Run(args, carriedSave, carriedPlayer, returning, diagnostics, presentation, energy, grapplerMemory, out var continuation);
|
||||
if (result != 0 || continuation == null) return result;
|
||||
args = continuation.Args; carriedSave = continuation.Save; returning = continuation.Returning;
|
||||
carriedPlayer = continuation.Player;
|
||||
@@ -44,7 +45,7 @@ internal static class Program
|
||||
private sealed record SceneContinuation(string[] Args, OriginalSave Save, bool Returning, PlayerLevelState? Player);
|
||||
|
||||
private static int Run(string[] args, OriginalSave? carriedSave, PlayerLevelState? carriedPlayer, bool returning, DebugDiagnostics diagnostics,
|
||||
RenderSession presentation, PlayerEnergy energy, out SceneContinuation? continuation)
|
||||
RenderSession presentation, PlayerEnergy energy, GrapplerMemory grapplerMemory, out SceneContinuation? continuation)
|
||||
{
|
||||
continuation = null;
|
||||
if (args.Contains("--help"))
|
||||
@@ -89,6 +90,7 @@ internal static class Program
|
||||
--smoke-shrink-ray Fire at an actual VR04 soldier; explicit player-placement fixture
|
||||
--smoke-invisible Accelerated recharge/activation/flash/expiry/unequip fixture in VR03
|
||||
--smoke-baseball VR07 aim/release/flight/target/respawn fixture
|
||||
--smoke-grappler VR08 attach/reel/swing/cleanup fixture
|
||||
--smoke-rocketship VR02 flight/turn/roll/control fixture
|
||||
--smoke-bubble VR01 expand/throttle/bounce/cleanup/fade input fixture
|
||||
--gadget-menu Render original gadget panel (--skip-intro); fixture owns item3
|
||||
@@ -263,6 +265,7 @@ internal static class Program
|
||||
var invisibleSmoke = args.Contains("--smoke-invisible");
|
||||
var bubbleSmoke = args.Contains("--smoke-bubble");
|
||||
var baseballSmoke = args.Contains("--smoke-baseball");
|
||||
var grapplerSmoke = args.Contains("--smoke-grappler");
|
||||
var rocketSmoke = args.Contains("--smoke-rocketship");
|
||||
var carlSmoke = args.Contains("--smoke-carl-cutscene");
|
||||
var controlPhaseSmoke = args.Contains("--smoke-control-phases");
|
||||
@@ -284,7 +287,7 @@ internal static class Program
|
||||
var defaultStory = (defaultScene || args.Contains("--walk")) && !args.Contains("--inspect") && !walkSmoke && !args.Contains("--smoke-window")
|
||||
&& animationPath == null && !args.Contains("--time");
|
||||
var story = defaultStory || loadedSave != null || saveOutput != null || args.Contains("--story") || args.Contains("--story-time")
|
||||
|| args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || gadgetWindowSmoke || practiceWindowSmoke || practiceReturnSmoke || carlSmoke || controlPhaseSmoke || objectiveSmoke;
|
||||
|| args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || gadgetWindowSmoke || practiceWindowSmoke || practiceReturnSmoke || carlSmoke || controlPhaseSmoke || objectiveSmoke;
|
||||
if (story && (args.Contains("--inspect") || walkSmoke || args.Contains("--smoke-window")))
|
||||
throw new ArgumentException("Story playback requires its own simulation mode.");
|
||||
if (walkSmoke && args.Contains("--inspect")) throw new ArgumentException("Walk smoke cannot run in inspection mode.");
|
||||
@@ -319,6 +322,7 @@ internal static class Program
|
||||
BaseballAimOverlay? baseballAim = null;
|
||||
Rocketship? rocketship = null;
|
||||
RocketshipVisuals? rocketshipVisuals = null;
|
||||
GrapplerVisuals? grapplerVisuals = null;
|
||||
var practice = new PracticePrompt();
|
||||
ObjectivePanel? objectivePanel = null;
|
||||
var patrols = new Dictionary<string, ActorPatrol>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -347,14 +351,15 @@ internal static class Program
|
||||
var standingPose = AseMesh.Load(AssetPath.Resolve(root, "ASE/jimstop.ase"));
|
||||
if (walking)
|
||||
{
|
||||
var cameraRay = level!.Code is "LV1B" or "VR01" or "VR02" or "VR04" or "VR07" or "LEV1"
|
||||
var cameraRay = level!.Code is "LV1B" or "VR01" or "VR02" or "VR04" or "VR07" or "VR08" or "LEV1"
|
||||
? OriginalCameraRay.FromRouteScene(world, level.Code) : null;
|
||||
debugCameraRay = cameraRay;
|
||||
simulation = new LabSimulation(new SceneCollision(world), standingPose, originalStart.Position, originalStart.Rotation.Y,
|
||||
cameraRay == null ? null : (look, eye) => cameraRay.Trace(look, eye),
|
||||
cameraRay == null ? null : (start, end) => cameraRay.TraceGeometry(start, end),
|
||||
level.Code is "VR01" or "VR02" or "VR04" or "VR07" ? OriginalStaticCollision.FromRouteScene(world,level.Code) : null, energy)
|
||||
level.Code is "VR01" or "VR02" or "VR04" or "VR07" or "VR08" ? OriginalStaticCollision.FromRouteScene(world,level.Code) : null, energy)
|
||||
{ LevelCode = level.Code, InputAfterPlayerUpdate = carriedSave != null };
|
||||
if(level.Code=="VR08")simulation.EnableGrappler(world,grapplerMemory);
|
||||
if (carriedPlayer != null)
|
||||
{
|
||||
var applied = simulation.ApplyRetainedLevelState(carriedPlayer);
|
||||
@@ -399,7 +404,7 @@ internal static class Program
|
||||
gadgets = new SceneGadgets(director,interactions.Inventory,simulation,world);
|
||||
gadgets.ScoreAwarded += interactions.ChangeScore;
|
||||
}
|
||||
if(level.Code is "LV1B" or "VR01" or "VR04" or "VR07" or "LEV1")
|
||||
if(level.Code is "LV1B" or "VR01" or "VR04" or "VR07" or "VR08" or "LEV1")
|
||||
{
|
||||
baseballs=new(director,simulation,world);
|
||||
baseballs.ScoreAwarded+=interactions.ChangeScore;
|
||||
@@ -467,6 +472,11 @@ internal static class Program
|
||||
rocketshipVisuals=new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
||||
mesh=rocketshipVisuals.Mesh;
|
||||
}
|
||||
if(simulation.Grappler!=null)
|
||||
{
|
||||
grapplerVisuals=new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
||||
mesh=grapplerVisuals.Mesh;
|
||||
}
|
||||
if (gadgets != null)
|
||||
{
|
||||
rayVisuals = new ShrinkRayVisuals(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")),root);
|
||||
@@ -510,7 +520,7 @@ internal static class Program
|
||||
var storyTime = double.Parse(Option(args, "--story-time") ?? "0", System.Globalization.CultureInfo.InvariantCulture);
|
||||
if (!double.IsFinite(storyTime) || storyTime < 0 || storyTime > 3600 || storyTime > 0 && !headless)
|
||||
throw new ArgumentException("Story time must be0..3600 seconds in headless mode.");
|
||||
var frames = int.Parse(Option(args, "--frames") ?? (rocketSmoke ? "10" : walkSmoke ? "240" : jetpackSmoke ? "300" : shrinkSmoke ? "90" : invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke ? "8" : gadgetWindowSmoke ? "24" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : controlPhaseSmoke ? "32" : toolsSmoke ? "20" : debugSmoke ? "16" : diagnosticsSmoke ? "24" : headless ? "1" : "0"));
|
||||
var frames = int.Parse(Option(args, "--frames") ?? (grapplerSmoke ? "9" : rocketSmoke ? "10" : walkSmoke ? "240" : jetpackSmoke ? "300" : shrinkSmoke ? "90" : invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke ? "8" : gadgetWindowSmoke ? "24" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : controlPhaseSmoke ? "32" : toolsSmoke ? "20" : debugSmoke ? "16" : diagnosticsSmoke ? "24" : headless ? "1" : "0"));
|
||||
if (gadgetWindowSmoke && (headless || level?.Code != "LV1B" || loadedSave != null || frames < 24))
|
||||
throw new ArgumentException("Gadget menu SDL fixture requires a fresh windowed lab and24 frames");
|
||||
if (shrinkSmoke && (level?.Code != "VR04" || gadgets == null || frames < 60))
|
||||
@@ -521,6 +531,8 @@ internal static class Program
|
||||
throw new ArgumentException("Bubble smoke requires a fresh VR01 and at least8 frames");
|
||||
if(baseballSmoke && (level?.Code!="VR07" || frames<8 || loadedSave!=null))
|
||||
throw new ArgumentException("Baseball fixture requires a fresh VR07 and at least8 frames");
|
||||
if(grapplerSmoke&&(level?.Code!="VR08"||frames<9||loadedSave!=null))
|
||||
throw new ArgumentException("Grappler fixture requires fresh VR08 and at least9 frames");
|
||||
if(rocketSmoke&&(level?.Code!="VR02"||frames<10||loadedSave!=null))
|
||||
throw new ArgumentException("Rocketship fixture requires fresh VR02 and at least10 frames");
|
||||
if (controlPhaseSmoke && (level?.Code != "LV1B" || loadedSave != null || frames < 32 || director == null))
|
||||
@@ -558,8 +570,10 @@ internal static class Program
|
||||
InvisibleSmoke? invisibleFixture = null;
|
||||
BubbleSmoke? bubbleFixture = null;
|
||||
BaseballSmoke? baseballFixture = null;
|
||||
GrapplerSmoke? grapplerFixture=null;
|
||||
RocketshipSmoke? rocketFixture=null;
|
||||
var sawRocketKeys=0;
|
||||
var sawGrapplerKeys=0;
|
||||
var sawBaseballKeys=0;
|
||||
var sawBubbleKeys=0;
|
||||
Console.WriteLine($"Scene presentation: revision={renderer.SceneRevision}, windows={presentation.WindowCreationCount}, renderers={presentation.RendererCreationCount}, window ID={(window == 0 ? 0 : Sdl.SDL_GetWindowID(window))}, size={renderer.Width}x{renderer.Height}.");
|
||||
@@ -567,6 +581,12 @@ internal static class Program
|
||||
using var audio = Option(args, "--audio") is { } audioFile
|
||||
? new SdlAudio(audioFile, args.Contains("--loop-audio"), debugMenu.Open) : null;
|
||||
using var sceneAudio = resources != null && !headless && !args.Contains("--mute") ? new SceneAudio(resources) : null;
|
||||
using var grapplerLifetime = simulation?.Grappler;
|
||||
if(simulation?.Grappler is{} grapplerAudio)
|
||||
{
|
||||
grapplerAudio.Sound+=(id,loop)=>sceneAudio?.Effect(id,loop?"grappler":null);
|
||||
grapplerAudio.LoopStopped+=()=>sceneAudio?.StopLoop("grappler");
|
||||
}
|
||||
sceneAudio?.SetPaused(debugMenu.Open);
|
||||
if (simulation!=null)
|
||||
{
|
||||
@@ -623,7 +643,7 @@ internal static class Program
|
||||
Console.WriteLine($"Practice RETURN: exact saved root={restored}, root={simulation.ActorRoot}, STRT yaw={simulation.Yaw}, intro suppressed={!director.Playing}, companion restored={companionRestored}, retained player input order={simulation.InputAfterPlayerUpdate}, gadget availability={interactions.Inventory.State(0, 3)}.");
|
||||
if (!restored) throw new InvalidOperationException("RETURN did not restore the live departure root without replaying STRT actions");
|
||||
}
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (gadgetWindowSmoke) { interactions!.Inventory.SetState(0,3,1); interactions.Inventory.SelectGadget(3); }
|
||||
if (controlPhaseSmoke)
|
||||
{
|
||||
@@ -705,6 +725,7 @@ internal static class Program
|
||||
}
|
||||
if (invisibleSmoke) invisibleFixture = new(simulation!,interactions!.Inventory);
|
||||
if(baseballSmoke)baseballFixture=new(simulation!,playerBinding!,interactions!.Inventory,baseballs!,director);
|
||||
if(grapplerSmoke)grapplerFixture=new(simulation!,playerBinding!,director,interactions!);
|
||||
if(rocketSmoke)rocketFixture=new(simulation!,playerBinding!,director,interactions!);
|
||||
if (bubbleSmoke) bubbleFixture = new(simulation!,interactions!.Inventory);
|
||||
if (shrinkSmoke)
|
||||
@@ -899,6 +920,11 @@ internal static class Program
|
||||
debugMenu.Message=rocketship?.Mounted==true?"ROCKETSHIP EQUIPPED - ARROWS FLY, ENTER/T TURN, R ROLL":
|
||||
"ROCKETSHIP GIVEN - SELECT ITS PRACTICE TILE TO FLY IN VR02";
|
||||
break;
|
||||
case DebugAction.GiveGrappler when interactions != null:
|
||||
interactions.Inventory.SetState(0,7,1);interactions.Inventory.SelectGadget(7);
|
||||
debugMenu.Message=simulation?.GadgetMode==7?"GRAPPLER EQUIPPED - FIRE ATTACH/REEL, JUMP DETACH":
|
||||
"GRAPPLER GIVEN - SELECT ITS PRACTICE TILE TO USE IN VR08";
|
||||
break;
|
||||
case DebugAction.CameraObstruction when debugCameraRay != null:
|
||||
debugCameraRay.Enabled = !debugCameraRay.Enabled; debugMenu.Message = "STATIC CAMERA QUERY TOGGLED"; break;
|
||||
case DebugAction.MuteMusic or DebugAction.MuteSpeech or DebugAction.MuteEffects when sceneAudio != null:
|
||||
@@ -964,6 +990,11 @@ internal static class Program
|
||||
}
|
||||
while (running)
|
||||
{
|
||||
grapplerFixture?.BeforeFrame(count,(key,down)=>
|
||||
{
|
||||
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
||||
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error);
|
||||
},headless);
|
||||
rocketFixture?.BeforeFrame(count,(key,down)=>
|
||||
{
|
||||
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
||||
@@ -1030,6 +1061,8 @@ internal static class Program
|
||||
}
|
||||
while (!headless && Sdl.SDL_PollEvent(out var e))
|
||||
{
|
||||
if(grapplerSmoke&&e.Type==Sdl.KeyDown)
|
||||
sawGrapplerKeys|=e.Scancode switch{80=>1,224=>2,82=>4,225=>8,60=>16,_=>0};
|
||||
if(rocketSmoke&&e.Type==Sdl.KeyDown)
|
||||
sawRocketKeys|=e.Scancode switch{82=>1,80=>2,40=>4,21=>8,43=>16,60=>32,_=>0};
|
||||
if(baseballSmoke && e.Type==Sdl.KeyDown)
|
||||
@@ -1160,12 +1193,13 @@ internal static class Program
|
||||
}
|
||||
}
|
||||
if (debugMenu.Open) animationStarted += elapsed;
|
||||
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true && (active || headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || gadgetWindowSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke))
|
||||
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true && (active || headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || gadgetWindowSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke))
|
||||
{
|
||||
var steps = headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || gadgetWindowSmoke || practiceWindowSmoke || carlSmoke || controlPhaseSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
var steps = headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || gadgetWindowSmoke || practiceWindowSmoke || carlSmoke || controlPhaseSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
for (var step = 0; step < steps; step++)
|
||||
{
|
||||
var input = carlSmoke || controlPhaseSmoke ? new PlayerInput(true, false, true, false, true)
|
||||
: grapplerSmoke && headless ? GrapplerSmoke.Input(count)
|
||||
: rocketSmoke && headless ? RocketshipSmoke.Input(count)
|
||||
: baseballSmoke && headless ? BaseballSmoke.Input(count)
|
||||
: bubbleSmoke && headless ? BubbleSmoke.Input(count)
|
||||
@@ -1178,7 +1212,7 @@ internal static class Program
|
||||
keys.Contains(44) || keys.Contains(8), keys.Contains(224) || keys.Contains(228) || keys.Contains(20),
|
||||
keys.Contains(4), keys.Contains(7), keys.Contains(225) || keys.Contains(229),
|
||||
mouseFire || keys.Contains(40) || keys.Contains(88) || keys.Contains(224) || keys.Contains(228),
|
||||
RocketTurn:keys.Contains(40)||keys.Contains(88)||keys.Contains(23),RocketRoll:keys.Contains(21),RocketMouseRise:mouseJump);
|
||||
RocketTurn:keys.Contains(40)||keys.Contains(88)||keys.Contains(23),RocketRoll:keys.Contains(21),RocketMouseRise:mouseJump,GrapplerEnter:keys.Contains(40)||keys.Contains(88));
|
||||
gadgets?.StepBodies(FixedStepClock.Step);
|
||||
baseballs?.StepBodies(FixedStepClock.Step);
|
||||
var before = simulation.Position;
|
||||
@@ -1186,6 +1220,7 @@ internal static class Program
|
||||
bool acceptsInput;
|
||||
if (playerBinding != null) acceptsInput = playerBinding.Step(input);
|
||||
else { simulation.Step(input); acceptsInput = true; }
|
||||
grapplerFixture?.Received(input);
|
||||
rocketFixture?.Received(input);
|
||||
gadgets?.StepTimers(FixedStepClock.Step);
|
||||
baseballs?.StepTargets(FixedStepClock.Step);
|
||||
@@ -1212,7 +1247,7 @@ internal static class Program
|
||||
objectivePanel?.Step(FixedStepClock.Step, director?.ControlledTag != null, practice.Active);
|
||||
var switched = director is { Controlled: false } && !simulation.Noclip
|
||||
? animations!.SelectAction(director.FindActor(level!.Player!.Tag!)!.Animation)
|
||||
: animations!.SelectPose(simulation.Pose);
|
||||
: simulation.Pose==PlayerPose.Swing ? false : animations!.SelectPose(simulation.Pose);
|
||||
if (switched) poseTime = 0;
|
||||
poseTime += FixedStepClock.Step;
|
||||
actorVisuals?.Update(FixedStepClock.Step, mesh);
|
||||
@@ -1263,6 +1298,8 @@ internal static class Program
|
||||
baseballVisuals?.Update(mesh,simulation!.Baseball.Projectiles,renderEye,renderTarget);
|
||||
baseballAim?.Update(mesh,simulation!.Baseball,renderer.Width,renderer.Height);
|
||||
if(rocketship!=null)rocketshipVisuals?.Update(mesh,rocketship,rocketship.FrameSteps/60d,simulation!.Appearance);
|
||||
if(simulation?.Grappler is{} grapplerRender)grapplerVisuals?.Update(mesh,grapplerRender,simulation.ActorRoot,
|
||||
new(simulation.Pitch,simulation.Yaw,simulation.Roll),poseTime,simulation.Appearance,renderEye,renderTarget);
|
||||
spriteVisuals?.FaceCamera(renderEye, renderTarget, mesh);
|
||||
objectivePanel?.Key(keys.Contains(18) && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true
|
||||
&& director is { Controlled: true, InventoryEnabled: true });
|
||||
@@ -1296,6 +1333,7 @@ internal static class Program
|
||||
BubblePhase = simulation?.Bubble.Active==true ? "ACTIVE" : simulation?.Bubble.Expanding==true ? "EXPAND"
|
||||
: simulation?.Bubble.Collapsing==true ? "FADE" : "OFF",
|
||||
BaseballState=simulation==null?"OFF":$"{(simulation.Baseball.Equipped?"ON":"OFF")} AIM {simulation.Baseball.SavedPitch:F1} PENDING {simulation.Baseball.PendingThrow} THROWS {simulation.Baseball.Throws}",
|
||||
GrapplerState=simulation?.Grappler is{} g?$"{(g.Attached?"ON":"OFF")} LEN {g.Memory.Length:F1} FIRST {g.Memory.FirstLength:F1} HIT {g.Contacts}":null,
|
||||
RocketshipState=rocketship==null?null:$"{(rocketship.Mounted?"ON":"OFF")} SPEED {rocketship.Steering.Speed:F1} VY {rocketship.Velocity.Y:F1} HIT {rocketship.Contacts}",
|
||||
BodyRadius = simulation?.InteractionRadius ?? 60, BodyFactor=simulation?.BodyFactor ?? 1.265f,
|
||||
Objective = interactions?.CurrentObjective ?? 0, ObjectiveTime = objectivePanel?.Elapsed ?? 0,
|
||||
@@ -1328,7 +1366,7 @@ internal static class Program
|
||||
}
|
||||
if (simulation != null && characterDraw != null)
|
||||
{
|
||||
characterDraw.Visible=rocketship?.Mounted!=true;
|
||||
characterDraw.Visible=rocketship?.Mounted!=true && simulation.Grappler?.SwingPose!=true;
|
||||
PlayerGadgetMaterial.Apply(characterDraw,simulation.Appearance);
|
||||
var color=simulation.Appearance.Color;
|
||||
for(var i=0;i<animations!.Current.Base.Vertices.Length;i++)
|
||||
@@ -1336,6 +1374,12 @@ internal static class Program
|
||||
}
|
||||
renderer.UpdateVertices(mesh.Vertices);
|
||||
renderer.Render(view * projection);
|
||||
if(grapplerFixture!=null)
|
||||
{
|
||||
grapplerFixture.AfterFrame(count);
|
||||
if(GrapplerSmoke.StageName(count) is{} stage&&Option(args,"--screenshot") is{} capture)
|
||||
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
||||
}
|
||||
if(rocketFixture!=null)
|
||||
{
|
||||
rocketFixture.AfterFrame(count);
|
||||
@@ -1634,6 +1678,12 @@ internal static class Program
|
||||
if(!headless)Console.WriteLine($"Baseball SDL keys received: {sawBaseballKeys==15}.");
|
||||
if(!baseballFixture.Passed || !headless && sawBaseballKeys!=15)return 2;
|
||||
}
|
||||
if(grapplerFixture!=null)
|
||||
{
|
||||
Console.WriteLine(grapplerFixture.Report);
|
||||
if(!headless)Console.WriteLine($"Grappler SDL keys received: {sawGrapplerKeys==31}.");
|
||||
if(!grapplerFixture.Passed||!headless&&sawGrapplerKeys!=31)return 2;
|
||||
}
|
||||
if(rocketFixture!=null)
|
||||
{
|
||||
Console.WriteLine(rocketFixture.Report);
|
||||
|
||||
@@ -84,7 +84,8 @@ var allGadgetsView=menu.View(new("LV1B","STARTEXP",Vector3.Zero,0,0,true,20,0,30
|
||||
Require(allGadgetsView.Lines.Length<=32 && allGadgetsView.Lines[allGadgetsView.SelectedLine]=="GIVE ALL GADGETS",
|
||||
"Last player action remains visible within the widescreen overlay capacity");
|
||||
menu.Key(81);Require(menu.Key(40)==DebugAction.GiveRocketship,"Player tools expose Rocketship after Give All Gadgets");
|
||||
menu.Key(81); Require(menu.Selected==0,"Player navigation wraps after Rocketship");
|
||||
menu.Key(81); Require(menu.Key(40)==DebugAction.GiveGrappler,"Player tools expose Grappler after Rocketship");
|
||||
menu.Key(81); Require(menu.Selected==0,"Player navigation wraps after Grappler");
|
||||
Console.WriteLine("PASS Give All Gadgets navigation, repeat handling and overlay bounds");
|
||||
|
||||
var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup>
|
||||
<ItemGroup><Compile Include="Program.cs"/><Compile Include="../../src/GamePort/Assets/*.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/*.cs"/>
|
||||
<Compile Include="../../src/GamePort/Application/PlayerGadgetMaterial.cs"/>
|
||||
<Compile Include="../../src/GamePort/Application/GrapplerVisuals.cs"/></ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,180 @@
|
||||
using System.Numerics;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
using GamePort.Application;
|
||||
|
||||
var tests=new(string,Action)[]{
|
||||
("actual VR08 fire attaches after body and ordinary apply still runs",Attach),
|
||||
("retained input attaches after ordinary publication",Retained),
|
||||
("held reel, jump detach, loop and retained first scale",Reel),
|
||||
("contact suffix uses strict60 boundary and no bounce impulse",Contact),
|
||||
("actual VR08 collision delivers the attached contact callback",LiveContact),
|
||||
("same body context replays stale wall, zero delta skips callback",BodyContext),
|
||||
("source ground/air locals, gains, clipping and old-eye aim",Camera),
|
||||
("camera transitions retain reattach look but cleanup restores defaults",CameraStates),
|
||||
("control loss alone retains gadget, named Jimmy cleanup releases",Ownership),
|
||||
("actual RETURN cleans selection before transition",Return),
|
||||
("noclip/reset release and process scalar retention",Lifecycle),
|
||||
("exact rope/swing pivot, fixed first scale and110 cursor",Visuals),
|
||||
("actual aim rejection skips late primary actions",AimGate),
|
||||
};
|
||||
foreach(var(name,test)in tests){test();Console.WriteLine("PASS "+name);}Console.WriteLine($"{tests.Length} live Grappler groups passed.");
|
||||
|
||||
static void Attach()
|
||||
{
|
||||
using var f=new Fixture();f.Attach();
|
||||
Check(f.G.Attached&&f.G.Attachments==1&&f.P.GadgetMode==7,"owned raw7");
|
||||
Check(f.P.PhysicsSteps==1&&f.P.ControllerSteps==1,"both phases run once");
|
||||
Check(f.P.Velocity.Y==100&&f.P.JumpState==0&&!f.G.SwingPose,"attachment impulse and next-input SWING");
|
||||
int body=f.P.PhysicsSteps;f.Binding.Step(default);
|
||||
Check(f.P.PhysicsSteps==body+1&&f.G.SwingPose&&f.P.Pose==PlayerPose.Swing,"ordinary body and swing pose continue");
|
||||
Check(float.IsFinite(f.P.ActorRoot.Length()),"finite attached root");
|
||||
}
|
||||
static void Retained()
|
||||
{
|
||||
using var f=new Fixture();f.P.InputAfterPlayerUpdate=true;f.Attach();
|
||||
Check(f.G.Attached&&f.P.PhysicsSteps==1&&f.P.ControllerSteps==1&&f.P.Velocity.Y==100,"late input keeps100 publication");
|
||||
}
|
||||
static void Reel()
|
||||
{
|
||||
using var f=new Fixture();int stops=0;var sounds=new List<int>();f.G.Sound+=(id,_)=>sounds.Add(id);f.G.LoopStopped+=()=>stops++;
|
||||
f.Attach();var first=f.G.Memory.FirstLength;var scale=f.G.Memory.RopeScaleZ;var length=f.G.Memory.Length;
|
||||
f.Binding.Step(new(false,false,false,false,false,Fire:true));
|
||||
Check(f.G.Attached&&f.G.Memory.Length<length&&sounds.Contains(31)&&sounds.Contains(34),"attach and reel sounds/length");
|
||||
f.Binding.Step(new(false,false,false,false,true));
|
||||
Check(!f.G.Attached&&!f.G.SwingPose&&!f.G.LoopPlaying&&stops>0,"jump withoutfire detach");
|
||||
Check(f.G.Memory.FirstLength==first&&f.G.Memory.RopeScaleZ==scale,"detach retains geometry scalar");
|
||||
f.I.Inventory.SelectGadget(-1);f.I.Inventory.SelectGadget(7);
|
||||
Check(f.G.Memory.FirstLength==first&&f.G.Memory.RopeScaleZ==scale,"reequip retains first scale");
|
||||
f.G.StepInput(f.P.ActorRoot,new(0,f.AimYaw,0),Vector3.Zero,new(false,false,false,false,false,Fire:true),1f/60,d=>new(d,Vector3.Zero));
|
||||
Check(f.G.Attached&&f.G.Memory.FirstLength==first,"reattach retains first length");
|
||||
f.G.StepInput(f.P.ActorRoot,new(0,f.AimYaw,0),Vector3.Zero,new(false,false,false,false,true,Fire:true),1f/60,d=>new(d,Vector3.Zero));
|
||||
Check(f.G.Attached,"simultaneous fire+jump does not detach");
|
||||
}
|
||||
static void Contact()
|
||||
{
|
||||
using var f=new Fixture();f.Attach();f.G.Memory.Swing=new(36,48,.7f);f.G.Contact();
|
||||
Check(f.G.Attached&&f.G.Memory.Swing.X==0&&f.G.Memory.Swing.Z==0,"equal60 clears only");
|
||||
f.G.Memory.Swing=new(60.001f,0,.7f);f.G.Contact();
|
||||
Check(!f.G.Attached&&f.P.Velocity==Vector3.Zero&&f.G.Memory.Swing.Elapsed==.7f,"fast contact detaches zero velocity no impulse");
|
||||
}
|
||||
static void LiveContact()
|
||||
{
|
||||
using var f=new Fixture();f.Attach();
|
||||
//Explicit root/scalar fixture: cross a large authored vertical wall, using
|
||||
//the live constraint and47B4B0 path rather than calling Contact directly.
|
||||
var index=Enumerable.Range(0,f.World.CollisionPolygons.Length).First(i=>
|
||||
MathF.Abs(f.World.CollisionPolygons[i].Normal.Y)<.01f &&
|
||||
Vector3.Cross(f.World.Vertices[f.World.Indices[3*i+1]].Position-f.World.Vertices[f.World.Indices[3*i]].Position,
|
||||
f.World.Vertices[f.World.Indices[3*i+2]].Position-f.World.Vertices[f.World.Indices[3*i]].Position).Length()>200000);
|
||||
var center=(f.World.Vertices[f.World.Indices[3*index]].Position+f.World.Vertices[f.World.Indices[3*index+1]].Position+
|
||||
f.World.Vertices[f.World.Indices[3*index+2]].Position)/3;
|
||||
var normal=f.World.CollisionPolygons[index].Normal;
|
||||
f.P.ApplyAuthoredTransform(center+normal*80,f.P.Yaw);
|
||||
f.G.Memory.Anchor=center-normal*80+Vector3.UnitY*116;
|
||||
f.G.Memory.Length=0;f.G.Memory.Swing=new(100,0,1);f.Binding.Step(default);
|
||||
Check(f.G.Contacts>0&&!f.G.Attached&&!f.G.LoopPlaying, $"live source wall callback detaches: contacts={f.G.Contacts}, attached={f.G.Attached}");
|
||||
}
|
||||
static void BodyContext()
|
||||
{
|
||||
var wall=new CameraRayPolygon(new(new(-1000,-1000,0),new(-1000,1000,0),new(1000,1000,0)),Vector3.UnitZ);
|
||||
var physics=new OriginalBodyPhysics(new([wall]));
|
||||
var result=physics.Step(new(new(0,75.9f,70),new(0,0,-1200),Vector3.Zero,Vector3.Zero,false,0),1f/60);
|
||||
Check(result.Contact==wall,"body accepted wall");var saved=physics.LastStaticContext!;var nearest=saved.Nearest;
|
||||
var root=result.Body.Position;var moved=physics.MoveAttached(root,root+Vector3.UnitZ*10,60);
|
||||
Check(moved.CallbackPolygon==wall&&ReferenceEquals(saved,physics.LastStaticContext),"stale terminal wall retained");
|
||||
Check(saved.Nearest==nearest,"departure adds no accepted hit");
|
||||
Check(physics.MoveAttached(moved.Position,moved.Position,60).CallbackPolygon==null,"zero delta skips stale callback");
|
||||
}
|
||||
static void Camera()
|
||||
{
|
||||
var locals=GrapplerCameraLocals.Default.Equip().Attach();var eye=new Vector3(0,200,-350);
|
||||
var ground=GrapplerCamera.Follow(locals,Vector3.Zero,Vector3.Zero,0,0,eye,.1f,null);
|
||||
Near(ground.DesiredEye,new(0,380,-650),"ground adjusted locals");Near(ground.Look,new(0,169,80),"ground look");
|
||||
Near(ground.Eye,new(0,221.6f,-374),"ground effective gains");
|
||||
var air=GrapplerCamera.Follow(locals with{Gains=new(99,88,77)},Vector3.Zero,Vector3.Zero,0,1,eye,.1f,null);
|
||||
Near(air.DesiredEye,new(0,400,-650),"air raw eye");Near(air.Eye,new(0,240,-386),"air fixed gains");
|
||||
var clipped=GrapplerCamera.Follow(locals,Vector3.Zero,Vector3.Zero,0,0,eye,.1f,(a,b)=>new(a+(b-a)*.5f,0,0,0));
|
||||
Near(clipped.DesiredEye,ground.Look+(ground.DesiredEye-ground.Look)*.375f,"clip .75 of hit from look");Check(clipped.RayGain==1.5f,"obstruction gain");
|
||||
var(p,y)=OriginalHeading.Angles(ground.Look-eye);
|
||||
Near(Vector3.Normalize(ground.Target-ground.Eye),RocketOrientation.Rotate(Vector3.UnitZ,new(p*.02197265625f,y*.02197265625f,0)),"aim from old eye");
|
||||
var pitched=GrapplerCamera.Follow(locals,Vector3.Zero,new(30,40,15),2,1,eye,.1f,null);
|
||||
Near(pitched.DesiredEye,RocketOrientation.Rotate(locals.Eye,new(0,RocketOrientation.AddAxis(40,2),15)),"air eye ignores pitch");
|
||||
}
|
||||
static void CameraStates()
|
||||
{
|
||||
var c=GrapplerCameraLocals.Default with{Gains=new(3,4,5)};Check(c.Equip().Gains==c.Gains,"equip retains gains");
|
||||
c=c.Equip().Attach().Detach().Attach();Near(c.Look,new(0,130,100),"reattach retains detach look");
|
||||
using var f=new Fixture();f.Attach();f.G.Release();Check(f.G.Camera==GrapplerCameraLocals.Default,"cleanup normal defaults");
|
||||
}
|
||||
static void Ownership()
|
||||
{
|
||||
using var f=new Fixture();f.Attach();var root=f.P.ActorRoot;
|
||||
f.P.Step(default,false,false);Check(f.G.Attached&&f.G.Equipped&&f.P.ActorRoot!=root,"controlfalse still body, no generic release");
|
||||
f.D.ReleasePlayerGadget();Check(!f.G.Attached&&!f.G.Equipped&&f.P.GadgetMode==-1,"namedJimmy selected cleanup");
|
||||
f.I.Inventory.SelectGadget(7);f.D.Trigger("gr");Check(!f.G.Equipped,"actualVR08 intro MCA/CAM cleanup");
|
||||
}
|
||||
static void Return()
|
||||
{
|
||||
using var f=new Fixture();f.Attach();f.I.SetReturnContext("level1b.gam","STARTEXP");
|
||||
var portal=GamLevel.Load("../Original/gam/VR08.gam").Entities.First(e=>e.Kind=="LOAD"&&e.Text("LevelName")=="RETURN");
|
||||
LevelTransition? transition=null;f.I.Transition+=t=>{Check(!f.G.Equipped&&!f.G.Attached,"cleanup before event");transition=t;};
|
||||
f.I.Update(portal.Position,60);Check(transition is{Returning:true,LevelFile:"level1b.gam"},"actual RETURN");
|
||||
}
|
||||
static void Lifecycle()
|
||||
{
|
||||
var memory=new GrapplerMemory();using(var f=new Fixture(memory)){f.Attach();f.P.SetNoclip(true);Check(!f.G.Equipped&&f.I.Inventory.SelectedGadget==-1,"noclip safety release");}
|
||||
var first=memory.FirstLength;Check(first>0,"process scalar set");
|
||||
using var next=new Fixture(memory);Check(next.G.Memory.FirstLength==first&&!next.G.Attached,"retained scalar fresh scene helper");
|
||||
next.P.Reset();Check(memory.FirstLength==0&&next.P.GadgetMode==-1,"debug reset clears memory");
|
||||
}
|
||||
static void Visuals()
|
||||
{
|
||||
using var f=new Fixture();var visuals=new GrapplerVisuals(f.World,"artifacts/extracted");f.Equip();
|
||||
f.G.StepInput(f.P.ActorRoot,new(0,f.AimYaw,0),Vector3.Zero,default,1f/60,d=>new(d,Vector3.Zero));
|
||||
visuals.Update(visuals.Mesh,f.G,f.P.ActorRoot,Vector3.Zero,0,f.P.Appearance,new(0,0,-100),Vector3.Zero);
|
||||
var cursor=visuals.Mesh.Draws[^1];Check(cursor.Visible&&cursor.Blend==MeshBlend.Alpha,"cursor alpha");
|
||||
var vertices=visuals.Mesh.Vertices;NearF(Vector3.Distance(vertices[^4].Position,vertices[^3].Position),110,"cursor width");
|
||||
NearF(Vector3.Distance(vertices[^3].Position,vertices[^2].Position),110,"cursor height");
|
||||
f.G.StepInput(f.P.ActorRoot,new(0,f.AimYaw,0),Vector3.Zero,new(false,false,false,false,false,Fire:true),1f/60,d=>new(d,Vector3.Zero));
|
||||
f.G.StepInput(f.P.ActorRoot,new(0,f.AimYaw,0),Vector3.Zero,default,1f/60,d=>new(d,Vector3.Zero));
|
||||
visuals.Update(visuals.Mesh,f.G,f.P.ActorRoot,Vector3.Zero,.1,f.P.Appearance,new(0,0,-100),Vector3.Zero);
|
||||
var rope=visuals.Mesh.Draws[^3];var swing=visuals.Mesh.Draws[^2];Check(rope.Visible&&swing.Visible,"rope and sourceSWING");
|
||||
var index=(int)visuals.Mesh.Indices[(int)rope.FirstIndex];var before=vertices[index].Position;
|
||||
f.G.Memory.Length*=.5f;visuals.Update(visuals.Mesh,f.G,f.P.ActorRoot,Vector3.Zero,.1,f.P.Appearance,new(0,0,-100),Vector3.Zero);
|
||||
Near(vertices[index].Position,before,"render uses firstscale not currentlength");
|
||||
f.G.Release();visuals.Update(visuals.Mesh,f.G,f.P.ActorRoot,Vector3.Zero,.1,f.P.Appearance,new(0,0,-100),Vector3.Zero);
|
||||
Check(!rope.Visible&&!swing.Visible&&!cursor.Visible,"cleanup hides all helpers");
|
||||
}
|
||||
static void AimGate()
|
||||
{
|
||||
using var f=new Fixture();f.Equip();int late=0;f.P.InputActions+=_=>late++;
|
||||
var ray=new GrapplerRay(f.World,"VR08");var hit=ray.Trace(f.P.ActorRoot,new(0,f.AimYaw,0))!.Value;
|
||||
var root=hit.Hit.Position-Vector3.Normalize(ray.Endpoint(f.P.ActorRoot,new(0,f.AimYaw,0))-f.P.ActorRoot)*200;
|
||||
f.P.ApplyAuthoredTransform(root,f.AimYaw);f.Binding.Step(new(false,false,false,false,false,Fire:true));
|
||||
Check(!f.G.Attached&&late==0&&!f.G.CursorVisible,"close surface ends active input");
|
||||
}
|
||||
static void Check(bool v,string m){if(!v)throw new Exception(m);}
|
||||
static void Near(Vector3 a,Vector3 b,string m)=>Check(Vector3.Distance(a,b)<.004f,$"{m}: {a} != {b}");
|
||||
static void NearF(float a,float b,string m)=>Check(Math.Abs(a-b)<.004f,$"{m}: {a} != {b}");
|
||||
|
||||
sealed class Fixture:IDisposable
|
||||
{
|
||||
public Mesh World{get;}=Mesh.LoadSceneJson("artifacts/extracted/VR08/scene.json");
|
||||
public SceneDirector D{get;}public SceneInteractions I{get;}public LabSimulation P{get;}public PlayerSceneBinding Binding{get;}
|
||||
public GrapplerGadget G=>P.Grappler!;public float AimYaw{get;}
|
||||
public Fixture(GrapplerMemory? memory=null)
|
||||
{
|
||||
var level=GamLevel.Load("../Original/gam/VR08.gam");var save=OriginalSave.Load("../Original/NewGame.tsk");var tasks=new TaskStates(save.Tasks);
|
||||
D=new(level,tasks,(_,_)=>0);I=new(D,tasks,save);var start=level.FindStart()!;D.Begin(start,activateStartTrigger:false);
|
||||
var ray=OriginalCameraRay.FromRouteScene(World,"VR08");
|
||||
P=new(new(World),new MorphAnimation("artifacts/extracted/animations/jimstop/animation.json").Base,start.Position,start.Rotation.Y,
|
||||
(a,b)=>ray.Trace(a,b),(a,b)=>ray.TraceGeometry(a,b),OriginalStaticCollision.FromRouteScene(World,"VR08")){LevelCode="VR08"};
|
||||
P.EnableGrappler(World,memory??new());Binding=new(D,P,I.Inventory,level.Player!.Tag!);
|
||||
var aim=new GrapplerRay(World,"VR08");AimYaw=Enumerable.Range(0,360).First(y=>aim.Aim(P.ActorRoot,new(0,y,0),false,false,0,1f/60).CursorVisible);
|
||||
P.ApplyAuthoredTransform(P.ActorRoot,AimYaw);
|
||||
}
|
||||
public void Equip(){I.Inventory.SetState(0,7,1);I.Inventory.SelectGadget(7);}
|
||||
public void Attach(){Equip();Binding.Step(new(false,false,false,false,false,Fire:true));}
|
||||
public void Dispose(){G.Release();Binding.Dispose();}
|
||||
}
|
||||
@@ -0,0 +1,554 @@
|
||||
{
|
||||
"scope": "Copied original components, synthetic bodies/grid; Wine32 exit0; not whole-original gameplay.",
|
||||
"source": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
|
||||
"files": {
|
||||
"tools/binary/grappler_body.py": "e57517dec4ef1e5404958a3a4c4243fa8bc7c2f8144dbd7161947a7ae651bcb9",
|
||||
"artifacts/grappler-body-live/grappler_body_probe.c": "ee3a23390730099f9a0962b274d674d52bc127ed6e84296c9e8f97f51c6129b8",
|
||||
"artifacts/grappler-body-live/probe/wine.log": "3e938a33ffc90614ec9edded6ffab9ff719d0602266e803ea9b7485014f81ec0"
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "body_wall_and_floor",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,60",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "0",
|
||||
"callback374": "1",
|
||||
"unchanged": "0",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "support_preserves_sphere",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,60",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "0",
|
||||
"callback374": "0",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "ray_preserves_sphere",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,60",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "0",
|
||||
"callback374": "0",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "attached_depart_replays_wall",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,70",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "0",
|
||||
"callback374": "1",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "zero_delta_skips_replay",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,70",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "0",
|
||||
"callback374": "0",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "below_threshold_370",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,70",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "1",
|
||||
"callback374": "0",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "equal_threshold_370",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,70",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "1",
|
||||
"callback374": "0",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CASE",
|
||||
"name": "above_threshold_374",
|
||||
"observed": {
|
||||
"root": "0,75.9000015,70",
|
||||
"lastWall": "1",
|
||||
"face": "70",
|
||||
"edge": "60",
|
||||
"hit": "0,75.9000015,0",
|
||||
"callback370": "0",
|
||||
"callback374": "1",
|
||||
"unchanged": "1",
|
||||
"support": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "0",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "2",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "3",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "0",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "0",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "1",
|
||||
"mature": "0",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "0",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "0",
|
||||
"latch": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "MATERIAL",
|
||||
"name": "MATERIAL",
|
||||
"observed": {
|
||||
"id": "4",
|
||||
"grounded": "1",
|
||||
"mature": "1",
|
||||
"fast": "1",
|
||||
"baseUnchanged": "1",
|
||||
"detached": "1",
|
||||
"latch": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CEILING",
|
||||
"name": "CEILING",
|
||||
"observed": {
|
||||
"independentPositiveYOnly": "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -27,5 +27,12 @@
|
||||
<Compile Include="../../src/GamePort/Game/RecoveredMotion.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/FixedStepClock.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/OriginalBodySupport.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerGadget.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerCamera.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerMotion.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerGeometry.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerRay.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/RocketOrientation.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/OriginalHeading.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -31,5 +31,12 @@
|
||||
<Compile Include="../../src/GamePort/Game/RecoveredMotion.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/FixedStepClock.cs"/>
|
||||
<Compile Include="../../src/GamePort/Application/PreviewCharacterPlacement.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerGadget.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerCamera.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerMotion.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerGeometry.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/GrapplerRay.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/RocketOrientation.cs" />
|
||||
<Compile Include="../../src/GamePort/Game/OriginalHeading.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Source identity and the retained copied-original body handoff observations."""
|
||||
from pathlib import Path
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0,str(ROOT/'tools/binary'))
|
||||
from grappler_body import collect, generate
|
||||
|
||||
class GrapplerBodyTests(unittest.TestCase):
|
||||
def test_source_spans_and_independent_support_metadata(self):
|
||||
report=collect(ROOT.parent/'Original')
|
||||
self.assertEqual(len(report['handoff_ranges']),5)
|
||||
self.assertEqual(report['support_sphere_references'],{'support':[],'nearest_support_query':[]})
|
||||
self.assertEqual(report['sha256'],'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8')
|
||||
def test_retained_original_body_support_ray_and_attached_chain(self):
|
||||
data=json.loads((ROOT/'tests/GamePort.GrapplerLiveTests/original-body-reference.json').read_text())
|
||||
cases={c['name']:c['observed'] for c in data['cases'] if c['kind']=='CASE'}
|
||||
self.assertEqual(len(cases),8)
|
||||
for name in ('support_preserves_sphere','ray_preserves_sphere','attached_depart_replays_wall','zero_delta_skips_replay'):
|
||||
self.assertEqual(cases[name]['unchanged'],'1')
|
||||
self.assertEqual(cases[name]['lastWall'],'1')
|
||||
self.assertEqual(cases['attached_depart_replays_wall']['callback374'],'1')
|
||||
self.assertEqual(cases['zero_delta_skips_replay']['callback374'],'0')
|
||||
for name in ('below_threshold_370','equal_threshold_370'):
|
||||
self.assertEqual(cases[name]['callback370'],'1')
|
||||
self.assertEqual(cases['above_threshold_374']['callback374'],'1')
|
||||
def test_full_base_callback_is_noop_for_all_vr08_material_states(self):
|
||||
cases=json.loads((ROOT/'tests/GamePort.GrapplerLiveTests/original-body-reference.json').read_text())['cases']
|
||||
rows=[c['observed'] for c in cases if c['kind']=='MATERIAL']
|
||||
self.assertEqual(len(rows),32)
|
||||
self.assertEqual({int(c['id']) for c in rows},{0,2,3,4})
|
||||
for c in rows:
|
||||
self.assertEqual(c['baseUnchanged'],'1')
|
||||
self.assertEqual(c['detached'],c['fast'])
|
||||
self.assertEqual(c['latch'],c['fast'])
|
||||
self.assertEqual([c['observed'] for c in cases if c['kind']=='CEILING'],[{'independentPositiveYOnly':'1'}])
|
||||
def test_generator_rejects_original_output(self):
|
||||
with self.assertRaises(ValueError):generate(ROOT.parent/'Original',ROOT.parent/'Original')
|
||||
@@ -0,0 +1,92 @@
|
||||
"""Guard original byte spans and interactions that a live adapter must preserve."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0,str(ROOT/'tools/binary'))
|
||||
from grappler_camera import CameraLocals, attach, cleanup, collect, desired, detach, equip, follow
|
||||
|
||||
|
||||
class GrapplerCameraTests(unittest.TestCase):
|
||||
def test_original_identity_spans_virtuals_and_constants(self):
|
||||
report=collect(ROOT.parent/'Original')
|
||||
self.assertEqual(len(report['spans']),11)
|
||||
self.assertEqual(len(report['vtables']),7)
|
||||
self.assertTrue(all(int(x['va'],16)-int(x['file_offset'],16)==0x400000
|
||||
for x in report['spans']))
|
||||
|
||||
def test_equip_preserves_existing_gain_values(self):
|
||||
camera=equip(CameraLocals(gains=(3.,4.,5.)))
|
||||
self.assertEqual(camera.eye,(0.,50.,-350.))
|
||||
self.assertEqual(camera.look,(0.,150.,80.))
|
||||
self.assertEqual(camera.gains,(3.,4.,5.))
|
||||
|
||||
def test_reattach_after_detach_preserves_changed_look(self):
|
||||
initial=attach(equip(CameraLocals()))
|
||||
reattached=attach(detach(initial))
|
||||
self.assertEqual(initial.look,(0.,150.,80.))
|
||||
self.assertEqual(reattached.look,(0.,130.,100.))
|
||||
self.assertEqual(reattached.eye,(0.,400.,-650.))
|
||||
self.assertEqual(reattached.gains,(.8,1.,.8))
|
||||
self.assertEqual(attach(CameraLocals(eye=(123.,50.,-350.))).eye[0],123.)
|
||||
|
||||
def test_inactive_detach_noop_but_cleanup_always_restores_default(self):
|
||||
camera=equip(CameraLocals(gains=(3.,4.,5.)))
|
||||
self.assertIs(detach(camera,False),camera)
|
||||
self.assertEqual(cleanup(camera,False),CameraLocals())
|
||||
|
||||
def test_ground_normal_adjusts_locals_before_full_euler(self):
|
||||
eye,look,gains=desired(equip(CameraLocals()))
|
||||
self.assertEqual(eye,(0.,30.,-350.))
|
||||
self.assertEqual(look,(0.,169.,80.))
|
||||
self.assertEqual(gains,(1.6,1.2,1.6))
|
||||
eye,look,gains=desired(attach(equip(CameraLocals())))
|
||||
self.assertEqual(eye,(0.,380.,-650.))
|
||||
self.assertEqual(gains,(.8,1.2,.8))
|
||||
|
||||
def test_air_uses_raw_locals_and_fixed_gains(self):
|
||||
eye,look,gains=desired(attach(equip(CameraLocals())),movement_mode=1)
|
||||
self.assertEqual(eye,(0.,400.,-650.))
|
||||
self.assertEqual(look,(0.,150.,80.))
|
||||
self.assertEqual(gains,(1.2,2.,1.2))
|
||||
self.assertEqual(desired(CameraLocals(gains=(99.,88.,77.)),movement_mode=3)[2],gains)
|
||||
|
||||
def test_air_eye_flattens_pitch_but_look_uses_pitch(self):
|
||||
camera=equip(CameraLocals())
|
||||
base=desired(camera,movement_mode=1)
|
||||
tilted=desired(camera,euler=(45.,0.,0.),movement_mode=1)
|
||||
self.assertEqual(tilted[0],base[0])
|
||||
self.assertNotEqual(tilted[1],base[1])
|
||||
self.assertNotEqual(desired(camera,euler=(45.,0.,0.))[0],base[0])
|
||||
|
||||
def test_air_turn_rate_changes_eye_yaw_without_changing_look(self):
|
||||
camera=equip(CameraLocals())
|
||||
baseline=desired(camera,movement_mode=1)
|
||||
changed=desired(camera,turn_rate=90.,movement_mode=1)
|
||||
self.assertNotEqual(changed[0],baseline[0])
|
||||
self.assertEqual(changed[1],baseline[1])
|
||||
self.assertAlmostEqual(changed[0][0],350.,places=3)
|
||||
|
||||
def test_aim_uses_old_eye_even_after_interpolation(self):
|
||||
result=follow(equip(CameraLocals()),(0.,100.,-100.),.1)
|
||||
self.assertEqual(result['aim_vector'],(0.,69.,180.))
|
||||
self.assertNotEqual(result['eye'],(0.,100.,-100.))
|
||||
self.assertNotEqual(result['aim_vector'],tuple(a-b for a,b in zip(result['look'],result['eye'])))
|
||||
|
||||
def test_hit_is_weighted_toward_hit_and_scales_interpolation(self):
|
||||
result=follow(equip(CameraLocals()),(0.,0.,0.),.5,hit=(20.,209.,-120.))
|
||||
self.assertEqual(result['desired_eye'],(15.,199.,-70.))
|
||||
self.assertEqual(result['ray_gain'],1.5)
|
||||
self.assertAlmostEqual(result['eye'][0],18.,places=5)
|
||||
self.assertAlmostEqual(result['eye'][1],179.1,places=4)
|
||||
|
||||
def test_follow_does_not_invent_final_clamp(self):
|
||||
result=follow(equip(CameraLocals()),(0.,0.,0.),2.)
|
||||
self.assertLess(result['eye'][2],result['desired_eye'][2])
|
||||
|
||||
def test_bubble_mode_is_not_claimed_by_grappler_projection(self):
|
||||
with self.assertRaises(ValueError): desired(CameraLocals(),movement_mode=2)
|
||||
|
||||
|
||||
if __name__=='__main__': unittest.main()
|
||||
@@ -0,0 +1,102 @@
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ORIGINAL = ROOT.parent/'Original'
|
||||
sys.path.insert(0, str(ROOT/'tools/extractors'))
|
||||
from grappler_resources import (CLIPS, CURSOR_RGBA_SHA256, JIMMY_RGBA_SHA256, SOURCES, export_grappler)
|
||||
from ase import expand_mesh, read_ase
|
||||
from entities import resolve_asset
|
||||
from omt import FormatError
|
||||
sys.path.insert(0,str(ROOT/"tools/binary"))
|
||||
from pe_inspect import PE
|
||||
from checkpoint_script_state import find_case,read_va
|
||||
|
||||
|
||||
@unittest.skipUnless(ORIGINAL.exists(), 'Original assets are local integration fixtures')
|
||||
class GrapplerResources(unittest.TestCase):
|
||||
def test_source_final_cursor_swing_binding_roll_and_shape_scale_consumer(self):
|
||||
spans=[('Neutron.exe',0x445580,96,'e2470f79238741d42a78acd678921e0810b93168fe9c53f9dc562d6596b4ae9e'),
|
||||
('Neutron.exe',0x422bcc,19,'1c37f47d4c3f5235876a2330c28634645a704c28781fb7540e9f485a29d0df5f'),
|
||||
('Neutron.exe',0x41f0fa,53,'0ec5e8e647578640c64290c69d6d193d2e14fbdbeb1eb424ee6b4d7305e8817b'),
|
||||
('OMT2.dll',0x10005970,244,'5b3747756cf8a343b3b4007cbb9710591b9026db0661c4a60a127684eb37560a')]
|
||||
for name,va,size,digest in spans:
|
||||
pe=PE(find_case(ORIGINAL,name))
|
||||
self.assertEqual(hashlib.sha256(read_va(pe,va,size)).hexdigest(),digest)
|
||||
|
||||
def test_exact_resources_and_source_sampling(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'grappler'
|
||||
manifest = export_grappler(ORIGINAL, output)
|
||||
self.assertEqual(manifest, json.loads((output/'grappler.json').read_text()))
|
||||
self.assertEqual(manifest['sources'], SOURCES)
|
||||
self.assertEqual(hashlib.sha256((output/'jimycarl.rgba').read_bytes()).hexdigest(), JIMMY_RGBA_SHA256)
|
||||
self.assertEqual(hashlib.sha256((output/'canvas_8.rgba').read_bytes()).hexdigest(), CURSOR_RGBA_SHA256)
|
||||
self.assertEqual((manifest['cursor']['width'], manifest['cursor']['height']), (64, 64))
|
||||
for stem, _, vertices, faces, times in CLIPS:
|
||||
animation = json.loads((output/stem/'animation.json').read_text())
|
||||
self.assertEqual([f['time'] for f in animation['frames']], list(times))
|
||||
self.assertEqual(animation['texture']['path'], '../jimycarl.rgba')
|
||||
for frame in animation['frames']:
|
||||
mesh = json.loads((output/stem/frame['path']).read_text())
|
||||
self.assertEqual(len(mesh['vertices']), faces*3)
|
||||
self.assertEqual(mesh['indices'], list(range(faces*3)))
|
||||
|
||||
def test_unscaled_rope_positions_and_swing_base_topology(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'grappler'
|
||||
export_grappler(ORIGINAL, output)
|
||||
base = read_ase(resolve_asset(ORIGINAL, 'ASE/jimstop.ASE'))['objects'][0]['samples'][0]
|
||||
for stem, base_stem, _, _, _ in CLIPS:
|
||||
source = read_ase(resolve_asset(ORIGINAL, f'ASE/{stem}.ASE'))
|
||||
animation = json.loads((output/stem/'animation.json').read_text())
|
||||
for sample, frame in zip(source['objects'][0]['samples'], animation['frames'], strict=True):
|
||||
if base_stem:
|
||||
sample = {**sample, 'faces': base['faces'], 'textureFaces': base['textureFaces'], 'uvs': base['uvs']}
|
||||
expected = expand_mesh(sample)
|
||||
actual = json.loads((output/stem/frame['path']).read_text())
|
||||
self.assertEqual(actual['vertices'], [list(v) for v in expected['vertices']])
|
||||
self.assertEqual(actual['uvs'], [list(v) for v in expected['uvs']])
|
||||
rope = json.loads((output/'rope01/frame_0000.json').read_text())
|
||||
self.assertEqual(max(v[2] for v in rope['vertices']), 600.9758)
|
||||
self.assertEqual(min(v[2] for v in rope['vertices']), 0)
|
||||
|
||||
def test_source_defaults_keep_final_cursor_size_distinct_from_sprite_size(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
m = export_grappler(ORIGINAL, Path(directory)/'grappler')
|
||||
self.assertEqual((m['bindings']['cursorInheritedSpriteSize'], m['bindings']['cursorWorldWidth'],
|
||||
m['bindings']['cursorWorldHeight']), (150, 110, 110))
|
||||
self.assertEqual(m['bindings']['cursorBlend'], [6, 7])
|
||||
self.assertEqual(m['bindings']['cursorAlign'], [3, 3])
|
||||
self.assertEqual((m['bindings']['ropeInitialRoll'], m['bindings']['ropeUpdateRoll']), (180, 0))
|
||||
self.assertEqual(len(m['tutorial']['entities']), 16)
|
||||
self.assertFalse(any(e['kind'] == '3GRA' for e in m['tutorial']['entities']))
|
||||
|
||||
def test_original_paths_ancestors_and_child_symlinks_rejected(self):
|
||||
for output in (ORIGINAL, ORIGINAL/'generated', ORIGINAL.parent):
|
||||
with self.subTest(output=output), self.assertRaises(ValueError):export_grappler(ORIGINAL, output)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'grappler';output.mkdir()
|
||||
target = Path(directory)/'unchanged';target.write_bytes(b'unchanged')
|
||||
(output/'jimycarl.rgba').symlink_to(target)
|
||||
with self.assertRaises(ValueError):export_grappler(ORIGINAL, output)
|
||||
self.assertEqual(target.read_bytes(), b'unchanged')
|
||||
|
||||
def test_bad_source_or_decoded_pixels_rejected_before_output(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)/'grappler'
|
||||
with patch('grappler_resources.digest', return_value='0'*64), \
|
||||
patch('grappler_resources.read_ase') as decoder, self.assertRaises(FormatError):
|
||||
export_grappler(ORIGINAL, output)
|
||||
decoder.assert_not_called();self.assertFalse(output.exists())
|
||||
with patch('grappler_resources.read_png', return_value=dict(width=1,height=1,rgba=b'\0'*4)), self.assertRaises(FormatError):
|
||||
export_grappler(ORIGINAL, output)
|
||||
self.assertFalse(output.exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':unittest.main()
|
||||
@@ -0,0 +1,198 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard the Grappler/body handoff and generate its isolated copied-code probe.
|
||||
|
||||
Original files are read only. The generated probe uses synthetic actors and a
|
||||
two-triangle grid; it does not start the original game or run its entry point.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from body_step_evidence import collect as body_collect
|
||||
from checkpoint_script_state import find_case, read_va
|
||||
from collision_response import header
|
||||
from pe_inspect import PE
|
||||
|
||||
RANGES = (
|
||||
('physics_scheduler', 0x479BC0, 0x479D1B, '857abe5d3602741415f84c7a735cd867a86126eb0ed8049ecebf962025d45e64'),
|
||||
('attached', 0x429D00, 0x42A660, '9f4f17bafbca614ee64094df4d951c53cb122f8e15adb9fd7f8a58be589cc2f3'),
|
||||
('jimmy_wall', 0x42A660, 0x42A714, 'd52831057c35afbdb73babff81857a6a3cfb2466f639b8be0a80e6300d386b0c'),
|
||||
('player_wall_full', 0x43AA40, 0x43AFE3, '2acd114eb62fe67490d9301bc8e68f196830be74eb9076f52f79111467344a78'),
|
||||
('ceiling_stop', 0x472690, 0x47274A, 'febfe9381b19074c41b229b314307c85f95710a35c7907935f76519052d4b50c'),
|
||||
)
|
||||
SPHERE = (0x695D4C, 0x695D5C, 0x5CFBE0, 0x5CFBE8)
|
||||
|
||||
|
||||
def collect(original):
|
||||
report = body_collect(original)
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
report['handoff_ranges'] = []
|
||||
for name, start, end, digest in RANGES:
|
||||
data = read_va(pe, start, end-start)
|
||||
if hashlib.sha256(data).hexdigest() != digest:
|
||||
raise ValueError(f'Changed {name}')
|
||||
report['handoff_ranges'].append(dict(name=name, va=hex(start),
|
||||
file_offset=hex(pe.offset(start-pe.base)), length=end-start, sha256=digest))
|
||||
if name in ('jimmy_wall', 'player_wall_full', 'ceiling_stop'):
|
||||
for target in (0x4F0588, 0x4F8210, 0x4F82BC, 0x4F82C0,
|
||||
0x49D5B4, 0x48E5A0, 0x48D914):
|
||||
value = struct.pack('<I', target)
|
||||
for index in range(len(data)-3):
|
||||
if data[index:index+4] == value:
|
||||
report['probe_operands'].append(dict(va=start+index, target=target))
|
||||
report['probe_operands'].sort(key=lambda value: value['va'])
|
||||
# Neither support routine even addresses these sphere-context variables.
|
||||
report['support_sphere_references'] = {}
|
||||
for name, start, end in (('support', 0x47B890, 0x47BBB0),
|
||||
('nearest_support_query', 0x47C6E0, 0x47CA8B)):
|
||||
data = read_va(pe, start, end-start)
|
||||
found = [hex(va) for va in SPHERE if struct.pack('<I', va) in data]
|
||||
if found:
|
||||
raise ValueError(f'Unexpected sphere-context operand in {name}: {found}')
|
||||
report['support_sphere_references'][name] = found
|
||||
report['scope'] = ('Source identity and bounded body/support/attached handoff. '
|
||||
'Support/ray metadata is separate; this is not whole-scene scheduler verification.')
|
||||
return report
|
||||
|
||||
|
||||
PROBE = r'''
|
||||
typedef void (__cdecl *Dispatch)(void*,Vec*,Vec,int);
|
||||
typedef int (__cdecl *Ray)(Vec,Vec,int);
|
||||
typedef void (__cdecl *Support)(Body*);
|
||||
typedef void (TC *Contact)(void*,Vec,void*);
|
||||
static unsigned contact370,contact374;
|
||||
static Vec observedNormal;
|
||||
static unsigned detached;
|
||||
static void TC detach(void*b) {(void)b;detached++;}
|
||||
static void TC callback370(Body*b,Vec normal,void*p) {
|
||||
(void)b;(void)p;contact370++;observedNormal=normal;
|
||||
}
|
||||
static void TC callback374(Body*b,Vec normal,void*p) {
|
||||
(void)b;(void)p;contact374++;observedNormal=normal;
|
||||
}
|
||||
static unsigned char wallPolygon[0x30],wallShape[0x90],wallCorners[60];
|
||||
static Vec wallPoints[3]={{-1000,-1000,0,1},{-1000,1000,0,1},{1000,1000,0,1}};
|
||||
typedef struct {void *last;float face,edge;Vec hit;} Context;
|
||||
static Context context(void) {
|
||||
return (Context){*(void**)AT(0x695d4c),*(float*)AT(0x695d5c),
|
||||
*(float*)AT(0x5cfbe0),*(Vec*)AT(0x5cfbe8)};
|
||||
}
|
||||
static int same(Context a,Context b) {
|
||||
return a.last==b.last&&!memcmp(&a.face,&b.face,4)&&!memcmp(&a.edge,&b.edge,4)
|
||||
&&!memcmp(&a.hit,&b.hit,sizeof(Vec));
|
||||
}
|
||||
static void wall(void) {
|
||||
*(Vec*)(wallPolygon+8)=(Vec){0,0,1,0};
|
||||
*(void**)(wallPolygon+0x24)=wallCorners;*(void**)(wallShape+0x68)=wallPoints;
|
||||
for(unsigned i=0;i<3;i++)*(unsigned*)(wallCorners+i*20)=i;
|
||||
for(int x=127;x<=132;x++)for(int z=129;z<=130;z++)for(int g=0;g<2;g++) {
|
||||
Node*s=&sentinels[g][260*x+z],*n=calloc(1,sizeof(Node));void**r=calloc(1,0x1c);
|
||||
require(n&&r,"wall fixture allocation");r[0]=wallPolygon;r[1]=wallShape;n->value=r;
|
||||
n->next=s;n->previous=s->previous;s->previous->next=n;s->previous=n;
|
||||
}
|
||||
}
|
||||
static void snapshot(const char*name,Body*b,unsigned a,unsigned c,int unchanged) {
|
||||
Context s=context();
|
||||
printf("CASE %s root=%.9g,%.9g,%.9g lastWall=%d face=%.9g edge=%.9g "
|
||||
"hit=%.9g,%.9g,%.9g callback370=%u callback374=%u unchanged=%d support=%d\n",
|
||||
name,b->position.x,b->position.y,b->position.z,s.last==wallPolygon,s.face,s.edge,
|
||||
s.hit.x,s.hit.y,s.hit.z,contact370-a,contact374-c,unchanged,b->supported);
|
||||
}
|
||||
static void full_callbacks(void) {
|
||||
// Direct offsets belong to the original player interface, not our Body stub.
|
||||
unsigned char jimmy[0x2100],before[0x2100],material[0x20],definition[0x20];
|
||||
uintptr_t completeTable[0x500/4];
|
||||
for(unsigned i=0;i<sizeof(completeTable)/sizeof(*completeTable);i++)completeTable[i]=(uintptr_t)missing;
|
||||
completeTable[0x204/4]=(uintptr_t)detach;
|
||||
const unsigned ids[]={0,2,3,4};
|
||||
for(unsigned i=0;i<4;i++)for(unsigned grounded=0;grounded<2;grounded++)
|
||||
for(unsigned mature=0;mature<2;mature++)for(unsigned fast=0;fast<2;fast++) {
|
||||
memset(jimmy,0,sizeof(jimmy));memset(material,0,sizeof(material));memset(definition,0,sizeof(definition));
|
||||
*(uintptr_t*)jimmy=(uintptr_t)completeTable;
|
||||
*(uintptr_t*)(jimmy+0xc0)=(uintptr_t)table;
|
||||
*(float*)(jimmy+0xc0+0x774)=mature?4.0f:0.0f;
|
||||
*(unsigned short*)(jimmy+0xc0+0x704)=grounded;
|
||||
*(void**)(wallPolygon+4)=material;*(void**)(material+0xc)=definition;*(unsigned*)(definition+8)=ids[i];
|
||||
memcpy(before,jimmy,sizeof(jimmy));
|
||||
((Contact)AT(0x43aa40))(jimmy+0xc0,(Vec){0,0,1,0},wallPolygon);
|
||||
require(!memcmp(before,jimmy,sizeof(jimmy)),"ordinary full Player callback is a no-op");
|
||||
*(unsigned short*)AT(0x4f0588)=7;*(unsigned char*)AT(0x4f8210)=1;
|
||||
*(float*)AT(0x4f82bc)=fast?61:60;*(float*)AT(0x4f82c0)=0;detached=0;
|
||||
((Contact)AT(0x42a660))(jimmy+0xc0,(Vec){0,0,1,0},wallPolygon);
|
||||
require(detached==fast&&jimmy[0xc0+0x1d65]==fast,"full wall wrapper detach and latch");
|
||||
require(*(float*)AT(0x4f82bc)==0&&*(float*)AT(0x4f82c0)==0,"wall wrapper clears swing");
|
||||
printf("MATERIAL id=%u grounded=%u mature=%u fast=%u baseUnchanged=1 detached=%u latch=%u\n",
|
||||
ids[i],grounded,mature,fast,detached,jimmy[0xc0+0x1d65]);
|
||||
}
|
||||
Body b=initial();b.velocity=(Vec){3,5,7,0};b.acceleration=(Vec){11,13,17,0};
|
||||
((Contact)AT(0x472690))(&b,(Vec){0,-1,0,0},wallPolygon);
|
||||
require(b.velocity.x==3&&b.velocity.y==0&&b.velocity.z==7&&b.acceleration.x==11
|
||||
&&b.acceleration.y==0&&b.acceleration.z==17,"source ceiling positive Y only");
|
||||
b.velocity.y=-5;b.acceleration.y=13;
|
||||
((Contact)AT(0x472690))(&b,(Vec){0,-1,0,0},wallPolygon);
|
||||
require(b.velocity.y==-5&&b.acceleration.y==0,"ceiling components independent");
|
||||
puts("CEILING independentPositiveYOnly=1");
|
||||
}
|
||||
int main(void) {
|
||||
setbuf(stdout,NULL);map_copy();setup();wall();
|
||||
table[0x370/4]=(uintptr_t)callback370;table[0x374/4]=(uintptr_t)callback374;
|
||||
*(unsigned char*)AT(0x4f69e5)=1;*(unsigned char*)AT(0x695d46)=0;
|
||||
Body b=initial();b.position.z=70;b.previous=b.position;b.velocity.z=-1000;
|
||||
((BodyStep)AT(0x479d20))(&b,1.0f/60);
|
||||
snapshot("body_wall_and_floor",&b,0,0,0);
|
||||
require(context().last==wallPolygon&&contact374==1&&b.supported,"body contact plus support");
|
||||
Context retained=context();unsigned a=contact370,c=contact374;
|
||||
((Support)AT(0x47b890))(&b);
|
||||
snapshot("support_preserves_sphere",&b,a,c,same(retained,context()));
|
||||
require(same(retained,context()),"support must preserve sphere state");
|
||||
a=contact370;c=contact374;
|
||||
int hit=((Ray)AT(0x47c6e0))((Vec){0,100,100,1},(Vec){0,-100,100,1},0)&0xff;
|
||||
snapshot("ray_preserves_sphere",&b,a,c,same(retained,context()));
|
||||
require(hit&&same(retained,context())&&*(void**)AT(0x695d54)==polygon,"ray separate polygon");
|
||||
a=contact370;c=contact374;
|
||||
Vec p=b.position;((Dispatch)AT(0x47b4b0))(&b,&p,(Vec){0,0,10,0},1);b.position=p;
|
||||
snapshot("attached_depart_replays_wall",&b,a,c,same(retained,context()));
|
||||
require(same(retained,context())&&contact374-c==1,"stale terminal callback replay");
|
||||
a=contact370;c=contact374;
|
||||
p=b.position;((Dispatch)AT(0x47b4b0))(&b,&p,(Vec){0,0,0,0},1);
|
||||
snapshot("zero_delta_skips_replay",&b,a,c,same(retained,context()));
|
||||
require(contact370==a&&contact374==c,"tiny delta returns before terminal callback");
|
||||
float normals[]={-.70000005f,-.7f,-.69999993f};
|
||||
const char*names[]={"below_threshold_370","equal_threshold_370","above_threshold_374"};
|
||||
for(unsigned i=0;i<3;i++) {
|
||||
*(Vec*)(wallPolygon+8)=(Vec){0,normals[i],1,0};
|
||||
a=contact370;c=contact374;p=b.position;
|
||||
((Dispatch)AT(0x47b4b0))(&b,&p,(Vec){0,0,10,0},1);
|
||||
snapshot(names[i],&b,a,c,same(retained,context()));
|
||||
require((i<2?contact370-a:contact374-c)==1,"strict callback threshold");
|
||||
}
|
||||
full_callbacks();
|
||||
puts("GRAPPLER_BODY_COMPONENT_COMPLETE: copied body/support/ray/dispatcher, synthetic grid");
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
def generate(original, output):
|
||||
output = Path(output).resolve()
|
||||
if output.is_relative_to(Path(original).resolve()):
|
||||
raise ValueError('Generated files must be outside originals')
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
report = collect(original)
|
||||
(output/'collision_response_relocations.h').write_text(header(report))
|
||||
base = (Path(__file__).parent/'body_step_probe.c').read_text()
|
||||
base = base.replace('int main(void) {', 'static int prior_body_main(void) {')
|
||||
(output/'grappler_body_probe.c').write_text(base+PROBE)
|
||||
(output/'source.json').write_text(json.dumps(report, indent=2)+'\n')
|
||||
return report
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
cli.add_argument('--generate-probe', type=Path)
|
||||
args = cli.parse_args()
|
||||
result = generate(args.original, args.generate_probe) if args.generate_probe else collect(args.original)
|
||||
print(json.dumps(result, indent=2))
|
||||
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guarded Grappler follow-camera/lifetime projection; never executes originals.
|
||||
|
||||
Only the ordinary walking/air follow branches are modeled. Camera flags828/851,
|
||||
Bubble movement2, scene-entry snap and whole frame scheduling remain separate.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
from rocketship_motion_camera import add_axis, f32, rotate
|
||||
|
||||
|
||||
SPANS = (
|
||||
('equip',0x4297dd,0x429857,'8d8c915150a29692734293b0048429f77f8467e50ab4e5449e7110f9d3a060eb'),
|
||||
('attach-camera',0x426d53,0x426da0,'8858a5eec86ee75575aafdfc6eadabc707432821a0db34cd3e6c663d21c423bf'),
|
||||
('detach',0x429c10,0x429cf7,'aad9706ec19de0d162827fe957e91fb4a513423d6e6901de9a29e4c780f7df97'),
|
||||
('cleanup',0x4287ac,0x42883b,'7f1a0574e1a04b1893e2599749616af049854408e1296a2f50e0510b6847d1e5'),
|
||||
('ground-follow',0x439625,0x4398f2,'43ae070dd7f5b3de39cef33e9af25c2847a5e35bfa172dc479292e896ef14a88'),
|
||||
('air-follow',0x439900,0x43a111,'895f27be2ad03f49230fe34e98753095285a61f52b4adbbb15f1dd7c868b2901'),
|
||||
('air-eye-transform',0x43a5d0,0x43a750,'d903035a775b5f2436ea203bfa40a812335c7c75d038592ec766a374d78e47a0'),
|
||||
('camera-ray',0x43b820,0x43b90f,'da79aee91ec334b7cba52edb6b3e0a016e6c553cace3a77a908f13c55af949ad'),
|
||||
('camera-defaults',0x437740,0x43778e,'8a03dc8f9289f76b96be53a678e54729e345624fe98b6045e93236a303d3cb12'),
|
||||
('action-guard',0x43aff0,0x43b0b6,'f439e7317ada3ffb0bc2a9dbfad19539e0faf6e97de463ebaa5b9825d27f7d82'),
|
||||
('constructor-globals',0x422761,0x4227d9,'76d9d28d1a7d655cc48a435af2c77017e86c610a586356859a13e53ea33235df'),
|
||||
)
|
||||
VTABLES = ((0x120, 0x43a5d0), (0x124, 0x438bc0), (0x128, 0x439900),
|
||||
(0x16c, 0x43b820), (0x170, 0x437740), (0x150, 0x43aff0),
|
||||
(0x204, 0x429c10))
|
||||
CONSTANTS = ((0x4afce8, 'd', 1.9), (0x4a2ad0, 'd', .2),
|
||||
(0x4a0ce0, 'd', 1.2), (0x49d5ac, 'f', .75),
|
||||
(0x4a3138, 'f', 1.5), (0x48e5e8, 'f', 45.511112213134766))
|
||||
|
||||
|
||||
def collect(original):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE identity')
|
||||
spans = []
|
||||
for name, start, end, expected in SPANS:
|
||||
digest = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
|
||||
if digest != expected:
|
||||
raise ValueError('Changed source span '+name)
|
||||
spans.append(dict(name=name, va=hex(start), end=hex(end),
|
||||
file_offset=hex(pe.offset(start-pe.base)), sha256=digest))
|
||||
for slot, expected in VTABLES:
|
||||
if struct.unpack('<I', read_va(pe, 0x4a3bdc+slot, 4))[0] != expected:
|
||||
raise ValueError('Changed Jimmy virtual '+hex(slot))
|
||||
for va, fmt, expected in CONSTANTS:
|
||||
if struct.unpack('<'+fmt, read_va(pe, va, struct.calcsize(fmt)))[0] != expected:
|
||||
raise ValueError('Changed camera constant '+hex(va))
|
||||
if read_va(pe, 0x4ef6d8, 6) != b'SWING\0':
|
||||
raise ValueError('Changed protected action literal')
|
||||
return dict(source_sha256=EXE_SHA256, spans=spans,
|
||||
vtables=[dict(slot=hex(s), target=hex(t)) for s,t in VTABLES],
|
||||
constants=[dict(va=hex(v),type=f,value=x) for v,f,x in CONSTANTS],
|
||||
scope='Static guards and bounded Python projection; no original execution')
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CameraLocals:
|
||||
eye: tuple = (0., 200., -350.)
|
||||
look: tuple = (0., 80., 0.)
|
||||
gains: tuple = (1.6, 1., 1.6)
|
||||
|
||||
|
||||
def equip(camera):
|
||||
"""4297DD writes six locals, leaves gains untouched."""
|
||||
return replace(camera, eye=(0.,50.,-350.), look=(0.,150.,80.))
|
||||
|
||||
|
||||
def attach(camera):
|
||||
"""426D writes eye Y/Z and gains; retains eye X and all look coordinates."""
|
||||
return replace(camera, eye=(camera.eye[0],400.,-650.), gains=(.8,1.,.8))
|
||||
|
||||
|
||||
def detach(camera, attached=True):
|
||||
"""429C10 is a strict no-op when its attached global is already false."""
|
||||
if not attached:
|
||||
return camera
|
||||
return CameraLocals((0.,50.,-350.),(0.,130.,100.),(1.6,1.,1.6))
|
||||
|
||||
|
||||
def cleanup(camera, attached=True):
|
||||
"""4287FC detaches then invokes complete170 normal camera defaults."""
|
||||
return CameraLocals()
|
||||
|
||||
|
||||
def desired(camera, root=(0.,0.,0.), euler=(0.,0.,0.), turn_rate=0.,
|
||||
movement_mode=0, adjustment=10.):
|
||||
"""Return desired world eye/look and effective gains for ordinary branches.
|
||||
|
||||
Air eye helper43A5D0 flattens pitch and adds turn_rate to logical yaw.
|
||||
Ground game384 uses complete logical Euler for both points. Values are
|
||||
projections of guarded instructions, not original x87-bit identity.
|
||||
"""
|
||||
if movement_mode == 2:
|
||||
raise ValueError('Bubble mode2 uses separate air smoothing branches')
|
||||
if movement_mode == 0:
|
||||
eye_local=(camera.eye[0],f32(camera.eye[1]-2*adjustment),camera.eye[2])
|
||||
look_local=(camera.look[0],f32(camera.look[1]+1.9*adjustment),camera.look[2])
|
||||
eye_rotation=euler
|
||||
gains=(camera.gains[0],camera.gains[1]+.2,camera.gains[2])
|
||||
else:
|
||||
eye_local,look_local=camera.eye,camera.look
|
||||
eye_rotation=(0.,add_axis(euler[1],turn_rate),euler[2])
|
||||
gains=(1.2,2.,1.2)
|
||||
eye=tuple(f32(a+b) for a,b in zip(root,rotate(eye_local,eye_rotation)))
|
||||
look=tuple(f32(a+b) for a,b in zip(root,rotate(look_local,euler)))
|
||||
return eye,look,gains
|
||||
|
||||
|
||||
def follow(camera, old_eye, dt, hit=None, **kwargs):
|
||||
"""One ordinary follow pass. Aim vector intentionally uses PRE-update eye."""
|
||||
eye,look,gains=desired(camera,**kwargs)
|
||||
ray_gain=1.
|
||||
if hit is not None:
|
||||
eye=tuple(f32(a-(a-b)*.75) for a,b in zip(look,hit))
|
||||
ray_gain=1.5
|
||||
updated=tuple(f32(old+(new-old)*gain*ray_gain*dt)
|
||||
for old,new,gain in zip(old_eye,eye,gains))
|
||||
return dict(eye=updated,look=look,desired_eye=eye,ray_gain=ray_gain,
|
||||
aim_vector=tuple(f32(a-b) for a,b in zip(look,old_eye)))
|
||||
|
||||
|
||||
def main():
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--output',type=Path)
|
||||
args=cli.parse_args()
|
||||
result=json.dumps(collect(args.original),indent=2)+'\n'
|
||||
if args.output: args.output.write_text(result)
|
||||
else: print(result,end='')
|
||||
|
||||
|
||||
if __name__=='__main__': main()
|
||||
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Export exact Grappler rope, SWING morph and owned cursor artwork.
|
||||
|
||||
Source geometry/pixels stay unchanged. Runtime owns first-length scaling,
|
||||
attachments, camera, sprite billboarding and helper lifetime.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import asdict
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from ase import export_ase, read_ase
|
||||
from entities import resolve_asset
|
||||
from gam import parse
|
||||
from omt import Database, FormatError, read_canvas, write_png
|
||||
from png import read_png
|
||||
|
||||
SOURCES = {
|
||||
'ASE/rope01.ASE': '9929f5cba177b887a3b0c389e0783a3bc5dc2bc8c310d3394aa1156bd1f645fd',
|
||||
'ASE/jimswing.ASE': '5e2f8ae134a7f35e440e1b8800bb354a6b1e77505df6515f04e34fdec330e768',
|
||||
'ASE/jimstop.ASE': 'b294d090ac5c4ec449d845db6d837f2cbedf5f7b812f5b6ed2bb70f85246f1d0',
|
||||
'png/jimycarl.png': '55ed165aaffe177cb62558a08d13fc3b2210da6e353065b108849d46df9dacb6',
|
||||
'omt/RetainedSprites.omt': 'b584ffa4a38f4bc809b3ea8f4321e0c08f2719e22df41a3fb4cd143ed89b3bef',
|
||||
'gam/VR08.gam': '8c52efbe95dc56cac136cb9137615261b2b3f84129aea25921e33a952c21738e',
|
||||
}
|
||||
CLIPS = (('rope01', None, 6, 6, (0,)), ('jimswing', 'jimstop', 426, 814, (0, 480)))
|
||||
JIMMY_RGBA_SHA256 = '5e54ccb99e9e060843cd7f80fd93ff8bf47f8779666e41d4240398354a278a3f'
|
||||
CURSOR_PAYLOAD_SHA256 = 'e0d92e1830031bd5ccdf5957779b874a4e7eae8821293ef3f082344da695712e'
|
||||
CURSOR_RGBA_SHA256 = '8d31014cb9b9661ebed902c864bf740f562460e74da3f6b86ed3d2be4d10f0ec'
|
||||
|
||||
|
||||
def digest(data: bytes) -> str:
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def _json(path: Path, value):
|
||||
path.write_text(json.dumps(value, separators=(',', ':'), allow_nan=False)+'\n', encoding='utf-8')
|
||||
|
||||
|
||||
def export_grappler(original: Path, output: Path) -> dict:
|
||||
original, output = original.resolve(), output.resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):
|
||||
raise ValueError('Output must be separate from the original installation')
|
||||
if output.exists() and any(p.is_symlink() for p in output.rglob('*')):
|
||||
raise ValueError('Generated Grappler paths must not contain symlinks')
|
||||
paths = {name: resolve_asset(original, name) for name in SOURCES}
|
||||
for name, path in paths.items():
|
||||
if digest(path.read_bytes()) != SOURCES[name]:
|
||||
raise FormatError(f'Unexpected original Grappler source identity: {name}')
|
||||
animations = {stem: read_ase(paths[f'ASE/{stem}.ASE']) for stem in ('rope01', 'jimswing', 'jimstop')}
|
||||
for stem, base, vertices, faces, times in CLIPS:
|
||||
clip = animations[stem]
|
||||
if len(clip['objects']) != 1:
|
||||
raise FormatError('Unexpected Grappler animation object count')
|
||||
samples = clip['objects'][0]['samples']
|
||||
if tuple(s['time'] for s in samples) != times or any(
|
||||
(len(s['vertices']), len(s['faces'])) != (vertices, faces) for s in samples):
|
||||
raise FormatError('Unexpected Grappler mesh or sample times')
|
||||
topology = animations[base]['objects'][0]['samples'][0] if base else samples[0]
|
||||
if len(topology['vertices']) != vertices or not topology['textureFaces']:
|
||||
raise FormatError('Grappler morph base lacks compatible textured topology')
|
||||
texture = read_png(paths['png/jimycarl.png'])
|
||||
rgba = texture['rgba']
|
||||
if (texture['width'], texture['height'], len(rgba), digest(rgba)) != (256, 256, 256*256*4, JIMMY_RGBA_SHA256):
|
||||
raise FormatError('Unexpected Grappler atlas pixels')
|
||||
database = Database(paths['omt/RetainedSprites.omt'])
|
||||
entries = [e for e in database.entries if e.type == 'Canv' and e.id == 8]
|
||||
if len(entries) != 1:
|
||||
raise FormatError('Expected one owned Grappler cursor canvas')
|
||||
entry = entries[0]
|
||||
payload = database.payload(entry)
|
||||
if (entry.name, entry.offset, entry.size, digest(payload)) != ('target', 48796, 10034, CURSOR_PAYLOAD_SHA256):
|
||||
raise FormatError('Unexpected owned Grappler cursor metadata')
|
||||
canvas = read_canvas(payload)
|
||||
cursor_rgba = canvas['rgba']
|
||||
if (canvas['width'], canvas['height'], len(cursor_rgba), digest(cursor_rgba)) != (64, 64, 64*64*4, CURSOR_RGBA_SHA256):
|
||||
raise FormatError('Unexpected Grappler cursor pixels')
|
||||
level = parse(paths['gam/VR08.gam'].read_bytes())
|
||||
if len(level.entities) != 16 or level.entities[0].kind != '3JIM' or any(e.kind == '3GRA' for e in level.entities):
|
||||
raise FormatError('Unexpected VR08 owned-helper provenance')
|
||||
manifest = dict(schema=1, sources=SOURCES.copy(), animations=[],
|
||||
ropeAnimation='rope01/animation.json', swingAnimation='jimswing/animation.json',
|
||||
cursor=dict(id=8, name=entry.name, width=64, height=64, path='canvas_8.rgba', png='canvas_8.png',
|
||||
sourceOffset=entry.offset, sourceBytes=entry.size, sourceSha256=CURSOR_PAYLOAD_SHA256, rgbaSha256=CURSOR_RGBA_SHA256),
|
||||
bindings=dict(ropeAlias='HIROPE', swingAlias='HISWING', swingAction='SWING',
|
||||
ropeInitialRoll=180, ropeUpdateRoll=0, cursorInheritedSpriteSize=150,
|
||||
cursorWorldWidth=110, cursorWorldHeight=110, cursorFlags=0x248, cursorBlend=[6, 7], cursorAlign=[3, 3]),
|
||||
tutorial=dict(source=paths['gam/VR08.gam'].name, sha256=SOURCES['gam/VR08.gam'],
|
||||
entities=[dict(ordinal=i, **asdict(e)) for i, e in enumerate(level.entities)]),
|
||||
bindingPolicy='Exact resources/source defaults; runtime owns first-length shape scale, transforms, billboarding, timing and helper lifetime')
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
(output/'jimycarl.rgba').write_bytes(rgba)
|
||||
(output/'canvas_8.rgba').write_bytes(cursor_rgba)
|
||||
write_png(output/'canvas_8.png', 64, 64, cursor_rgba)
|
||||
for stem, base, vertices, faces, times in CLIPS:
|
||||
animation = export_ase(paths[f'ASE/{stem}.ASE'], output/stem, paths[f'ASE/{base}.ASE'] if base else None)
|
||||
animation['texture'] = dict(path='../jimycarl.rgba', width=256, height=256,
|
||||
source=paths['png/jimycarl.png'].name, sourceSha256=SOURCES['png/jimycarl.png'], rgbaSha256=JIMMY_RGBA_SHA256)
|
||||
_json(output/stem/'animation.json', animation)
|
||||
manifest['animations'].append(dict(source=paths[f'ASE/{stem}.ASE'].name, path=f'{stem}/animation.json',
|
||||
indexedVertices=vertices, polygons=faces, sourceTimes=list(times)))
|
||||
_json(output/'grappler.json', manifest)
|
||||
return manifest
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
cli.add_argument('--output', type=Path, required=True)
|
||||
args = cli.parse_args()
|
||||
export_grappler(args.original, args.output)
|
||||
print(f'Original Grappler resources exported: {args.output}/grappler.json')
|
||||
@@ -15,6 +15,7 @@ from gadget_followup_assets import export_meter
|
||||
from bubble_resources import export_bubble
|
||||
from baseball_resources import export_baseball
|
||||
from rocketship_resources import export_rocketship
|
||||
from grappler_resources import export_grappler
|
||||
from sound_bank import export_sound_bank
|
||||
|
||||
|
||||
@@ -88,6 +89,7 @@ def main():
|
||||
export_bubble(args.original,args.output/'bubble')
|
||||
export_baseball(args.original,args.output/'baseball')
|
||||
export_rocketship(args.original,args.output/'rocketship')
|
||||
export_grappler(args.original,args.output/'grappler')
|
||||
effects = export_sound_bank(args.original, args.output / 'effects')
|
||||
print(f"SoundEffects.omt: {len(effects['resources'])} original sound identities")
|
||||
for name in args.audio:
|
||||
|
||||
Reference in new issue
Block a user