diff --git a/MCGalaxy/Blocks/BlockOptions.cs b/MCGalaxy/Blocks/BlockOptions.cs index 447ae76e4..e8487413f 100644 --- a/MCGalaxy/Blocks/BlockOptions.cs +++ b/MCGalaxy/Blocks/BlockOptions.cs @@ -33,43 +33,41 @@ namespace MCGalaxy.Blocks { public static class BlockOptions { 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 Options = new List() { - 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(Rails, SetRails, "%HToggles whether %Strain %Hblocks can run over 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(Door, SetDoor, "%HToggles whether this block is a Door 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(DeathMsg, SetDeathMsg, "%HSets or removes the death message for this block " + + new BlockOption("Portal", SetPortal, "%HToggles whether the block is a %T/Portal"), + 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("WaterKills", SetWater, "%HToggles whether flooding water 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("tDoor", SetTDoor, "%HToggles whether this block is a tDoor block"), + new BlockOption("Killer", SetKiller, "%HToggles whether colliding with this block kills player"), + 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"), - 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()), - 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)"), - 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."), - 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)"), - 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)"), - 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)"), + 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) { - if (opt.CaselessEq("mb")) opt = MB; - if (opt.CaselessEq("death")) opt = Killer; - if (opt.CaselessEq("deathmsg")) opt = DeathMsg; - if (opt.CaselessEq("animal")) opt = AI; - if (opt.CaselessEq("stackid")) opt = StackId; - if (opt.CaselessEq("drown")) opt = Drownable; + if (opt.CaselessEq("MB")) opt = "MessageBlock"; + if (opt.CaselessEq("Death")) opt = "Killer"; + if (opt.CaselessEq("DeathMsg")) opt = "DeathMessage"; + if (opt.CaselessEq("Animal")) opt = "AnimalAI"; + if (opt.CaselessEq("StackID")) opt = "StackBlock"; + if (opt.CaselessEq("Drown")) opt = "Drownable"; foreach (BlockOption option in Options) { 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 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 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) { on = !on; diff --git a/MCGalaxy/Blocks/BlockProperties.cs b/MCGalaxy/Blocks/BlockProperties.cs index df1de58b4..e52555e52 100644 --- a/MCGalaxy/Blocks/BlockProperties.cs +++ b/MCGalaxy/Blocks/BlockProperties.cs @@ -39,7 +39,7 @@ namespace MCGalaxy.Blocks { public bool IsTDoor; /// Whether this block is considered a door. public bool IsDoor; - /// Extended block ID of the block this is converted to when toggled by a neighbouring door. + /// Block ID of the block this is converted to when toggled by a neighbouring door. public BlockID oDoorBlock; /// Whether this block is considered a message block. @@ -61,17 +61,17 @@ namespace MCGalaxy.Blocks { /// Animal AI behaviour of this block. public AnimalAI AnimalAI; - /// The extended block ID that is placed when two of this block are placed on top of each other. + /// Block ID that is placed when two of this block are placed on top of each other. /// e.g. slabs and cobblestone slabs. public BlockID StackBlock; /// Whether players can drown inside this block (e.g. water). public bool Drownable; - /// The extended block ID this is changed into when exposed to sunlight. + /// Block ID this is changed into when exposed to sunlight. public BlockID GrassBlock; - /// The extended block ID this is changed into when no longer exposed to sunlight. + /// Block ID this is changed into when no longer exposed to sunlight. public BlockID DirtBlock; /// Whether the properties for this block have been modified and hence require saving. diff --git a/MCGalaxy/Commands/CPE/CmdEnvironment.cs b/MCGalaxy/Commands/CPE/CmdEnvironment.cs index 9db4d9d3b..086705c57 100644 --- a/MCGalaxy/Commands/CPE/CmdEnvironment.cs +++ b/MCGalaxy/Commands/CPE/CmdEnvironment.cs @@ -53,45 +53,45 @@ namespace MCGalaxy.Commands.CPE { 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 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") { - LevelEnv.SetColor(p, value, area, "cloud color", ref cfg.CloudColor); + EnvOptions.SetColor(p, value, area, "cloud color", ref cfg.CloudColor); } 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") { - 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") { - LevelEnv.SetColor(p, value, area, "sun color", ref cfg.LightColor); + EnvOptions.SetColor(p, value, area, "sun color", ref cfg.LightColor); } 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") { - 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") { - 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") { - 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") { - 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") { - LevelEnv.SetFloat(p, value, area, 256, "clouds speed", + EnvOptions.SetFloat(p, value, area, 256, "clouds speed", ref cfg.CloudsSpeed, -0xFFFFFF, 0xFFFFFF); } 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); } 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); } 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") { - LevelEnv.SetBlock(p, value, area, "sides block", ref cfg.EdgeBlock); + EnvOptions.SetBlock(p, value, area, "sides block", ref cfg.EdgeBlock); } 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") { - LevelEnv.SetFloat(p, value, area, 1024, "skybox horizontal speed", + EnvOptions.SetFloat(p, value, area, 1024, "skybox horizontal speed", ref cfg.SkyboxHorSpeed, -0xFFFFFF, 0xFFFFFF); } 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); } else { return false; diff --git a/MCGalaxy/Levels/LevelEnv.cs b/MCGalaxy/Levels/LevelEnv.cs index 13648c5e6..aa1511455 100644 --- a/MCGalaxy/Levels/LevelEnv.cs +++ b/MCGalaxy/Levels/LevelEnv.cs @@ -16,14 +16,29 @@ permissions and limitations under the Licenses. */ using System; +using System.Collections.Generic; using MCGalaxy.Commands; using MCGalaxy.Commands.Building; using MCGalaxy.Network; using MCGalaxy.Blocks; using BlockID = System.UInt16; -namespace MCGalaxy { - public static class LevelEnv { +namespace MCGalaxy { + 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 Options = new List() { + //new EnvOption("Weather", SetWeather, "%HSets the weather (sun, rain, snow)"), + }; static bool IsResetString(string value) { return value.CaselessEq("normal") || value.CaselessEq("reset") || value.CaselessEq("default");