0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-28 22:23:05 +00:00

Make flipping a permanent setting like the others

This commit is contained in:
Sanae 2022-03-06 17:32:49 -06:00
parent 134437eec9
commit f47ab01d4c
2 changed files with 8 additions and 6 deletions

View file

@ -51,7 +51,6 @@ timer.AutoReset = true;
timer.Enabled = true; timer.Enabled = true;
timer.Elapsed += (_, _) => { SyncShineBag(); }; timer.Elapsed += (_, _) => { SyncShineBag(); };
timer.Start(); timer.Start();
bool flipEnabled = Settings.Instance.Flip.EnabledOnStart;
float MarioSize(bool is2d) { float MarioSize(bool is2d) {
return is2d ? 180 : 160; return is2d ? 180 : 160;
@ -76,7 +75,7 @@ server.PacketHandler = (c, p) => {
SyncShineBag(); SyncShineBag();
break; break;
} }
case PlayerPacket playerPacket when flipEnabled case PlayerPacket playerPacket when Settings.Instance.Flip.Enabled
&& Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others && Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others
&& Settings.Instance.Flip.Players.Contains(c.Id): { && Settings.Instance.Flip.Players.Contains(c.Id): {
playerPacket.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d); playerPacket.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d);
@ -84,7 +83,9 @@ server.PacketHandler = (c, p) => {
server.Broadcast(playerPacket, c); server.Broadcast(playerPacket, c);
return false; return false;
} }
case PlayerPacket playerPacket when flipEnabled && Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Self && !Settings.Instance.Flip.Players.Contains(c.Id): { case PlayerPacket playerPacket when Settings.Instance.Flip.Enabled
&& Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Self
&& !Settings.Instance.Flip.Players.Contains(c.Id): {
server.BroadcastReplace(playerPacket, c, (from, to, sp) => { server.BroadcastReplace(playerPacket, c, (from, to, sp) => {
if (Settings.Instance.Flip.Players.Contains(to.Id)) { if (Settings.Instance.Flip.Players.Contains(to.Id)) {
sp.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d); sp.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d);
@ -148,8 +149,9 @@ CommandHandler.RegisterCommand("flip", args => {
} }
case "set" when args.Length == 2: { case "set" when args.Length == 2: {
if (bool.TryParse(args[1], out bool result)) { if (bool.TryParse(args[1], out bool result)) {
flipEnabled = result; Settings.Instance.Flip.Enabled = result;
return result ? "Enabled player flipping for session" : "Disabled player flipping for session"; Settings.SaveSettings();
return result ? "Enabled player flipping" : "Disabled player flipping";
} }
return optionUsage; return optionUsage;

View file

@ -54,7 +54,7 @@ public class Settings {
public class FlipTable { public class FlipTable {
public List<Guid> Players { get; set; } = new List<Guid>(); public List<Guid> Players { get; set; } = new List<Guid>();
public bool EnabledOnStart { get; set; } = true; public bool Enabled { get; set; } = true;
public FlipOptions Pov { get; set; } = FlipOptions.Both; public FlipOptions Pov { get; set; } = FlipOptions.Both;
} }
} }