Restore tutorial return placement and source terrain collision eligibility
This commit is contained in:
1 parent
ca08c468ba
commit
8d60a68511
36 files changed
+991
-69
No files matched your search
@@ -85,6 +85,16 @@ public sealed class LabSimulation
|
||||
CameraEye = DesiredEye();
|
||||
}
|
||||
|
||||
/// <summary>Jimmy PostLoad423A90..423ABF restores the saved RETURN root.
|
||||
/// Yaw remains the authored STRT yaw; the source stores only XYZ here.</summary>
|
||||
public void RestoreReturnRoot(Vector3 root)
|
||||
{
|
||||
if (!float.IsFinite(root.X) || !float.IsFinite(root.Y) || !float.IsFinite(root.Z))
|
||||
throw new ArgumentOutOfRangeException(nameof(root));
|
||||
Position = root - Vector3.UnitY * rootHeight;
|
||||
CameraEye = DesiredEye();
|
||||
}
|
||||
|
||||
// EXE 0x47F940 truncates, then degree lookup masks to the 16384-entry table.
|
||||
// Table generated with modern trig; x87 bit-identical table recovery is pending.
|
||||
public static (float Sin, float Cos) Trig(float degrees)
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed class OriginalScenePhysics
|
||||
throw new InvalidDataException("Prepare source collision polygon metadata before original root support");
|
||||
walls = new SceneCollision(world, wallsAndCeilingsOnly: true);
|
||||
support = Enumerable.Range(0, world.Indices.Length / 3)
|
||||
.Where(i => !Checkpoint(world.CollisionPolygons[i].MaterialName))
|
||||
.Where(i => world.CollisionPolygons[i].TerrainCollision && !Checkpoint(world.CollisionPolygons[i].MaterialName))
|
||||
.Select(i => new SupportTriangle(world.Vertices[world.Indices[i * 3]].Position,
|
||||
world.Vertices[world.Indices[i * 3 + 1]].Position, world.Vertices[world.Indices[i * 3 + 2]].Position,
|
||||
world.CollisionPolygons[i].ShapeId, world.CollisionPolygons[i].PolygonIndex)).ToArray();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Player43B5A0 stages a level transition. Ordinary departure captures the current
|
||||
/// root at complete+9A8; RETURN preserves it using complete+9A5. PostLoad restores
|
||||
/// that root and STRT suppresses its initial trigger using the separate+954 flag.
|
||||
/// This is distinct from Jimmy42AF00's currently unconsumed+1E38 checkpoint.
|
||||
/// </summary>
|
||||
public sealed class RuntimeCheckpoint
|
||||
{
|
||||
public Vector3 Root { get; }
|
||||
public bool Returning { get; }
|
||||
public bool ActivateStartTrigger => !Returning;
|
||||
|
||||
private RuntimeCheckpoint(Vector3 root, bool returning)
|
||||
{
|
||||
Root = root;
|
||||
Returning = returning;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Only RETURN restores a root on scene entry. No rotation is captured here;
|
||||
/// the destination STRT remains the source of authored spawn rotation.
|
||||
/// Root is the same vector serialized in OriginalSave.StoredVector.
|
||||
/// </summary>
|
||||
public static RuntimeCheckpoint Stage(Vector3 storedRoot, Vector3 currentRoot, bool returning)
|
||||
{
|
||||
Validate(storedRoot, nameof(storedRoot));
|
||||
Validate(currentRoot, nameof(currentRoot));
|
||||
return new(returning ? storedRoot : currentRoot, returning);
|
||||
}
|
||||
|
||||
private static void Validate(Vector3 root, string name)
|
||||
{
|
||||
if (!float.IsFinite(root.X) || !float.IsFinite(root.Y) || !float.IsFinite(root.Z))
|
||||
throw new ArgumentOutOfRangeException(name, "Transition roots must be finite");
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace GamePort.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Provisional geometric reconstruction for the controllable-scene checkpoint.
|
||||
/// Uses source triangles, including invisible proxies, without claiming the
|
||||
/// original game's unrecovered collision-mask/state rules or solver tolerances.
|
||||
/// Uses source terrain-eligible triangles, including invisible proxies. NC shape
|
||||
/// exclusion is recovered; remaining masks/state rules and solver are provisional.
|
||||
/// Positions are the bottom of a vertical capsule in original Y-up world units.
|
||||
/// </summary>
|
||||
public sealed class SceneCollision
|
||||
@@ -35,6 +35,8 @@ public sealed class SceneCollision
|
||||
// proxies remain present and block movement in this provisional policy.
|
||||
for (var i = 0; i < mesh.Indices.Length; i += 3)
|
||||
{
|
||||
if (mesh.CollisionPolygons.Length == mesh.Indices.Length / 3
|
||||
&& !mesh.CollisionPolygons[i / 3].TerrainCollision) continue;
|
||||
// EXE4798B3 registers only stored normal.Y<.7 in the wall/ceiling
|
||||
// grid. Render normals and a recomputed cross product differ.
|
||||
if (wallsAndCeilingsOnly && mesh.CollisionPolygons[i / 3].Normal.Y >= .7f) continue;
|
||||
|
||||
@@ -113,7 +113,7 @@ public sealed class SceneDirector
|
||||
tasks.Assigned += OnTaskAssigned;
|
||||
}
|
||||
|
||||
public void Begin(GamEntity start)
|
||||
public void Begin(GamEntity start, bool activateStartTrigger = true)
|
||||
{
|
||||
if (start.Kind != "STRT") throw new ArgumentException("Expected original STRT entity", nameof(start));
|
||||
shot = null; pending.Clear(); activations.Clear();
|
||||
@@ -131,7 +131,9 @@ public sealed class SceneDirector
|
||||
actor.SpritePlaying = initial.SpritePlaying; actor.SpriteRevision++;
|
||||
ApplyTask(actor, tasks.Get(source.Text("TaskName")));
|
||||
}
|
||||
var trigger = start.Text("StartTrigger");
|
||||
// RETURN sets Jimmy+954; STRT4427F2..44282A consumes that flag and
|
||||
// suppresses its trigger once. Do not fast-forward the trigger's actions.
|
||||
var trigger = activateStartTrigger ? start.Text("StartTrigger") : null;
|
||||
ControlledTag = IsNone(trigger) ? level.Player?.Tag : null; // EXE4426B7.
|
||||
if (!IsNone(trigger)) Trigger(trigger!, start.Tag);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
public sealed record LevelTransition(string LevelFile, string StartPoint, float FadeTime, int FadeType);
|
||||
public sealed record LevelTransition(string LevelFile, string StartPoint, float FadeTime, int FadeType, bool Returning = false);
|
||||
|
||||
/// <summary>
|
||||
/// Recovered star/trophy/lab jetpack contacts, Carl talk dispatch and LOAD gates. Uses source root spheres
|
||||
@@ -122,11 +122,12 @@ public sealed class SceneInteractions
|
||||
if (!TaskActivation.Load(source, tasks)) break;
|
||||
var destination = source.Text("LevelName") ?? "none";
|
||||
var start = source.Text("StartPoint") ?? "none";
|
||||
if (string.Equals(destination, "RETURN", StringComparison.OrdinalIgnoreCase))
|
||||
var returning = string.Equals(destination, "RETURN", StringComparison.OrdinalIgnoreCase);
|
||||
if (returning)
|
||||
{ destination = ReturnLevel; start = ReturnStart; }
|
||||
if (string.Equals(destination, "none", StringComparison.OrdinalIgnoreCase))
|
||||
{ unsupported.Add("RETURN has no stored destination"); break; }
|
||||
Transition?.Invoke(new(destination, start, source.Number("FadeTime"), source.Integer("FadeType")));
|
||||
Transition?.Invoke(new(destination, start, source.Number("FadeTime"), source.Integer("FadeType"), returning));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user