0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-25 04:35:18 +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.Elapsed += (_, _) => { SyncShineBag(); };
timer.Start();
bool flipEnabled = Settings.Instance.Flip.EnabledOnStart;
float MarioSize(bool is2d) {
return is2d ? 180 : 160;
@ -76,7 +75,7 @@ server.PacketHandler = (c, p) => {
SyncShineBag();
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.Players.Contains(c.Id): {
playerPacket.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d);
@ -84,7 +83,9 @@ server.PacketHandler = (c, p) => {
server.Broadcast(playerPacket, c);
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) => {
if (Settings.Instance.Flip.Players.Contains(to.Id)) {
sp.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d);
@ -148,8 +149,9 @@ CommandHandler.RegisterCommand("flip", args => {
}
case "set" when args.Length == 2: {
if (bool.TryParse(args[1], out bool result)) {
flipEnabled = result;
return result ? "Enabled player flipping for session" : "Disabled player flipping for session";
Settings.Instance.Flip.Enabled = result;
Settings.SaveSettings();
return result ? "Enabled player flipping" : "Disabled player flipping";
}
return optionUsage;

View file

@ -54,7 +54,7 @@ public class Settings {
public class FlipTable {
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;
}
}