mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Cancel countdown when the map is unloaded. Fixes #375.
This commit is contained in:
parent
dbb2569efb
commit
d9f67fd562
@ -253,7 +253,7 @@ namespace MCGalaxy.Commands.Fun {
|
||||
case CountdownGameStatus.Disabled:
|
||||
Player.Message(p, "Countdown is not running."); break;
|
||||
case CountdownGameStatus.Enabled:
|
||||
Player.Message(p, "No round is not running."); break;
|
||||
Player.Message(p, "No round is currently running."); break;
|
||||
default:
|
||||
game.EndRound(null); break;
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ namespace MCGalaxy {
|
||||
|
||||
public delegate void OnLevelLoad(string level);
|
||||
|
||||
public delegate void OnLevelLoaded(Level l);
|
||||
public delegate void OnLevelLoaded(Level lvl);
|
||||
|
||||
public delegate void OnLevelSave(Level l);
|
||||
public delegate void OnLevelSave(Level lvl);
|
||||
|
||||
public delegate void OnLevelUnload(Level l);
|
||||
public delegate void OnLevelUnload(Level lvl);
|
||||
|
||||
public delegate void OnPhysicsUpdate(ushort x, ushort y, ushort z, PhysicsArgs args, Level l);
|
||||
public delegate void OnPhysicsUpdate(ushort x, ushort y, ushort z, PhysicsArgs args, Level lvl);
|
||||
|
||||
public delegate void OnPhysicsStateChanged(object sender, PhysicsState state);
|
||||
|
||||
|
@ -46,19 +46,13 @@ namespace MCGalaxy.Games {
|
||||
public string SpeedType;
|
||||
|
||||
|
||||
CountdownPlugin plugin;
|
||||
CountdownPlugin plugin = new CountdownPlugin();
|
||||
List<SquarePos> squaresLeft = new List<SquarePos>();
|
||||
|
||||
|
||||
#region Round
|
||||
|
||||
public void BeginRound(Player p) {
|
||||
if (plugin == null) {
|
||||
plugin = new CountdownPlugin();
|
||||
plugin.Game = this;
|
||||
plugin.Load(false);
|
||||
}
|
||||
|
||||
ResetMap();
|
||||
SetGlassTube(Block.glass, Block.glass);
|
||||
Map.ChatLevel("Countdown is about to start!");
|
||||
@ -108,7 +102,9 @@ namespace MCGalaxy.Games {
|
||||
pl.SendMessage("Sending you to the correct map.");
|
||||
PlayerActions.ChangeMap(pl, Map.name);
|
||||
}
|
||||
|
||||
Entities.Spawn(pl, pl, pos, pl.Rot);
|
||||
pl.SendPos(Entities.SelfID, pos, pl.Rot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,6 +299,9 @@ namespace MCGalaxy.Games {
|
||||
|
||||
|
||||
public void Enable(Player p) {
|
||||
plugin.Game = this;
|
||||
plugin.Load(false);
|
||||
|
||||
CmdLoad.LoadLevel(null, "countdown");
|
||||
Map = LevelInfo.FindExact("countdown");
|
||||
|
||||
@ -325,6 +324,8 @@ namespace MCGalaxy.Games {
|
||||
if (Status == CountdownGameStatus.RoundInProgress) EndRound(null);
|
||||
|
||||
Status = CountdownGameStatus.Disabled;
|
||||
plugin.Unload(false);
|
||||
|
||||
Map.ChatLevel("Countdown was disabled.");
|
||||
Players.Clear();
|
||||
Remaining.Clear();
|
||||
@ -390,7 +391,7 @@ namespace MCGalaxy.Games {
|
||||
if (!Players.Contains(p)) {
|
||||
Players.Add(p);
|
||||
Player.Message(p, "You've joined countdown!");
|
||||
Chat.MessageGlobal("{0} %Sjoined Countdown!", p.ColoredName);
|
||||
Chat.MessageGlobal("{0} %Sjoined countdown!", p.ColoredName);
|
||||
if (p.level != Map) PlayerActions.ChangeMap(p, "countdown");
|
||||
} else {
|
||||
Player.Message(p, "You've already joined countdown. To leave type /countdown leave");
|
||||
|
@ -16,7 +16,6 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MCGalaxy.Events;
|
||||
|
||||
namespace MCGalaxy.Games {
|
||||
@ -29,11 +28,13 @@ namespace MCGalaxy.Games {
|
||||
public override void Load(bool startup) {
|
||||
OnPlayerMoveEvent.Register(HandlePlayerMove, Priority.High, this);
|
||||
OnPlayerDisconnectEvent.Register(HandlePlayerDisconnect, Priority.High, this);
|
||||
OnLevelUnloadEvent.Register(HandleLevelUnload, Priority.High, this);
|
||||
}
|
||||
|
||||
public override void Unload(bool shutdown) {
|
||||
OnPlayerMoveEvent.UnRegister(this);
|
||||
OnPlayerDisconnectEvent.UnRegister(this);
|
||||
OnLevelUnloadEvent.UnRegister(this);
|
||||
}
|
||||
|
||||
|
||||
@ -60,5 +61,10 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
Game.Players.Remove(p);
|
||||
}
|
||||
|
||||
void HandleLevelUnload(Level lvl) {
|
||||
if (Game.Status == CountdownGameStatus.Disabled || lvl != Game.Map) return;
|
||||
Game.Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user