Send WorldInfo when setting various time flags, fix time format

This commit is contained in:
MarioE 2014-06-30 11:02:36 -04:00
parent 97252dfe93
commit e715a6bac9
2 changed files with 52 additions and 26 deletions

View file

@ -1560,20 +1560,20 @@ namespace TShockAPI
private static void Fullmoon(CommandArgs args)
{
TSPlayer.Server.SetFullMoon(true);
TShock.Utils.Broadcast(string.Format("{0} turned on the full moon.", args.Player.Name), Color.Green);
TSPlayer.Server.SetFullMoon();
TSPlayer.All.SendInfoMessage("{0} started a full moon.", args.Player.Name);
}
private static void Bloodmoon(CommandArgs args)
{
TSPlayer.Server.SetBloodMoon(true);
TShock.Utils.Broadcast(string.Format("{0} turned on the blood moon.", args.Player.Name), Color.Green);
TSPlayer.Server.SetBloodMoon(!Main.bloodMoon);
TSPlayer.All.SendInfoMessage("{0} {1}ed a blood moon.", args.Player.Name, Main.bloodMoon ? "start" : "stopp");
}
private static void Eclipse(CommandArgs args)
{
TSPlayer.Server.SetEclipse(true);
TShock.Utils.Broadcast(string.Format("{0} has forced an Eclipse!", args.Player.Name), Color.Green);
TSPlayer.Server.SetEclipse(!Main.eclipse);
TSPlayer.All.SendInfoMessage("{0} {1}ed an eclipse.", args.Player.Name, Main.eclipse ? "start" : "stopp");
}
private static void Invade(CommandArgs args)
@ -1616,8 +1616,6 @@ namespace TShockAPI
private static void PumpkinMoon(CommandArgs args)
{
TSPlayer.Server.SetPumpkinMoon(true);
int wave = 1;
if (args.Parameters.Count != 0)
{
@ -1628,6 +1626,7 @@ namespace TShockAPI
}
}
TSPlayer.Server.SetPumpkinMoon(true);
Main.bloodMoon = false;
NPC.waveKills = 0f;
NPC.waveCount = wave;
@ -1636,8 +1635,6 @@ namespace TShockAPI
private static void FrostMoon(CommandArgs args)
{
TSPlayer.Server.SetFrostMoon(true);
int wave = 1;
if (args.Parameters.Count != 0)
{
@ -1648,6 +1645,7 @@ namespace TShockAPI
}
}
TSPlayer.Server.SetFrostMoon(true);
Main.bloodMoon = false;
NPC.waveKills = 0f;
NPC.waveCount = wave;
@ -3093,7 +3091,7 @@ namespace TShockAPI
time += 4.5;
if (!Main.dayTime)
time += 15.0;
args.Player.SendInfoMessage("The current time is {0:D2}:{1:D2}.", (int)Math.Floor(time), (int)Math.Round((time % 1.0) * 30.0));
args.Player.SendInfoMessage("The current time is {0}:{1:D2}.", (int)Math.Floor(time), (int)Math.Round((time % 1.0) * 30.0));
return;
}
@ -3140,7 +3138,7 @@ namespace TShockAPI
TSPlayer.Server.SetTime(false, (double)((time - 15.00m) * 3600.0m));
else
TSPlayer.Server.SetTime(true, (double)(time * 3600.0m));
TSPlayer.All.SendInfoMessage("{0} set the time to {1:D2}:{2:D2}.", args.Player.Name, hours, minutes);
TSPlayer.All.SendInfoMessage("{0} set the time to {1}:{2:D2}.", args.Player.Name, hours, minutes);
break;
}
}

View file

@ -1020,42 +1020,70 @@ namespace TShockAPI
//RconHandler.Response += msg + "\n";
}
public void SetFullMoon(bool fullmoon)
public void SetFullMoon()
{
Main.dayTime = false;
Main.moonPhase = 0;
SetTime(false, 0);
Main.time = 0.0;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
}
public void SetBloodMoon(bool bloodMoon)
{
Main.bloodMoon = bloodMoon;
SetTime(false, 0);
if (bloodMoon)
{
Main.dayTime = false;
Main.bloodMoon = true;
Main.time = 0.0;
}
else
Main.bloodMoon = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
}
public void SetFrostMoon(bool frostMoon)
public void SetFrostMoon(bool snowMoon)
{
Main.snowMoon = frostMoon;
SetTime(false, 0);
if (snowMoon)
{
Main.dayTime = false;
Main.snowMoon = true;
Main.time = 0.0;
}
else
Main.snowMoon = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
}
public void SetPumpkinMoon(bool pumpkinMoon)
{
Main.pumpkinMoon = pumpkinMoon;
SetTime(false, 0);
if (pumpkinMoon)
{
Main.dayTime = false;
Main.pumpkinMoon = true;
Main.time = 0.0;
}
else
Main.pumpkinMoon = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
}
public void SetEclipse(bool Eclipse)
public void SetEclipse(bool eclipse)
{
Main.eclipse = Eclipse;
SetTime(true, 150);
if (eclipse)
{
Main.dayTime = Main.eclipse = true;
Main.time = 0.0;
}
else
Main.eclipse = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
}
public void SetTime(bool dayTime, double time)
{
Main.dayTime = dayTime;
Main.time = time;
NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
// NetMessage.syncPlayers(); Is not in any way resposnsible for time...
TSPlayer.All.SendData(PacketTypes.TimeSet, "", 0, 0, Main.sunModY, Main.moonModY);
}
public void SpawnNPC(int type, string name, int amount, int startTileX, int startTileY, int tileXRange = 100,