Skip to content

Commit

Permalink
Add enable tuning, fix integration with direct control, regen health
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi committed Dec 2, 2024
1 parent 06eddbe commit 31bea08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions TSOClient/tso.simantics/VMContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ public void InitSpecialTuning()
DisableAvatarCollision = (VM.Tuning.GetTuning("special", 0, 1) ?? 0f) > 0;
var minLight = VM.Tuning.GetTuning("special", 0, 2);
_3DFloorGeometry.af2019 = VM.Tuning.GetTuning("aprilfools", 0, 2019) == 1;
SM64Component.Allowed = VM.Tuning.GetTuning("platformer", 0, 0) == 1;

if (DisableAvatarCollision)
{
Expand Down
23 changes: 17 additions & 6 deletions TSOClient/tso.world/Components/SM64Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ public class SM64Component : IDisposable

private static AnimSource AnimData;

public static bool Allowed;

private Blueprint Bp;
internal WorldState State;
private Collision Collision = new Collision();
Expand Down Expand Up @@ -370,7 +372,7 @@ public sbyte DetermineLevel(Vector3 pos, bool forLight)

sbyte level = (sbyte)(Math.Max(0, Math.Min(Bp.Stories - 1, Math.Floor((height + 0.5f) / 2.95f))) + 1);

return forLight || TileIndoors((int)pos.X, (int)pos.Y, level) ? level : (sbyte)(Bp.Stories - 1);
return forLight || TileIndoors((int)pos.X, (int)pos.Y, level) ? level : Bp.Stories;
}

public void RemoveMario(AvatarComponent avatar)
Expand Down Expand Up @@ -564,12 +566,15 @@ public void Update(GraphicsDevice device, WorldState world, bool visible)

if (!MarioActiveForMe)
{
var gamepad = GamePad.GetState(0);

if (gamepad.IsConnected && visible)
if (Allowed)
{
MarioActiveForMe = true;
InitCollision(world);
var gamepad = GamePad.GetState(0);

if (gamepad.IsConnected && visible)
{
MarioActiveForMe = true;
InitCollision(world);
}
}

return;
Expand Down Expand Up @@ -619,6 +624,12 @@ public void Update(GraphicsDevice device, WorldState world, bool visible)
// TODO: displacement? (on top of interpolated movement objects? we only really have cars and ducks lol)
Mario.MarioUpdate();

if (Mario.State.HurtCounter == 0 && Mario.State.Health < 2176 && Mario.State.Health > 0)
{
// Slowly heal over time (about 35 seconds for a full heal)
Mario.State.Health += 2;
}

if (Mario.Floor == null) return;
// TODO: update_mario_platform (also displacement related)

Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public void CenterTo(EntityComponent comp)
{
if (comp.Room == 0 || comp.Room == 65531) return; //don't center if the target is out of bounds

bool isFirstPerson = State.CameraMode == CameraRenderMode._3D && State.Cameras.ActiveType == CameraControllerType.FirstPerson;
bool isFirstPerson = State.Cameras.ActiveType == CameraControllerType.Direct;
sbyte level = comp.Level;

Vector3 pelvisCenter;
Expand Down

0 comments on commit 31bea08

Please sign in to comment.