Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CelerityTAS committed Feb 4, 2024
2 parents 5a000f7 + 9024894 commit 835bc92
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
24 changes: 17 additions & 7 deletions Source/Actors/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public void Kill()
Dead = true;
}

public bool ClimbCheckAt(Vec3 offset, out WallHit hit)
public bool ClimbCheckAt(Vec3 offset, out WallHit hit) // TAS: publicized
{
if (World.SolidWallCheckClosestToNormal(SolidWaistTestPos + offset, ClimbCheckDist, -new Vec3(targetFacing, 0), out hit)
&& (RelativeMoveInput == Vec2.Zero || Vec2.Dot(hit.Normal.XY().Normalized(), RelativeMoveInput) <= -0.5f)
Expand All @@ -972,7 +972,7 @@ public bool ClimbCheckAt(Vec3 offset, out WallHit hit)
return false;
}

public bool TryClimb() // TAS: publicized
private bool TryClimb()
{
var result = ClimbCheckAt(Vec3.Zero, out var wall);

Expand Down Expand Up @@ -1471,7 +1471,7 @@ private void SetDashSpeed(in Vec2 dir)

#region Skidding State

private float tNoSkidJump;
public float tNoSkidJump; // TAS: publicized

private void StSkiddingEnter()
{
Expand Down Expand Up @@ -2096,7 +2096,12 @@ private void StDeadUpdate()
if (!Game.Instance.IsMidTransition && drawOrbsEase > 0.30f)
{
var entry = World.Entry with { Reason = World.EntryReasons.Respawned };
Game.Instance.Goto(new Transition() { Mode = Transition.Modes.Replace, Scene = () => new World(entry), ToBlack = new AngledWipe(), });
Game.Instance.Goto(new Transition()
{
Mode = Transition.Modes.Replace,
Scene = () => new World(entry),
ToBlack = new AngledWipe()
});
}
}

Expand Down Expand Up @@ -2188,7 +2193,13 @@ private CoEnumerator StCassetteRoutine()
{
if (World.Entry.Submap)
{
Game.Instance.Goto(new Transition() { Mode = Transition.Modes.Pop, ToPause = true, ToBlack = new SpotlightWipe(), StopMusic = true });
Game.Instance.Goto(new Transition()
{
Mode = Transition.Modes.Pop,
ToPause = true,
ToBlack = new SpotlightWipe(),
StopMusic = true
});
}
//Saves and quits game if you collect a cassette with an empty map property when you're not in a submap
else if (!Assets.Maps.ContainsKey(cassette.Map))
Expand All @@ -2212,7 +2223,7 @@ private CoEnumerator StCassetteRoutine()
Scene = () => new World(new(cassette.Map, string.Empty, true, World.EntryReasons.Entered)),
ToPause = true,
ToBlack = new SpotlightWipe(),
StopMusic = true,
StopMusic = true
});
}
}
Expand Down Expand Up @@ -2354,7 +2365,6 @@ public void RenderCollider(Batcher3D batch)
{
batch.Sphere(actor.Position, (actor as IPickup)!.PickupRadius, 12, Color.Green * 0.5f);
}

batch.Cube(Position, Color.Green, thickness: 0.2f);
}

Expand Down
12 changes: 6 additions & 6 deletions Source/Scenes/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public enum EntryReasons { Entered, Returned, Respawned }
private readonly List<ModelEntry> models = [];
private readonly List<Sprite> sprites = [];

private Target? postTarget;
private readonly Material postMaterial = new();
private readonly Batcher batch = new();
private readonly List<Skybox> skyboxes = [];
private readonly SpriteRenderer spriteRenderer = new();
private Target? postTarget;
private readonly Material postMaterial = new();
private readonly Batcher batch = new();
private readonly Batcher3D batch3d = new();
private readonly List<Skybox> skyboxes = [];
private readonly SpriteRenderer spriteRenderer = new();

// Pause Menu, only drawn when actually paused
private readonly Menu pauseMenu = new();
Expand Down Expand Up @@ -801,7 +802,6 @@ public override void Render(Target target)
// render colliders
if (Save.Instance.Hitboxes)
{
var batch3d = new Batcher3D();
foreach (var actor in All<IHaveRenderCollider>())
(actor as IHaveRenderCollider).RenderCollider(batch3d);
batch3d.Render(ref state);
Expand Down
1 change: 1 addition & 0 deletions Source/TAS/CustomInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ List<Actor> GetCachedOrFindActors(Type type, string actorId, Dictionary<string,
(MethodRegex.Match(memberNames.First()) is {Success: true} match &&
type.GetMethodInfo(match.Groups[1].Value) is {IsStatic: true})
)) {
foundValid = true;
return FormatValue(GetMemberValue(type, null, memberNames), helperMethod, decimals);
}

Expand Down
4 changes: 3 additions & 1 deletion Source/TAS/InfoHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public static void RenderGUI()
statues.Add($"DashCD({player.tDashCooldown.ToFrames()})");
if (player.tNoDashJump > 0)
statues.Add($"DashJumpCD({player.tNoDashJump.ToFrames()})");
if (player.tNoSkidJump > 0)
statues.Add($"SkidJumpCD({player.tNoSkidJump.ToFrames()})");

// Taken from player.TryClimb()
bool canClimb = player.ClimbCheckAt(Vec3.Zero, out var wall);
Expand All @@ -152,7 +154,7 @@ public static void RenderGUI()
string timerStr = (int) Save.CurrentRecord.Time.TotalHours > 0
? $"{((int) Save.CurrentRecord.Time.TotalHours):00}:{Save.CurrentRecord.Time.Minutes:00}:{Save.CurrentRecord.Time.Seconds:00}:{Save.CurrentRecord.Time.Milliseconds:000}"
: $"{Save.CurrentRecord.Time.Minutes:00}:{Save.CurrentRecord.Time.Seconds:00}:{Save.CurrentRecord.Time.Milliseconds:000}";
ImGui.Text($"[{Save.Instance.LevelID}] Timer: {timerStr}");
ImGui.Text($"[{Save.Instance.LevelID}] Timer: {timerStr}({((float)Save.CurrentRecord.Time.TotalSeconds).ToFrames()})");
}

ImGui.Text(string.Empty);
Expand Down
9 changes: 8 additions & 1 deletion Source/TAS/Render/Batcher3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public struct Vertex(Vec3 position, Vec2 texcoord, Color color) : IVertex
public readonly VertexFormat Format => VertexFormat;
}

~Batcher3D()
{
if (vertexPtr != IntPtr.Zero)
Marshal.FreeHGlobal(vertexPtr);
if (indexPtr != IntPtr.Zero)
Marshal.FreeHGlobal(indexPtr);
}

private IntPtr vertexPtr = IntPtr.Zero;
private int vertexCount = 0;
private int vertexCapacity = 0;
Expand Down Expand Up @@ -436,7 +444,6 @@ public void Render(ref RenderState state)
MeshIndexStart = 0,
MeshIndexCount = indexCount,
};
Log.Info($"Rendered {indexCount}");
call.Submit();
state.Calls++;
state.Triangles += indexCount / 3;
Expand Down

0 comments on commit 835bc92

Please sign in to comment.