mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -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:
|
case CountdownGameStatus.Disabled:
|
||||||
Player.Message(p, "Countdown is not running."); break;
|
Player.Message(p, "Countdown is not running."); break;
|
||||||
case CountdownGameStatus.Enabled:
|
case CountdownGameStatus.Enabled:
|
||||||
Player.Message(p, "No round is not running."); break;
|
Player.Message(p, "No round is currently running."); break;
|
||||||
default:
|
default:
|
||||||
game.EndRound(null); break;
|
game.EndRound(null); break;
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public delegate void OnLevelLoad(string level);
|
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);
|
public delegate void OnPhysicsStateChanged(object sender, PhysicsState state);
|
||||||
|
|
||||||
|
@ -46,19 +46,13 @@ namespace MCGalaxy.Games {
|
|||||||
public string SpeedType;
|
public string SpeedType;
|
||||||
|
|
||||||
|
|
||||||
CountdownPlugin plugin;
|
CountdownPlugin plugin = new CountdownPlugin();
|
||||||
List<SquarePos> squaresLeft = new List<SquarePos>();
|
List<SquarePos> squaresLeft = new List<SquarePos>();
|
||||||
|
|
||||||
|
|
||||||
#region Round
|
#region Round
|
||||||
|
|
||||||
public void BeginRound(Player p) {
|
public void BeginRound(Player p) {
|
||||||
if (plugin == null) {
|
|
||||||
plugin = new CountdownPlugin();
|
|
||||||
plugin.Game = this;
|
|
||||||
plugin.Load(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResetMap();
|
ResetMap();
|
||||||
SetGlassTube(Block.glass, Block.glass);
|
SetGlassTube(Block.glass, Block.glass);
|
||||||
Map.ChatLevel("Countdown is about to start!");
|
Map.ChatLevel("Countdown is about to start!");
|
||||||
@ -108,7 +102,9 @@ namespace MCGalaxy.Games {
|
|||||||
pl.SendMessage("Sending you to the correct map.");
|
pl.SendMessage("Sending you to the correct map.");
|
||||||
PlayerActions.ChangeMap(pl, Map.name);
|
PlayerActions.ChangeMap(pl, Map.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.Spawn(pl, pl, pos, pl.Rot);
|
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) {
|
public void Enable(Player p) {
|
||||||
|
plugin.Game = this;
|
||||||
|
plugin.Load(false);
|
||||||
|
|
||||||
CmdLoad.LoadLevel(null, "countdown");
|
CmdLoad.LoadLevel(null, "countdown");
|
||||||
Map = LevelInfo.FindExact("countdown");
|
Map = LevelInfo.FindExact("countdown");
|
||||||
|
|
||||||
@ -325,6 +324,8 @@ namespace MCGalaxy.Games {
|
|||||||
if (Status == CountdownGameStatus.RoundInProgress) EndRound(null);
|
if (Status == CountdownGameStatus.RoundInProgress) EndRound(null);
|
||||||
|
|
||||||
Status = CountdownGameStatus.Disabled;
|
Status = CountdownGameStatus.Disabled;
|
||||||
|
plugin.Unload(false);
|
||||||
|
|
||||||
Map.ChatLevel("Countdown was disabled.");
|
Map.ChatLevel("Countdown was disabled.");
|
||||||
Players.Clear();
|
Players.Clear();
|
||||||
Remaining.Clear();
|
Remaining.Clear();
|
||||||
@ -390,7 +391,7 @@ namespace MCGalaxy.Games {
|
|||||||
if (!Players.Contains(p)) {
|
if (!Players.Contains(p)) {
|
||||||
Players.Add(p);
|
Players.Add(p);
|
||||||
Player.Message(p, "You've joined countdown!");
|
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");
|
if (p.level != Map) PlayerActions.ChangeMap(p, "countdown");
|
||||||
} else {
|
} else {
|
||||||
Player.Message(p, "You've already joined countdown. To leave type /countdown leave");
|
Player.Message(p, "You've already joined countdown. To leave type /countdown leave");
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using MCGalaxy.Events;
|
using MCGalaxy.Events;
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
namespace MCGalaxy.Games {
|
||||||
@ -29,11 +28,13 @@ namespace MCGalaxy.Games {
|
|||||||
public override void Load(bool startup) {
|
public override void Load(bool startup) {
|
||||||
OnPlayerMoveEvent.Register(HandlePlayerMove, Priority.High, this);
|
OnPlayerMoveEvent.Register(HandlePlayerMove, Priority.High, this);
|
||||||
OnPlayerDisconnectEvent.Register(HandlePlayerDisconnect, Priority.High, this);
|
OnPlayerDisconnectEvent.Register(HandlePlayerDisconnect, Priority.High, this);
|
||||||
|
OnLevelUnloadEvent.Register(HandleLevelUnload, Priority.High, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Unload(bool shutdown) {
|
public override void Unload(bool shutdown) {
|
||||||
OnPlayerMoveEvent.UnRegister(this);
|
OnPlayerMoveEvent.UnRegister(this);
|
||||||
OnPlayerDisconnectEvent.UnRegister(this);
|
OnPlayerDisconnectEvent.UnRegister(this);
|
||||||
|
OnLevelUnloadEvent.UnRegister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,5 +61,10 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
Game.Players.Remove(p);
|
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