Skip to content

Commit

Permalink
move simplified Graphics into Save.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
CelerityTAS committed Feb 7, 2024
1 parent a8324c8 commit c6f0b92
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
7 changes: 4 additions & 3 deletions Source/Actors/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public override void Added() {
GetCameraTarget(out var orig, out var target, out _);
World.Camera.LookAt = target;
World.Camera.Position = orig;
World.Camera.FarPlane = Save.Instance.SimplifiedGraphics ? 8000 : 800;

if (Save.Instance.Freecam != Save.FreecamMode.Free) {
Manager.FreeCamPosition = Position;
Expand Down Expand Up @@ -2112,10 +2113,10 @@ public void CollectSprites(List<Sprite> populate) {
if (drawOrbs && drawOrbsEase > 0) {
var ease = drawOrbsEase;
var col = Math.Floor(ease * 10) % 2 == 0 ? Hair.Color : Color.White;
var s = (ease < 0.5f) ? (0.5f + ease) : (Ease.CubeOut(1 - (ease - 0.5f) * 2));
var s = (ease < 0.5f) ? (0.5f + ease) : (Ease.Cube.Out(1 - (ease - 0.5f) * 2));
for (int i = 0; i < 8; i++) {
var rot = (i / 8f + ease * 0.25f) * MathF.Tau;
var rad = Ease.CubeOut(ease) * 16;
var rad = Ease.Cube.Out(ease) * 16;
var pos = SolidWaistTestPos + World.Camera.Left * MathF.Cos(rot) * rad + World.Camera.Up * MathF.Sin(rot) * rad;
var size = 3 * s;
populate.Add(Sprite.CreateBillboard(World, pos, "circle", size + 0.5f, Color.Black) with { Post = true });
Expand Down Expand Up @@ -2149,7 +2150,7 @@ public void CollectModels(List<(Actor Actor, Model Model)> populate) {
continue;

// I HATE this alpha fade out but don't have time to make some kind of full-model fade out effect
var alpha = Ease.CubeOut(Calc.ClampedMap(trail.Percent, 0.5f, 1.0f, 1, 0));
var alpha = Ease.Cube.Out(Calc.ClampedMap(trail.Percent, 0.5f, 1.0f, 1, 0));

foreach (var mat in trail.Model.Materials)
mat.Color = trail.Color * alpha;
Expand Down
18 changes: 18 additions & 0 deletions Source/Data/Save.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,24 @@ public void ToggleFullscreen()
public void ToggleSimplifiedGraphics()
{
SimplifiedGraphics = !SimplifiedGraphics;
Save.Instance.SyncSettings();

if (Game.Scene is World world) {
world.Camera.FarPlane = Save.Instance.SimplifiedGraphics ? 8000 : 800;

foreach (var actor in world.Actors) {
var fields = actor.GetType().GetFields()
.Where(f => f.FieldType.IsAssignableTo(typeof(Model)));

foreach (var field in fields) {
var model = (Model)field.GetValue(actor)!;
foreach (var material in model.Materials) {
if (material.Shader == null || !Assets.Shaders.ContainsKey(material.Shader.Name)) continue;
material.Simplified = Save.Instance.SimplifiedGraphics;
}
}
}
}
}

public void ToggleZGuide()
Expand Down
24 changes: 1 addition & 23 deletions Source/TAS/TASMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,7 @@ public static void Update()

if (TASControls.SimplifiedGraphics.ConsumePress())
{
Save.Instance.SimplifiedGraphics = !Save.Instance.SimplifiedGraphics;
Save.Instance.SyncSettings();

if (Game.Scene is World world)
{
world.Camera.FarPlane = Save.Instance.SimplifiedGraphics ? 8000 : 800;

foreach (var actor in world.Actors)
{
var fields = actor.GetType().GetFields()
.Where(f => f.FieldType.IsAssignableTo(typeof(Model)));

foreach (var field in fields)
{
var model = (Model) field.GetValue(actor)!;
foreach (var material in model.Materials)
{
if (material.Shader == null || !Assets.Shaders.ContainsKey(material.Shader.Name)) continue;
material.Simplified = Save.Instance.SimplifiedGraphics;
}
}
}
}
Save.Instance.ToggleSimplifiedGraphics();
}

if (TASControls.Hitboxes.ConsumePress())
Expand Down

0 comments on commit c6f0b92

Please sign in to comment.