Fix missing oDoor block property in /blockprops

This commit is contained in:
UnknownShadow200 2018-10-04 10:07:41 +10:00
parent 0c5411befd
commit 2f4b61d6ee
4 changed files with 64 additions and 50 deletions

View File

@ -33,43 +33,41 @@ namespace MCGalaxy.Blocks {
public static class BlockOptions { public static class BlockOptions {
public delegate void OptionSetter(Player p, BlockProps[] scope, BlockID b, string value); public delegate void OptionSetter(Player p, BlockProps[] scope, BlockID b, string value);
public const string Portal = "Portal", MB = "MessageBlock", Rails = "Rails", WaterKills = "WaterKills";
public const string LavaKills = "LavaKills", Door = "Door", tDoor = "tDoor", Killer = "Killer";
public const string DeathMsg = "DeathMessage", AI = "AnimalAI", StackId = "StackBlock", OPBlock = "OPBlock";
public const string oDoor = "oDoor", Drownable = "Drownable", Grass = "Grass", Dirt = "Dirt";
public static List<BlockOption> Options = new List<BlockOption>() { public static List<BlockOption> Options = new List<BlockOption>() {
new BlockOption(Portal, SetPortal, "%HToggles whether the block is a %T/Portal"), new BlockOption("Portal", SetPortal, "%HToggles whether the block is a %T/Portal"),
new BlockOption(MB, SetMB, "%HToggles whether the block is a %T/MessageBlock"), new BlockOption("MessageBlock", SetMB, "%HToggles whether the block is a %T/MessageBlock"),
new BlockOption(Rails, SetRails, "%HToggles whether %Strain %Hblocks can run over this block"), new BlockOption("Rails", SetRails, "%HToggles whether %Strain %Hblocks can run over this block"),
new BlockOption(WaterKills, SetWater, "%HToggles whether flooding water kills this block"), new BlockOption("WaterKills", SetWater, "%HToggles whether flooding water kills this block"),
new BlockOption(LavaKills, SetLava, "%HToggles whether flooding lava kills this block"), new BlockOption("LavaKills", SetLava, "%HToggles whether flooding lava kills this block"),
new BlockOption(Door, SetDoor, "%HToggles whether this block is a Door block"), new BlockOption("Door", SetDoor, "%HToggles whether this block is a Door block"),
new BlockOption(tDoor, SetTDoor, "%HToggles whether this block is a tDoor block"), new BlockOption("tDoor", SetTDoor, "%HToggles whether this block is a tDoor block"),
new BlockOption(Killer, SetKiller, "%HToggles whether colliding with this block kills player"), new BlockOption("Killer", SetKiller, "%HToggles whether colliding with this block kills player"),
new BlockOption(DeathMsg, SetDeathMsg, "%HSets or removes the death message for this block " + new BlockOption("DeathMessage", SetDeathMsg, "%HSets or removes the death message for this block " +
"(Note: %S@p %His a placeholder for name of player who dies"), "(Note: %S@p %His a placeholder for name of player who dies"),
new BlockOption(AI, SetAI, "%HSets the flying or swimming animal AI for this block. " + new BlockOption("AnimalAI", SetAI, "%HSets the flying or swimming animal AI for this block. " +
"Types: &f" + Enum.GetNames(typeof(AnimalAI)).Join()), "Types: &f" + Enum.GetNames(typeof(AnimalAI)).Join()),
new BlockOption(StackId, SetStackId,"%HSets the block this block is changed into, when placed on top " + new BlockOption("StackBlock", SetStackId,"%HSets the block this block is changed into, when placed on top " +
"of itself (e.g. placing a slab on top of another slab turns into a double slab)"), "of itself (e.g. placing a slab on top of another slab turns into a double slab)"),
new BlockOption(OPBlock, SetOPBlock,"%HMarks the block as being on OP block. OP blocks can't be " + new BlockOption("OPBlock", SetOPBlock,"%HMarks the block as being on OP block. OP blocks can't be " +
"blown up by explosions, and can't be replaced in games when build type is ModifyOnly."), "blown up by explosions, and can't be replaced in games when build type is ModifyOnly."),
new BlockOption(Drownable, SetDrown, "%HSets whether this block can drown players " + new BlockOption("Drownable", SetDrown, "%HSets whether this block can drown players " +
"(Note %T/Map death %Hmust be enabled for players to drown)"), "(Note %T/Map death %Hmust be enabled for players to drown)"),
new BlockOption(Grass, SetGrass, "%HSets the block that this block is changed into, " + new BlockOption("Grass", SetGrass, "%HSets the block that this block is changed into, " +
"when exposed to sunlight (leave block blank to remove)"), "when exposed to sunlight (leave block blank to remove)"),
new BlockOption(Dirt, SetDirt, "%HSets the block that this block is changed into, " + new BlockOption("Dirt", SetDirt, "%HSets the block that this block is changed into, " +
"when no longer exposed to sunlight (leave block blank to remove)"), "when no longer exposed to sunlight (leave block blank to remove)"),
new BlockOption("oDoor", SetODoor, "%HSets the block that this block is changed into, " +
"when activated by a neighbouring door"),
}; };
public static BlockOption Find(string opt) { public static BlockOption Find(string opt) {
if (opt.CaselessEq("mb")) opt = MB; if (opt.CaselessEq("MB")) opt = "MessageBlock";
if (opt.CaselessEq("death")) opt = Killer; if (opt.CaselessEq("Death")) opt = "Killer";
if (opt.CaselessEq("deathmsg")) opt = DeathMsg; if (opt.CaselessEq("DeathMsg")) opt = "DeathMessage";
if (opt.CaselessEq("animal")) opt = AI; if (opt.CaselessEq("Animal")) opt = "AnimalAI";
if (opt.CaselessEq("stackid")) opt = StackId; if (opt.CaselessEq("StackID")) opt = "StackBlock";
if (opt.CaselessEq("drown")) opt = Drownable; if (opt.CaselessEq("Drown")) opt = "Drownable";
foreach (BlockOption option in Options) { foreach (BlockOption option in Options) {
if (option.Name.CaselessEq(opt)) return option; if (option.Name.CaselessEq(opt)) return option;
@ -129,6 +127,7 @@ namespace MCGalaxy.Blocks {
static void SetDrown(Player p, BlockProps[] s, BlockID b, string v) { Toggle(p,s,b, "drowns players", ref s[b].Drownable); } static void SetDrown(Player p, BlockProps[] s, BlockID b, string v) { Toggle(p,s,b, "drowns players", ref s[b].Drownable); }
static void SetGrass(Player p, BlockProps[] s, BlockID b, string v) { SetBlock(p,s,b,v, "Grass form", ref s[b].GrassBlock); } static void SetGrass(Player p, BlockProps[] s, BlockID b, string v) { SetBlock(p,s,b,v, "Grass form", ref s[b].GrassBlock); }
static void SetDirt(Player p, BlockProps[] s, BlockID b, string v) { SetBlock(p,s,b,v, "Dirt form", ref s[b].DirtBlock); } static void SetDirt(Player p, BlockProps[] s, BlockID b, string v) { SetBlock(p,s,b,v, "Dirt form", ref s[b].DirtBlock); }
static void SetODoor(Player p, BlockProps[] s, BlockID b, string v) { SetBlock(p,s,b,v, "oDoor form", ref s[b].oDoorBlock); }
static void Toggle(Player p, BlockProps[] scope, BlockID block, string type, ref bool on) { static void Toggle(Player p, BlockProps[] scope, BlockID block, string type, ref bool on) {
on = !on; on = !on;

View File

@ -39,7 +39,7 @@ namespace MCGalaxy.Blocks {
public bool IsTDoor; public bool IsTDoor;
/// <summary> Whether this block is considered a door. </summary> /// <summary> Whether this block is considered a door. </summary>
public bool IsDoor; public bool IsDoor;
/// <summary> Extended block ID of the block this is converted to when toggled by a neighbouring door. </summary> /// <summary> Block ID of the block this is converted to when toggled by a neighbouring door. </summary>
public BlockID oDoorBlock; public BlockID oDoorBlock;
/// <summary> Whether this block is considered a message block. </summary> /// <summary> Whether this block is considered a message block. </summary>
@ -61,17 +61,17 @@ namespace MCGalaxy.Blocks {
/// <summary> Animal AI behaviour of this block. </summary> /// <summary> Animal AI behaviour of this block. </summary>
public AnimalAI AnimalAI; public AnimalAI AnimalAI;
/// <summary> The extended block ID that is placed when two of this block are placed on top of each other. </summary> /// <summary> Block ID that is placed when two of this block are placed on top of each other. </summary>
/// <remarks> e.g. slabs and cobblestone slabs. </remarks> /// <remarks> e.g. slabs and cobblestone slabs. </remarks>
public BlockID StackBlock; public BlockID StackBlock;
/// <summary> Whether players can drown inside this block (e.g. water). </summary> /// <summary> Whether players can drown inside this block (e.g. water). </summary>
public bool Drownable; public bool Drownable;
/// <summary> The extended block ID this is changed into when exposed to sunlight. </summary> /// <summary> Block ID this is changed into when exposed to sunlight. </summary>
public BlockID GrassBlock; public BlockID GrassBlock;
/// <summary> The extended block ID this is changed into when no longer exposed to sunlight. </summary> /// <summary> Block ID this is changed into when no longer exposed to sunlight. </summary>
public BlockID DirtBlock; public BlockID DirtBlock;
/// <summary> Whether the properties for this block have been modified and hence require saving. </summary> /// <summary> Whether the properties for this block have been modified and hence require saving. </summary>

View File

@ -53,45 +53,45 @@ namespace MCGalaxy.Commands.CPE {
internal static bool Handle(Player p, Level lvl, string opt, string value, AreaConfig cfg, string area) { internal static bool Handle(Player p, Level lvl, string opt, string value, AreaConfig cfg, string area) {
// using if else instead of switch here reduces IL by about 200 bytes // using if else instead of switch here reduces IL by about 200 bytes
if (opt == "sky") { if (opt == "sky") {
LevelEnv.SetColor(p, value, area, "sky color", ref cfg.SkyColor); EnvOptions.SetColor(p, value, area, "sky color", ref cfg.SkyColor);
} else if (opt == "cloud" || opt == "clouds") { } else if (opt == "cloud" || opt == "clouds") {
LevelEnv.SetColor(p, value, area, "cloud color", ref cfg.CloudColor); EnvOptions.SetColor(p, value, area, "cloud color", ref cfg.CloudColor);
} else if (opt == "fog") { } else if (opt == "fog") {
LevelEnv.SetColor(p, value, area, "fog color", ref cfg.FogColor); EnvOptions.SetColor(p, value, area, "fog color", ref cfg.FogColor);
} else if (opt == "dark" || opt == "shadow") { } else if (opt == "dark" || opt == "shadow") {
LevelEnv.SetColor(p, value, area, "shadow color", ref cfg.ShadowColor); EnvOptions.SetColor(p, value, area, "shadow color", ref cfg.ShadowColor);
} else if (opt == "sun" || opt == "light" || opt == "sunlight") { } else if (opt == "sun" || opt == "light" || opt == "sunlight") {
LevelEnv.SetColor(p, value, area, "sun color", ref cfg.LightColor); EnvOptions.SetColor(p, value, area, "sun color", ref cfg.LightColor);
} else if (opt == "weather") { } else if (opt == "weather") {
LevelEnv.SetWeather(p, value, area, ref cfg.Weather); EnvOptions.SetWeather(p, value, area, ref cfg.Weather);
} else if (opt == "cloudheight" || opt == "cloudsheight") { } else if (opt == "cloudheight" || opt == "cloudsheight") {
LevelEnv.SetShort(p, value, area, "clouds height", ref cfg.CloudsHeight); EnvOptions.SetShort(p, value, area, "clouds height", ref cfg.CloudsHeight);
} else if (opt == "waterlevel" || opt == "edgelevel" || opt == "level") { } else if (opt == "waterlevel" || opt == "edgelevel" || opt == "level") {
LevelEnv.SetShort(p, value, area, "water level", ref cfg.EdgeLevel); EnvOptions.SetShort(p, value, area, "water level", ref cfg.EdgeLevel);
} else if (opt == "bedrockoffset" || opt == "sidesoffset" || opt == "sideoffset") { } else if (opt == "bedrockoffset" || opt == "sidesoffset" || opt == "sideoffset") {
LevelEnv.SetShort(p, value, area, "bedrock offset", ref cfg.SidesOffset); EnvOptions.SetShort(p, value, area, "bedrock offset", ref cfg.SidesOffset);
} else if (opt == "maxfogdistance" || opt == "maxfog" || opt == "fogdistance") { } else if (opt == "maxfogdistance" || opt == "maxfog" || opt == "fogdistance") {
LevelEnv.SetShort(p, value, area, "max fog distance", ref cfg.MaxFogDistance); EnvOptions.SetShort(p, value, area, "max fog distance", ref cfg.MaxFogDistance);
} else if (opt == "cloudspeed" || opt == "cloudsspeed") { } else if (opt == "cloudspeed" || opt == "cloudsspeed") {
LevelEnv.SetFloat(p, value, area, 256, "clouds speed", EnvOptions.SetFloat(p, value, area, 256, "clouds speed",
ref cfg.CloudsSpeed, -0xFFFFFF, 0xFFFFFF); ref cfg.CloudsSpeed, -0xFFFFFF, 0xFFFFFF);
} else if (opt == "weatherspeed") { } else if (opt == "weatherspeed") {
LevelEnv.SetFloat(p, value, area, 256, "weather speed", EnvOptions.SetFloat(p, value, area, 256, "weather speed",
ref cfg.WeatherSpeed, -0xFFFFFF, 0xFFFFFF); ref cfg.WeatherSpeed, -0xFFFFFF, 0xFFFFFF);
} else if (opt == "weatherfade") { } else if (opt == "weatherfade") {
LevelEnv.SetFloat(p, value, area, 128, "weather fade rate", EnvOptions.SetFloat(p, value, area, 128, "weather fade rate",
ref cfg.WeatherFade, 0, 255); ref cfg.WeatherFade, 0, 255);
} else if (opt == "horizon" || opt == "edge" || opt == "water") { } else if (opt == "horizon" || opt == "edge" || opt == "water") {
LevelEnv.SetBlock(p, value, area, "edge block", ref cfg.HorizonBlock); EnvOptions.SetBlock(p, value, area, "edge block", ref cfg.HorizonBlock);
} else if (opt == "side" || opt == "border" || opt == "bedrock") { } else if (opt == "side" || opt == "border" || opt == "bedrock") {
LevelEnv.SetBlock(p, value, area, "sides block", ref cfg.EdgeBlock); EnvOptions.SetBlock(p, value, area, "sides block", ref cfg.EdgeBlock);
} else if (opt == "expfog") { } else if (opt == "expfog") {
LevelEnv.SetBool(p, value, area, "exp fog", 0, ref cfg.ExpFog); EnvOptions.SetBool(p, value, area, "exp fog", 0, ref cfg.ExpFog);
} else if (opt == "skyboxhorspeed" || opt == "skyboxhor") { } else if (opt == "skyboxhorspeed" || opt == "skyboxhor") {
LevelEnv.SetFloat(p, value, area, 1024, "skybox horizontal speed", EnvOptions.SetFloat(p, value, area, 1024, "skybox horizontal speed",
ref cfg.SkyboxHorSpeed, -0xFFFFFF, 0xFFFFFF); ref cfg.SkyboxHorSpeed, -0xFFFFFF, 0xFFFFFF);
} else if (opt == "skyboxverspeed" || opt == "skyboxver") { } else if (opt == "skyboxverspeed" || opt == "skyboxver") {
LevelEnv.SetFloat(p, value, area, 1024, "skybox vertical speed", EnvOptions.SetFloat(p, value, area, 1024, "skybox vertical speed",
ref cfg.SkyboxVerSpeed, -0xFFFFFF, 0xFFFFFF); ref cfg.SkyboxVerSpeed, -0xFFFFFF, 0xFFFFFF);
} else { } else {
return false; return false;

View File

@ -16,6 +16,7 @@
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System; using System;
using System.Collections.Generic;
using MCGalaxy.Commands; using MCGalaxy.Commands;
using MCGalaxy.Commands.Building; using MCGalaxy.Commands.Building;
using MCGalaxy.Network; using MCGalaxy.Network;
@ -23,7 +24,21 @@ using MCGalaxy.Blocks;
using BlockID = System.UInt16; using BlockID = System.UInt16;
namespace MCGalaxy { namespace MCGalaxy {
public static class LevelEnv { public sealed class EnvOption {
public string Name, Help;
public EnvOptions.OptionSetter SetFunc;
public EnvOption(string name, EnvOptions.OptionSetter func, string help) {
Name = name; SetFunc = func; Help = help;
}
}
public static class EnvOptions {
public delegate void OptionSetter(Player p, string area, LevelConfig cfg, string value);
public static List<EnvOption> Options = new List<EnvOption>() {
//new EnvOption("Weather", SetWeather, "%HSets the weather (sun, rain, snow)"),
};
static bool IsResetString(string value) { static bool IsResetString(string value) {
return value.CaselessEq("normal") || value.CaselessEq("reset") || value.CaselessEq("default"); return value.CaselessEq("normal") || value.CaselessEq("reset") || value.CaselessEq("default");