Implement timed Invisible gadget and shared energy warnings
This commit is contained in:
1 parent
3527d33810
commit
1897dd2b90
44 files changed
+2466
-39
No files matched your search
@@ -7,7 +7,8 @@ namespace GamePort.Application;
|
||||
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 }
|
||||
CameraObstruction, MuteMusic, MuteSpeech, MuteEffects, RestartMusic, StopEffects, SaveCheckpoint, LoadCheckpoint, Practice,
|
||||
GiveInvisible, UnequipGadget }
|
||||
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,
|
||||
@@ -25,6 +26,9 @@ public sealed record DebugSystems
|
||||
public float JumpHold { get; init; }
|
||||
public float BurnRemaining { get; init; }
|
||||
public int JetpackAvailability { get; init; }
|
||||
public float InvisibleRemaining { get; init; }
|
||||
public float InvisibleRecharge { get; init; }
|
||||
public bool Targetable { get; init; } = true;
|
||||
public int Objective { get; init; }
|
||||
public float ObjectiveTime { get; init; }
|
||||
public bool? CameraObstruction { get; init; }
|
||||
@@ -48,7 +52,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 => 10, 2 => 9, _ => ItemCount };
|
||||
public int PageItems => Page switch { 1 => 12, 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];
|
||||
@@ -110,7 +114,8 @@ public sealed class DebugMenu
|
||||
0 => DebugAction.Noclip, 1 => DebugAction.NoclipSpeed, 2 => DebugAction.StopMotion,
|
||||
3 => DebugAction.ShowObjective, 4 => DebugAction.ReturnNoclipEntry,
|
||||
5 => DebugAction.LevelAvailability, 6 => DebugAction.InputOrder,
|
||||
8 => DebugAction.ApplyJetpackState, 9 => DebugAction.RefillEnergy, _ => DebugAction.None
|
||||
8 => DebugAction.ApplyJetpackState, 9 => DebugAction.RefillEnergy,
|
||||
10 => DebugAction.GiveInvisible, 11 => DebugAction.UnequipGadget, _ => DebugAction.None
|
||||
};
|
||||
if (Page == 2) return Selected switch
|
||||
{
|
||||
@@ -147,13 +152,15 @@ public sealed class DebugMenu
|
||||
Page == 1 ? $"PENDING {V(system.PendingImpulse)}" : $"AUDIO BYTES MUSIC {system.MusicBytes} VOICE {system.SpeechBytes}",
|
||||
Page == 1 ? $"JUMP {system.JumpState} HOLD {F(system.JumpHold)} BURN {F(system.BurnRemaining)}"
|
||||
: $"EFFECT BYTES {system.EffectBytes} AUDIO AVAILABLE {system.AudioAvailable}",
|
||||
$"OBJECTIVE {system.Objective} TIME {F(system.ObjectiveTime)} GADGET STATE {system.JetpackAvailability}", ""];
|
||||
$"OBJECTIVE {system.Objective} TIME {F(system.ObjectiveTime)} GADGET STATE {system.JetpackAvailability}",
|
||||
$"INVISIBLE {F(system.InvisibleRemaining)} RECHARGE {F(system.InvisibleRecharge)}/7 TARGETABLE {system.Targetable}", ""];
|
||||
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",
|
||||
"RETURN TO NOCLIP ENTRY POSITION", "APPLY THIS LEVEL'S GADGET AVAILABILITY",
|
||||
$"INPUT AFTER PLAYER: {system.InputAfterPlayer} (TOGGLE)",
|
||||
$"JET PACK STATE: {JetpackState} (0 NONE / 1 OWNED / 4 DISABLED)", "APPLY JET PACK STATE", "REFILL ENERGY TO 100"] : [
|
||||
$"JET PACK STATE: {JetpackState} (0 NONE / 1 OWNED / 4 DISABLED)", "APPLY JET PACK STATE", "REFILL ENERGY TO 100",
|
||||
"GIVE / SELECT INVISIBLE", "UNEQUIP CURRENT GADGET"] : [
|
||||
$"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"];
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>Original Canv21/22 meter. Source size/tint/full-image stretch with
|
||||
/// a declared logical rectangle conversion and uniform centered widescreen UI.</summary>
|
||||
public sealed class InvisibleMeterOverlay
|
||||
{
|
||||
private readonly int offset;
|
||||
private readonly uint firstIndex;
|
||||
public Mesh Mesh { get; }
|
||||
|
||||
public InvisibleMeterOverlay(Mesh combined, string manifest)
|
||||
{
|
||||
var full = Path.GetFullPath(manifest);
|
||||
var directory = Path.GetDirectoryName(full)!;
|
||||
if (new FileInfo(full).Length > 16 * 1024) throw new InvalidDataException("Meter manifest exceeds limit");
|
||||
using var document = JsonDocument.Parse(File.ReadAllBytes(full), new JsonDocumentOptions {MaxDepth=10});
|
||||
var root = document.RootElement;
|
||||
if (root.GetProperty("schema").GetInt32() != 1 || root.GetProperty("referenceWidth").GetInt32() != 640
|
||||
|| root.GetProperty("referenceHeight").GetInt32() != 480 || root.GetProperty("textures").GetArrayLength() != 2)
|
||||
throw new InvalidDataException("Unsupported Invisible meter format");
|
||||
offset = combined.Vertices.Length; firstIndex = (uint)combined.Indices.Length;
|
||||
var vertices = combined.Vertices.ToList(); var indices = combined.Indices.ToList();
|
||||
var draws = combined.Draws.ToList(); var textures = new Dictionary<int,PngImage>(combined.Textures);
|
||||
if (!combined.HasExplicitDraws && indices.Count != 0) draws.Add(new(0,(uint)indices.Count,-1));
|
||||
var seen = new HashSet<int>();
|
||||
foreach (var entry in root.GetProperty("textures").EnumerateArray().OrderBy(e=>e.GetProperty("id").GetInt32()))
|
||||
{
|
||||
var id = entry.GetProperty("id").GetInt32();
|
||||
if (id is not (21 or 22) || !seen.Add(id) || entry.GetProperty("width").GetInt32()!=30
|
||||
|| entry.GetProperty("height").GetInt32()!=110) throw new InvalidDataException("Invalid source meter canvas");
|
||||
var path = Path.GetFullPath(Path.Combine(directory,entry.GetProperty("path").GetString()!));
|
||||
if (!path.StartsWith(directory+Path.DirectorySeparatorChar,StringComparison.Ordinal)
|
||||
|| new FileInfo(path).Length != 30*110*4) throw new InvalidDataException("Invalid meter pixel path/length");
|
||||
var textureId = int.MinValue+15000; while(textures.ContainsKey(textureId))textureId++;
|
||||
textures.Add(textureId,new(30,110,File.ReadAllBytes(path)));
|
||||
var first = (uint)vertices.Count;
|
||||
vertices.AddRange([new(Vector3.Zero,new(0,0),Vector3.One),new(Vector3.Zero,new(.9999f,0),Vector3.One),
|
||||
new(Vector3.Zero,new(.9999f,.9999f),Vector3.One),new(Vector3.Zero,new(0,.9999f),Vector3.One)]);
|
||||
indices.AddRange([first,first+1,first+2,first,first+2,first+3]);
|
||||
draws.Add(new((uint)indices.Count-6,6,textureId){ScreenSpace=true,Visible=false});
|
||||
}
|
||||
Mesh = new(vertices.ToArray(),indices.ToArray()) {HasExplicitDraws=true,Draws=draws.ToArray(),Textures=textures,
|
||||
CollisionPolygons=combined.CollisionPolygons,HasCollisionMaterialIds=combined.HasCollisionMaterialIds};
|
||||
}
|
||||
|
||||
public void Update(Mesh destination, InvisibleGadget device, uint width, uint height)
|
||||
{
|
||||
var viewport = new UiViewport(width,height);
|
||||
var visible = device.Equipped && device.MeterVisible;
|
||||
var color = device.MeterReady ? Vector3.One : new Vector3(1,.2f,.2f);
|
||||
var fillHeight = (float)(Math.Max(device.MeterPercent,0)*1.04);
|
||||
Quad(0,new(320,7),new(30,110),Vector3.One);
|
||||
Quad(1,new(322,114-fillHeight),new(27,fillHeight),color);
|
||||
void Quad(int index, Vector2 position, Vector2 size, Vector3 tint)
|
||||
{
|
||||
destination.Draws.First(d=>d.ScreenSpace&&d.FirstIndex==firstIndex+(uint)index*6).Visible=visible;
|
||||
var p = position+viewport.CenterOffset;
|
||||
var corners = new[] {p,p+new Vector2(size.X,0),p+size,p+new Vector2(0,size.Y)};
|
||||
for(var i=0;i<4;i++)
|
||||
{
|
||||
destination.Vertices[offset+index*4+i].Position=viewport.ToNdc(corners[i]);
|
||||
destination.Vertices[offset+index*4+i].Color=tint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>Accelerated port verification: full player ticks between six rendered
|
||||
/// phases. No actor relocation or direct timer/material writes; not original cadence.</summary>
|
||||
public sealed class InvisibleSmoke
|
||||
{
|
||||
private readonly LabSimulation player;
|
||||
private readonly SceneInventory inventory;
|
||||
private readonly bool[] checks = new bool[6];
|
||||
private readonly float initialEnergy;
|
||||
private int acceleratedTicks;
|
||||
|
||||
public InvisibleSmoke(LabSimulation player, SceneInventory inventory)
|
||||
{
|
||||
this.player = player; this.inventory = inventory; initialEnergy = player.Energy;
|
||||
inventory.SetState(0,2,1); inventory.SelectGadget(2);
|
||||
if (player.GadgetMode != 2 || !player.Invisible.Equipped)
|
||||
throw new InvalidOperationException("Invisible fixture requires a connected, eligible player binding");
|
||||
Advance(() => player.Invisible.Recharge == 7);
|
||||
}
|
||||
|
||||
public void BeforeFrame(int count, Action<uint,bool> injectKey, bool headless)
|
||||
{
|
||||
if (count == 1 && !headless) injectKey(224,true);
|
||||
if (count == 2 && !headless) injectKey(224,false);
|
||||
if (count == 3) Advance(() => player.Invisible.Active && player.Invisible.Remaining <= 2.9f && player.Invisible.ConventionalBlend);
|
||||
if (count == 4) Advance(() => player.Invisible.Active && !player.Invisible.ConventionalBlend);
|
||||
if (count == 5) Advance(() => !player.Invisible.Active);
|
||||
if (count == 6)
|
||||
{
|
||||
if (headless) inventory.SelectGadget(-1);
|
||||
else injectKey(43,true);
|
||||
}
|
||||
if (count == 7 && !headless) injectKey(43,false);
|
||||
}
|
||||
|
||||
private void Advance(Func<bool> done)
|
||||
{
|
||||
for(var i=0;i<1000;i++)
|
||||
{
|
||||
if(done())return;
|
||||
player.Step(default); acceleratedTicks++;
|
||||
}
|
||||
throw new InvalidOperationException("Invisible fixture did not reach the requested source phase");
|
||||
}
|
||||
|
||||
public void AfterFrame(int count, MeshDraw material)
|
||||
{
|
||||
var device = player.Invisible;
|
||||
if(count==0)checks[0]=device.Recharge==7 && device.Targetable && material.Opacity==1 && device.MeterReady;
|
||||
if(count==1)checks[1]=device.Active && device.Activations==1 && device.Remaining>3
|
||||
&& material.Opacity==.7f && material.Blend==MeshBlend.Additive
|
||||
&& player.Energy==(player.IgnoresGadgetEnergy ? initialEnergy : initialEnergy-2);
|
||||
if(count==3)checks[2]=device.Active && material.Opacity==.7f && material.Blend==MeshBlend.Alpha;
|
||||
if(count==4)checks[3]=device.Active && material.Blend==MeshBlend.Additive && device.Remaining<=3;
|
||||
if(count==5)checks[4]=!device.Active && device.Targetable && material.Opacity==1 && material.Blend==MeshBlend.Opaque;
|
||||
if(count==7)checks[5]=player.GadgetMode==-1 && !device.Equipped && !device.MeterVisible && device.Targetable;
|
||||
}
|
||||
|
||||
public bool Passed => checks.All(value=>value);
|
||||
public string Report => $"Invisible fixture: charged={checks[0]}, activation={checks[1]}, alpha flash={checks[2]}, additive flash={checks[3]}, expiry={checks[4]}, unequip={checks[5]}, accelerated player ticks={acceleratedTicks}, energy={player.Energy:F3}.";
|
||||
public static string? StageName(int count) => count switch
|
||||
{0=>"charged",1=>"active",3=>"alpha",4=>"additive",5=>"expired",7=>"unequipped",_=>null};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>Current Jimmy atlas is one linked material. Source114 alpha and
|
||||
/// indexed0 FC blend changes affect that draw without changing pose/visibility.</summary>
|
||||
public static class PlayerGadgetMaterial
|
||||
{
|
||||
public static void Apply(MeshDraw draw, InvisibleGadget invisible)
|
||||
{
|
||||
draw.Opacity = invisible.Opacity;
|
||||
draw.Blend = !invisible.Active ? MeshBlend.Opaque
|
||||
: invisible.ConventionalBlend ? MeshBlend.Alpha : MeshBlend.Additive;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user