Implement verified Grappler body camera and helpers in VR08

This commit is contained in:
UnixNight committed 2026-11-04 11:27:03 -05:00
1 parent ffea678e90
commit 43806fe862
39 files changed
+2429 -40

No files matched your search

+7 -6
View File
@@ -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);
}
+75
View File
@@ -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);
}
}
+35
View File
@@ -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);
}
}
+115
View File
@@ -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();
}
}
+48 -4
View File
@@ -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;
+10
View File
@@ -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);
+1 -1
View File
@@ -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");
+3 -1
View File
@@ -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;
}
+5
View File
@@ -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
+1
View File
@@ -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
View File
@@ -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);