Implement Baseball aiming, pooled projectiles and VR07 targets
This commit is contained in:
1 parent
50fcb87d90
commit
d6ca417e9e
50 files changed
+3149
-32
No files matched your search
+58
-8
@@ -88,6 +88,7 @@ internal static class Program
|
||||
--smoke-jetpack 300-step powered steering/jump check in VR04
|
||||
--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-bubble VR01 expand/throttle/bounce/cleanup/fade input fixture
|
||||
--gadget-menu Render original gadget panel (--skip-intro); fixture owns item3
|
||||
--smoke-gadget-menu SDL menu input/pause/selection/practice/Return check (24 frames)
|
||||
@@ -260,6 +261,7 @@ internal static class Program
|
||||
var shrinkSmoke = args.Contains("--smoke-shrink-ray");
|
||||
var invisibleSmoke = args.Contains("--smoke-invisible");
|
||||
var bubbleSmoke = args.Contains("--smoke-bubble");
|
||||
var baseballSmoke = args.Contains("--smoke-baseball");
|
||||
var carlSmoke = args.Contains("--smoke-carl-cutscene");
|
||||
var controlPhaseSmoke = args.Contains("--smoke-control-phases");
|
||||
var objectiveWindowSmoke = args.Contains("--smoke-objective-window");
|
||||
@@ -280,7 +282,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 || gadgetWindowSmoke || practiceWindowSmoke || practiceReturnSmoke || carlSmoke || controlPhaseSmoke || objectiveSmoke;
|
||||
|| args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || 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.");
|
||||
@@ -310,6 +312,9 @@ internal static class Program
|
||||
ShrinkSoldierVisuals? soldierVisuals = null;
|
||||
JetpackVisuals? jetpackVisuals = null;
|
||||
BubbleVisuals? bubbleVisuals = null;
|
||||
SceneBaseballs? baseballs = null;
|
||||
BaseballVisuals? baseballVisuals = null;
|
||||
BaseballAimOverlay? baseballAim = null;
|
||||
var practice = new PracticePrompt();
|
||||
ObjectivePanel? objectivePanel = null;
|
||||
var patrols = new Dictionary<string, ActorPatrol>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -338,13 +343,13 @@ 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 "VR04" or "LEV1"
|
||||
var cameraRay = level!.Code is "LV1B" or "VR01" or "VR04" or "VR07" 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 "VR04" ? OriginalStaticCollision.FromRouteScene(world,level.Code) : null, energy)
|
||||
level.Code is "VR01" or "VR04" or "VR07" ? OriginalStaticCollision.FromRouteScene(world,level.Code) : null, energy)
|
||||
{ LevelCode = level.Code, InputAfterPlayerUpdate = carriedSave != null };
|
||||
if (carriedPlayer != null)
|
||||
{
|
||||
@@ -389,6 +394,11 @@ 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")
|
||||
{
|
||||
baseballs=new(director,simulation,world);
|
||||
baseballs.ScoreAwarded+=interactions.ChangeScore;
|
||||
}
|
||||
mechanisms = new SceneMechanisms(director);
|
||||
interactions.Transition += RequestTransition;
|
||||
interactions.PracticeRequested += practice.Show;
|
||||
@@ -445,6 +455,8 @@ internal static class Program
|
||||
mesh = jetpackVisuals.Mesh;
|
||||
bubbleVisuals = new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
||||
mesh = bubbleVisuals.Mesh;
|
||||
baseballVisuals = new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
||||
mesh = baseballVisuals.Mesh;
|
||||
if (gadgets != null)
|
||||
{
|
||||
rayVisuals = new ShrinkRayVisuals(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")),root);
|
||||
@@ -454,6 +466,8 @@ internal static class Program
|
||||
mesh = hud.Mesh;
|
||||
invisibleMeter = new InvisibleMeterOverlay(mesh,Path.Combine(Path.GetDirectoryName(scene!)!,"../invisible-meter/meter.json"));
|
||||
mesh = invisibleMeter.Mesh;
|
||||
baseballAim = new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
||||
mesh = baseballAim.Mesh;
|
||||
gadgetOverlay = new GadgetMenuOverlay(mesh, Path.Combine(Path.GetDirectoryName(scene!)!, "../gadgets/gadgets.json"));
|
||||
mesh = gadgetOverlay.Mesh;
|
||||
Console.WriteLine($"Prepared source model actors: {staticVisuals.ActorCount}.");
|
||||
@@ -486,7 +500,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") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : shrinkSmoke ? "90" : invisibleSmoke || bubbleSmoke ? "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") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : shrinkSmoke ? "90" : invisibleSmoke || bubbleSmoke || baseballSmoke ? "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))
|
||||
@@ -495,6 +509,8 @@ internal static class Program
|
||||
throw new ArgumentException("Invisible smoke requires a fresh VR03 and at least8 frames");
|
||||
if (bubbleSmoke && (level?.Code!="VR01" || frames<8 || loadedSave!=null))
|
||||
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 (controlPhaseSmoke && (level?.Code != "LV1B" || loadedSave != null || frames < 32 || director == null))
|
||||
throw new ArgumentException("Control-phase fixture needs a fresh lab and at least32 frames");
|
||||
if (toolsSmoke && (headless || frames < 16 || director == null || level?.Code != "LV1B" || loadedSave != null || debugMenu.Open))
|
||||
@@ -529,6 +545,8 @@ internal static class Program
|
||||
var sawShrinkKey = false;
|
||||
InvisibleSmoke? invisibleFixture = null;
|
||||
BubbleSmoke? bubbleFixture = null;
|
||||
BaseballSmoke? baseballFixture = null;
|
||||
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}.");
|
||||
{
|
||||
@@ -541,6 +559,7 @@ internal static class Program
|
||||
simulation.GadgetSound += (id,loop) => sceneAudio?.Effect(id,loop?"bubble":null);
|
||||
simulation.BubbleSoundStopped += () => sceneAudio?.StopLoop("bubble");
|
||||
}
|
||||
if(baseballs!=null)baseballs.Sound+=id=>sceneAudio?.Effect(id);
|
||||
if (gadgets != null)
|
||||
{
|
||||
gadgets.Sound += (id,loop) => sceneAudio?.Effect(id,loop ? "shrink-ray" : null);
|
||||
@@ -568,6 +587,7 @@ internal static class Program
|
||||
}
|
||||
director.Begin(originalStart!, activateStartTrigger: !returning);
|
||||
gadgets?.Reset();
|
||||
baseballs?.Reset();
|
||||
interactions!.Reset();
|
||||
mechanisms!.Reset();
|
||||
director.SyncActor(level!.Player!.Tag!, simulation!.ActorRoot, new Vector3(0, simulation.Yaw, 0));
|
||||
@@ -583,7 +603,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 || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (gadgetWindowSmoke) { interactions!.Inventory.SetState(0,3,1); interactions.Inventory.SelectGadget(3); }
|
||||
if (controlPhaseSmoke)
|
||||
{
|
||||
@@ -664,6 +684,7 @@ internal static class Program
|
||||
gadgetScreen.Point(new(200,380), level!.Code, storyTasks!.Get("SCENE"));
|
||||
}
|
||||
if (invisibleSmoke) invisibleFixture = new(simulation!,interactions!.Inventory);
|
||||
if(baseballSmoke)baseballFixture=new(simulation!,playerBinding!,interactions!.Inventory,baseballs!,director);
|
||||
if (bubbleSmoke) bubbleFixture = new(simulation!,interactions!.Inventory);
|
||||
if (shrinkSmoke)
|
||||
{
|
||||
@@ -756,7 +777,7 @@ internal static class Program
|
||||
if (simulation == null) { debugMenu.Message = "RESET REQUIRES PLAY MODE"; return; }
|
||||
if (practice.Active) practice.Key(17, Vector2.Zero);
|
||||
simulation.Reset(); poseTime = 0; sceneAudio?.StopSpeech(); director?.Begin(originalStart!);
|
||||
interactions?.Reset(); mechanisms?.Reset(); gadgets?.Reset(); mouseFire = false;
|
||||
interactions?.Reset(); mechanisms?.Reset(); gadgets?.Reset(); baseballs?.Reset(); mouseFire = false;
|
||||
director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0));
|
||||
}
|
||||
void ToggleCamera()
|
||||
@@ -843,6 +864,10 @@ internal static class Program
|
||||
debugMenu.Message = simulation?.GadgetMode==0 ? "BUBBLE EQUIPPED - FIRE/UP ACCELERATES, JUMP BOUNCES HIGH"
|
||||
: simulation?.Bubble.Collapsing==true ? "WAIT FOR THE BUBBLE TO FADE BEFORE REEQUIPPING" : "ENERGY REQUIRED TO EQUIP";
|
||||
break;
|
||||
case DebugAction.GiveBaseball when interactions != null:
|
||||
interactions.Inventory.SetState(0,6,1); interactions.Inventory.SelectGadget(6);
|
||||
debugMenu.Message="BASEBALL EQUIPPED - HOLD FIRE, UP/DOWN AIM, RELEASE TO THROW";
|
||||
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:
|
||||
@@ -908,6 +933,11 @@ internal static class Program
|
||||
}
|
||||
while (running)
|
||||
{
|
||||
baseballFixture?.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);
|
||||
bubbleFixture?.BeforeFrame(count,(key,down)=>
|
||||
{
|
||||
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
||||
@@ -964,6 +994,8 @@ internal static class Program
|
||||
}
|
||||
while (!headless && Sdl.SDL_PollEvent(out var e))
|
||||
{
|
||||
if(baseballSmoke && e.Type==Sdl.KeyDown)
|
||||
sawBaseballKeys|=e.Scancode switch{224=>1,80=>2,82=>4,43=>8,_=>0};
|
||||
if (bubbleSmoke && e.Type==Sdl.KeyDown)
|
||||
sawBubbleKeys |= e.Scancode switch {224=>1,80=>2,225=>4,43=>8,_=>0};
|
||||
if (e.Type is Sdl.Quit or 0x210) running = false;
|
||||
@@ -1090,12 +1122,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 || gadgetWindowSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke))
|
||||
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true && (active || headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || gadgetWindowSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke))
|
||||
{
|
||||
var steps = headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || gadgetWindowSmoke || practiceWindowSmoke || carlSmoke || controlPhaseSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
var steps = headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || 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)
|
||||
: baseballSmoke && headless ? BaseballSmoke.Input(count)
|
||||
: bubbleSmoke && headless ? BubbleSmoke.Input(count)
|
||||
: invisibleSmoke && headless ? new PlayerInput(false,false,false,false,false,Fire:count==1)
|
||||
: shrinkSmoke && headless ? new PlayerInput(false,false,false,false,false,Fire:true)
|
||||
@@ -1107,12 +1140,14 @@ internal static class Program
|
||||
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));
|
||||
gadgets?.StepBodies(FixedStepClock.Step);
|
||||
baseballs?.StepBodies(FixedStepClock.Step);
|
||||
var before = simulation.Position;
|
||||
var powered = simulation.JetpackEffectVisible && !simulation.Grounded;
|
||||
bool acceptsInput;
|
||||
if (playerBinding != null) acceptsInput = playerBinding.Step(input);
|
||||
else { simulation.Step(input); acceptsInput = true; }
|
||||
gadgets?.StepTimers(FixedStepClock.Step);
|
||||
baseballs?.StepTargets(FixedStepClock.Step);
|
||||
if (jetpackSmoke && powered)
|
||||
{
|
||||
poweredAirTravel += Vector2.Distance(new(before.X, before.Z), new(simulation.Position.X, simulation.Position.Z));
|
||||
@@ -1179,6 +1214,8 @@ internal static class Program
|
||||
if (shrinkSmoke && gadgets!.Ray.Visible) shrinkPhaseMask |= 1 << gadgets.Ray.TexturePhase;
|
||||
jetpackVisuals?.Update(mesh, simulation!);
|
||||
bubbleVisuals?.Update(mesh,simulation!.Bubble,simulation.BubbleRoot,renderEye,renderTarget);
|
||||
baseballVisuals?.Update(mesh,simulation!.Baseball.Projectiles,renderEye,renderTarget);
|
||||
baseballAim?.Update(mesh,simulation!.Baseball,renderer.Width,renderer.Height);
|
||||
spriteVisuals?.FaceCamera(renderEye, renderTarget, mesh);
|
||||
objectivePanel?.Key(keys.Contains(18) && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true
|
||||
&& director is { Controlled: true, InventoryEnabled: true });
|
||||
@@ -1211,6 +1248,7 @@ internal static class Program
|
||||
Targetable = simulation?.Invisible.Targetable ?? true,
|
||||
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}",
|
||||
BodyRadius = simulation?.InteractionRadius ?? 60, BodyFactor=simulation?.BodyFactor ?? 1.265f,
|
||||
Objective = interactions?.CurrentObjective ?? 0, ObjectiveTime = objectivePanel?.Elapsed ?? 0,
|
||||
CameraObstruction = debugCameraRay?.Enabled, CameraPolygons = debugCameraRay?.PolygonCount ?? 0,
|
||||
@@ -1249,6 +1287,12 @@ internal static class Program
|
||||
}
|
||||
renderer.UpdateVertices(mesh.Vertices);
|
||||
renderer.Render(view * projection);
|
||||
if(baseballFixture!=null)
|
||||
{
|
||||
baseballFixture.AfterFrame(count);
|
||||
if(BaseballSmoke.StageName(count) is{} stage && Option(args,"--screenshot") is{} capture)
|
||||
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
||||
}
|
||||
if (bubbleFixture!=null)
|
||||
{
|
||||
bubbleFixture.AfterFrame(count);
|
||||
@@ -1529,6 +1573,12 @@ internal static class Program
|
||||
if (!headless) Console.WriteLine($"Invisible SDL primary received: {sawShrinkKey}.");
|
||||
if (!invisibleFixture.Passed || !headless && !sawShrinkKey) return 2;
|
||||
}
|
||||
if(baseballFixture!=null)
|
||||
{
|
||||
Console.WriteLine(baseballFixture.Report);
|
||||
if(!headless)Console.WriteLine($"Baseball SDL keys received: {sawBaseballKeys==15}.");
|
||||
if(!baseballFixture.Passed || !headless && sawBaseballKeys!=15)return 2;
|
||||
}
|
||||
if (bubbleFixture!=null)
|
||||
{
|
||||
Console.WriteLine(bubbleFixture.Report);
|
||||
|
||||
Reference in new issue
Block a user