mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
Add build types (normal/nomodify/modifyonly)
This commit is contained in:
parent
47911b6e29
commit
3646407eef
@ -34,8 +34,9 @@ namespace MCGalaxy.Commands {
|
||||
if (message == "") {
|
||||
Player.SendMessage(p, "Map authors: " + p.level.Authors);
|
||||
Player.SendMessage(p, "Pillaring allowed: " + p.level.Pillaring);
|
||||
Player.SendMessage(p, "Build type: " + p.level.BuildType);
|
||||
}
|
||||
p.level.Authors = message.Replace(" ", "%S, ")
|
||||
p.level.Authors = message.Replace(" ", "%S, ");
|
||||
Player.SendMessage(p, "Sets the authors of the map to: " + message);
|
||||
}
|
||||
|
||||
|
@ -30,17 +30,17 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
if (p.assertingSurvive) {
|
||||
Player.SendMessage(p, "You cannot un-assert that you will be infected."); return;
|
||||
if (p.pledgeSurvive) {
|
||||
Player.SendMessage(p, "You cannot un-pledge that you will be infected."); return;
|
||||
}
|
||||
|
||||
p.assertingSurvive = true;
|
||||
p.pledgeSurvive = true;
|
||||
Server.zombie.CurrentLevel
|
||||
.ChatLevel(p.FullName + " %Sasserts that they will not succumb to the infection!");
|
||||
.ChatLevel(p.FullName + " %Spledges that they will not succumb to the infection!");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "%T/human %H- asserts that you will not be infected.");
|
||||
Player.SendMessage(p, "%T/human %H- pledges that you will not be infected.");
|
||||
Player.SendMessage(p, "%HIf you survive, you receive an &aextra 5 %3" + Server.moneys);
|
||||
Player.SendMessage(p, "%HHowever, if you are infected, you will &close 2 %3" + Server.moneys);
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ namespace MCGalaxy.Games
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in online) {
|
||||
pl.ratedMap = false;
|
||||
pl.assertingSurvive = false;
|
||||
pl.pledgeSurvive = false;
|
||||
if (pl.level == oldMap)
|
||||
{
|
||||
if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");
|
||||
|
@ -193,9 +193,9 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
void CheckAssertHuman(Player pAlive) {
|
||||
if (!pAlive.assertingSurvive) return;
|
||||
pAlive.assertingSurvive = false;
|
||||
CurrentLevel.ChatLevel(pAlive.FullName + "%Sfailed the challenge of not being infected.");
|
||||
if (!pAlive.pledgeSurvive) return;
|
||||
pAlive.pledgeSurvive = false;
|
||||
CurrentLevel.ChatLevel(pAlive.FullName + "%Sbroke their pledge of not being infected.");
|
||||
pAlive.money = Math.Max(pAlive.money - 2, 0);
|
||||
pAlive.OnMoneyChanged();
|
||||
}
|
||||
@ -254,9 +254,9 @@ namespace MCGalaxy.Games {
|
||||
ResetPlayer(pl, ref playersString);
|
||||
} else {
|
||||
foreach (Player pl in alive) {
|
||||
if (pl.assertingSurvive) {
|
||||
if (pl.pledgeSurvive) {
|
||||
pl.SendMessage("You received &a5 %3" + Server.moneys +
|
||||
"%s for successfully asserting that you would survive.");
|
||||
"%s for successfully pledging that you would survive.");
|
||||
pl.money += 5;
|
||||
pl.OnMoneyChanged();
|
||||
}
|
||||
|
@ -24,6 +24,14 @@ namespace MCGalaxy.Games {
|
||||
|
||||
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||
byte action, byte tile, byte b) {
|
||||
|
||||
if (CurrentLevel.BuildType == BuildType.NoModify) {
|
||||
p.RevertBlock(x, y, z); return true;
|
||||
} else if (CurrentLevel.BuildType == BuildType.ModifyOnly
|
||||
&& p.level.GetTile(x, y, z) == Block.op_air) {
|
||||
p.RevertBlock(x, y, z); return true;
|
||||
}
|
||||
|
||||
if (action == 1 && !CurrentLevel.Pillaring && !p.referee) {
|
||||
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
|
||||
p.blocksStacked++;
|
||||
@ -113,8 +121,8 @@ namespace MCGalaxy.Games {
|
||||
|
||||
public override void PlayerJoinedServer(Player p) {
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
Player.SendMessage(p, "There is a Zombie Survival game currently in-progress! " +
|
||||
"Join it by typing /g " + CurrentLevelName);
|
||||
Player.SendMessage(p, "A Zombie Survival game is running! " +
|
||||
"Type %T/g " + CurrentLevelName + " %Sto join.");
|
||||
}
|
||||
|
||||
public override void PlayerJoinedLevel(Player p, Level oldLvl) {
|
||||
@ -132,6 +140,10 @@ namespace MCGalaxy.Games {
|
||||
p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
|
||||
p.SendMessage("This map has &a" + CurrentLevel.Likes +
|
||||
" likes %Sand &c" + CurrentLevel.Dislikes + " dislikes");
|
||||
p.SendCpeMessage(CpeMessageType.Status2,
|
||||
"%SPillaring " + (CurrentLevel.Pillaring ? "&aAllowed" : "&cForbidden") +
|
||||
"%S, Type is &a" + CurrentLevel.BuildType);
|
||||
|
||||
if (CurrentLevel.Authors != "")
|
||||
p.SendMessage("It was created by " + CurrentLevel.Authors);
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight1, "%SYou have &a" + p.money + " %S" + Server.moneys);
|
||||
@ -141,6 +153,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
|
||||
p.SendCpeMessage(CpeMessageType.Status1, "");
|
||||
p.SendCpeMessage(CpeMessageType.Status2, "");
|
||||
Alive.Remove(p);
|
||||
Infected.Remove(p);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace MCGalaxy.Games {
|
||||
online = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in online) {
|
||||
pl.ratedMap = false;
|
||||
pl.assertingSurvive = false;
|
||||
pl.pledgeSurvive = false;
|
||||
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
|
||||
pl.SendMessage("Going to the next map!");
|
||||
Command.all.Find("goto").Use(pl, next);
|
||||
@ -204,7 +204,7 @@ namespace MCGalaxy.Games {
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in online) {
|
||||
pl.ratedMap = false;
|
||||
pl.assertingSurvive = false;
|
||||
pl.pledgeSurvive = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ namespace MCGalaxy {
|
||||
SendDefineBlock(pl, def);
|
||||
|
||||
if (pl.HasCpeExt(CpeExt.BlockPermissions))
|
||||
pl.SendSetBlockPermission(def.BlockID, pl.level.Buildable, pl.level.Deletable);
|
||||
pl.SendSetBlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete);
|
||||
}
|
||||
Save(global, level);
|
||||
}
|
||||
@ -197,7 +197,7 @@ namespace MCGalaxy {
|
||||
SendDefineBlock(pl, def);
|
||||
|
||||
if (pl.HasCpeExt(CpeExt.BlockPermissions))
|
||||
pl.SendSetBlockPermission(def.BlockID, pl.level.Buildable, pl.level.Deletable);
|
||||
pl.SendSetBlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ using System.IO.Compression;
|
||||
|
||||
namespace MCGalaxy.Levels.IO {
|
||||
|
||||
//WARNING! DO NOT CHANGE THE WAY THE LEVEL IS SAVED/LOADED!
|
||||
//You MUST make it able to save and load as a new version other wise you will make old levels incompatible!
|
||||
public static class LvlFile {
|
||||
|
||||
public static void Save(Level level, string file) {
|
||||
|
@ -35,17 +35,13 @@ using MCGalaxy.Levels.IO;
|
||||
|
||||
namespace MCGalaxy
|
||||
{
|
||||
public enum LevelPermission //int is default
|
||||
{
|
||||
Banned = -20,
|
||||
Guest = 0,
|
||||
Builder = 30,
|
||||
AdvBuilder = 50,
|
||||
Operator = 80,
|
||||
Admin = 100,
|
||||
Nobody = 120,
|
||||
Null = 150
|
||||
public enum LevelPermission {
|
||||
Banned = -20, Guest = 0, Builder = 30,
|
||||
AdvBuilder = 50, Operator = 80,
|
||||
Admin = 100, Nobody = 120, Null = 150
|
||||
}
|
||||
|
||||
public enum BuildType { Normal, ModifyOnly, NoModify };
|
||||
|
||||
public sealed partial class Level : IDisposable
|
||||
{
|
||||
@ -208,7 +204,10 @@ namespace MCGalaxy
|
||||
public int Likes, Dislikes;
|
||||
public string Authors = "";
|
||||
public bool Pillaring = !Server.zombie.noPillaring;
|
||||
|
||||
public BuildType BuildType = BuildType.Normal;
|
||||
public bool CanPlace { get { return Buildable && BuildType != BuildType.NoModify; } }
|
||||
public bool CanDelete { get { return Deletable && BuildType != BuildType.NoModify; } }
|
||||
|
||||
public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false)
|
||||
{
|
||||
//onLevelSave += null;
|
||||
|
@ -239,18 +239,15 @@ namespace MCGalaxy
|
||||
public void SendCurrentBlockPermissions() {
|
||||
byte count = hasCustomBlocks ? Block.CpeCount : Block.OriginalCount;
|
||||
for (byte i = 0; i < count; i++) {
|
||||
bool canPlace = Block.canPlace(this, i);
|
||||
bool canDelete = canPlace;
|
||||
|
||||
if (!level.Buildable) canPlace = false;
|
||||
if (!level.Deletable) canDelete = false;
|
||||
bool canPlace = Block.canPlace(this, i) && level.CanPlace;
|
||||
bool canDelete = Block.canPlace(this, i) && level.CanDelete;
|
||||
SendSetBlockPermission(i, canPlace, canDelete);
|
||||
}
|
||||
|
||||
if (!hasBlockDefs) return;
|
||||
for (int i = count; i < 256; i++) {
|
||||
if (level.CustomBlockDefs[i] == null) continue;
|
||||
SendSetBlockPermission((byte)i, level.Buildable, level.Deletable);
|
||||
SendSetBlockPermission((byte)i, level.CanPlace, level.CanDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ namespace MCGalaxy {
|
||||
public int playersInfected = 0;
|
||||
internal string lastSpawnColor = "";
|
||||
internal bool ratedMap = false;
|
||||
internal bool assertingSurvive = false;
|
||||
internal bool pledgeSurvive = false;
|
||||
|
||||
//Tnt Wars
|
||||
public bool PlayingTntWars = false;
|
||||
@ -341,9 +341,8 @@ namespace MCGalaxy {
|
||||
byte head = level.GetTile(x, y, z);
|
||||
byte feet = level.GetTile(x, (ushort)(y - 1), z);
|
||||
|
||||
if (Block.Walkthrough(Block.Convert(head)) && Block.Walkthrough(Block.Convert(feet)))
|
||||
return false;
|
||||
return Block.Convert(head) != Block.Zero && Block.Convert(head) != Block.op_air;
|
||||
return (Block.Walkthrough(Block.Convert(head)) || head == Block.Zero)
|
||||
&& (Block.Walkthrough(Block.Convert(feet)) || feet == Block.Zero);
|
||||
}
|
||||
|
||||
//This is so that plugin devs can declare a player without needing a socket..
|
||||
|
Loading…
x
Reference in New Issue
Block a user