internal static bool Handle(Player p, Predicate <Player> selector, string opt, string value, AreaConfig cfg, string area) { Level lvl = p.level; // 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); LevelEnv.UpdateColor(selector, 0, cfg.SkyColor); } else if (opt == "cloud" || opt == "clouds") { LevelEnv.SetColor(p, value, area, "cloud color", ref cfg.CloudColor); LevelEnv.UpdateColor(selector, 1, cfg.CloudColor); } else if (opt == "fog") { LevelEnv.SetColor(p, value, area, "fog color", ref cfg.FogColor); LevelEnv.UpdateColor(selector, 2, cfg.FogColor); } else if (opt == "dark" || opt == "shadow") { LevelEnv.SetColor(p, value, area, "shadow color", ref cfg.ShadowColor); LevelEnv.UpdateColor(selector, 3, cfg.ShadowColor); } else if (opt == "sun" || opt == "light" || opt == "sunlight") { LevelEnv.SetColor(p, value, area, "sun color", ref cfg.LightColor); LevelEnv.UpdateColor(selector, 4, cfg.LightColor); } else if (opt == "weather") { LevelEnv.SetWeather(p, value, area, ref cfg.Weather); LevelEnv.UpdateWeather(selector, (byte)cfg.Weather); } else if (opt == "cloudheight" || opt == "cloudsheight") { LevelEnv.SetShort(p, value, area, "clouds height", lvl.Height + 2, ref cfg.CloudsHeight); LevelEnv.UpdateAppearance(selector, EnvProp.CloudsLevel, cfg.CloudsHeight); } else if (opt == "waterlevel" || opt == "edgelevel" || opt == "level") { LevelEnv.SetShort(p, value, area, "water level", lvl.Height / 2, ref cfg.EdgeLevel); LevelEnv.UpdateAppearance(selector, EnvProp.EdgeLevel, cfg.EdgeLevel); } else if (opt == "bedrockoffset" || opt == "sidesoffset" || opt == "sideoffset") { LevelEnv.SetShort(p, value, area, "bedrock offset", -2, ref cfg.SidesOffset); LevelEnv.UpdateAppearance(selector, EnvProp.SidesOffset, cfg.SidesOffset); } else if (opt == "maxfogdistance" || opt == "maxfog" || opt == "fogdistance") { LevelEnv.SetShort(p, value, area, "max fog distance", 0, ref cfg.MaxFogDistance); LevelEnv.UpdateAppearance(selector, EnvProp.MaxFog, cfg.MaxFogDistance); } else if (opt == "cloudspeed" || opt == "cloudsspeed") { LevelEnv.SetFloat(p, value, area, 256, "clouds speed", 256, ref cfg.CloudsSpeed, -0xFFFFFF, 0xFFFFFF); LevelEnv.UpdateAppearance(selector, EnvProp.CloudsSpeed, cfg.CloudsSpeed); } else if (opt == "weatherspeed") { LevelEnv.SetFloat(p, value, area, 256, "weather speed", 256, ref cfg.WeatherSpeed, -0xFFFFFF, 0xFFFFFF); LevelEnv.UpdateAppearance(selector, EnvProp.WeatherSpeed, cfg.WeatherSpeed); } else if (opt == "weatherfade") { LevelEnv.SetFloat(p, value, area, 128, "weather fade rate", 128, ref cfg.WeatherFade, 0, 255); LevelEnv.UpdateAppearance(selector, EnvProp.WeatherFade, cfg.WeatherFade); } else if (opt == "horizon" || opt == "edge" || opt == "water") { LevelEnv.SetBlock(p, value, area, "edge block", Block.Water, ref cfg.HorizonBlock); LevelEnv.UpdateAppearance(selector, EnvProp.EdgeBlock, cfg.HorizonBlock); } else if (opt == "side" || opt == "border" || opt == "bedrock") { LevelEnv.SetBlock(p, value, area, "sides block", Block.Bedrock, ref cfg.EdgeBlock); LevelEnv.UpdateAppearance(selector, EnvProp.SidesBlock, cfg.EdgeBlock); } else if (opt == "expfog") { LevelEnv.SetBool(p, value, area, "exp fog", 0, ref cfg.ExpFog); LevelEnv.UpdateAppearance(selector, EnvProp.ExpFog, cfg.ExpFog); } else if (opt == "skyboxhorspeed" || opt == "skyboxhor") { LevelEnv.SetFloat(p, value, area, 1024, "skybox horizontal speed", 0, ref cfg.SkyboxHorSpeed, -0xFFFFFF, 0xFFFFFF); LevelEnv.UpdateAppearance(selector, EnvProp.SkyboxHorSpeed, cfg.SkyboxHorSpeed); } else if (opt == "skyboxverspeed" || opt == "skyboxver") { LevelEnv.SetFloat(p, value, area, 1024, "skybox vertical speed", 0, ref cfg.SkyboxVerSpeed, -0xFFFFFF, 0xFFFFFF); LevelEnv.UpdateAppearance(selector, EnvProp.SkyboxVerSpeed, cfg.SkyboxVerSpeed); } else { return(false); } Level.SaveSettings(lvl); return(true); }
internal static bool Handle(Player p, string variable, string value) { Level lvl = p.level; switch (variable) { case "fog": LevelEnv.SetColor(p, value, 2, "fog", ref lvl.FogColor); break; case "cloud": case "clouds": LevelEnv.SetColor(p, value, 1, "cloud", ref lvl.CloudColor); break; case "sky": LevelEnv.SetColor(p, value, 0, "sky", ref lvl.SkyColor); break; case "dark": case "shadow": LevelEnv.SetColor(p, value, 3, "shadow", ref lvl.ShadowColor); break; case "sun": case "light": case "sunlight": LevelEnv.SetColor(p, value, 4, "sunlight", ref lvl.LightColor); break; case "weather": LevelEnv.SetWeather(p, p.level, value); break; case "cloudsheight": case "cloudheight": LevelEnv.SetShort(p, value, EnvProp.CloudsLevel, "clouds height", (short)(lvl.Height + 2), ref lvl.CloudsHeight); break; case "waterlevel": case "edgelevel": case "level": LevelEnv.SetShort(p, value, EnvProp.EdgeLevel, "water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); break; case "maxfogdistance": case "maxfog": case "fogdistance": case "fogdist": LevelEnv.SetShort(p, value, EnvProp.MaxFog, "max fog distance", 0, ref lvl.MaxFogDistance); break; case "cloudspeed": case "cloudsspeed": LevelEnv.SetFloat(p, value, EnvProp.CloudsSpeed, 256, "clouds speed", 256, ref lvl.CloudsSpeed, -32767, 32767); break; case "weatherspeed": LevelEnv.SetFloat(p, value, EnvProp.WeatherSpeed, 256, "weather speed", 256, ref lvl.WeatherSpeed, -32767, 32767); break; case "weatherfade": LevelEnv.SetFloat(p, value, EnvProp.WeatherFade, 128, "weather fade rate", 128, ref lvl.WeatherFade, 0, 255); break; case "horizon": case "edge": case "water": LevelEnv.SetBlock(p, value, EnvProp.EdgeBlock, "edge block", Block.waterstill, ref lvl.HorizonBlock); break; case "side": case "border": case "bedrock": LevelEnv.SetBlock(p, value, EnvProp.SidesBlock, "sides block", Block.blackrock, ref lvl.EdgeBlock); break; default: return(false); } Level.SaveSettings(lvl); return(true); }
internal static bool Handle(Player p, string opt, string value) { Level lvl = p.level; // using if else instead of switch here reduces IL by about 200 bytes if (opt == "fog") { LevelEnv.SetColor(p, value, 2, opt, ref lvl.Config.FogColor); } else if (opt == "cloud" || opt == "clouds") { LevelEnv.SetColor(p, value, 1, opt, ref lvl.Config.CloudColor); } else if (opt == "sky") { LevelEnv.SetColor(p, value, 0, opt, ref lvl.Config.SkyColor); } else if (opt == "dark" || opt == "shadow") { LevelEnv.SetColor(p, value, 3, opt, ref lvl.Config.ShadowColor); } else if (opt == "sun" || opt == "light" || opt == "sunlight") { LevelEnv.SetColor(p, value, 4, opt, ref lvl.Config.LightColor); } else if (opt == "weather") { LevelEnv.SetWeather(p, p.level, value); } else if (opt == "cloudheight" || opt == "cloudsheight") { LevelEnv.SetShort(p, value, EnvProp.CloudsLevel, "clouds height", (short)(lvl.Height + 2), ref lvl.Config.CloudsHeight); } else if (opt == "waterlevel" || opt == "edgelevel" || opt == "level") { LevelEnv.SetShort(p, value, EnvProp.EdgeLevel, "water level", (short)(lvl.Height / 2), ref lvl.Config.EdgeLevel); } else if (opt == "bedrockoffset" || opt == "sidesoffset" || opt == "sideoffset") { LevelEnv.SetShort(p, value, EnvProp.SidesOffset, "bedrock offset", -2, ref lvl.Config.SidesOffset); } else if (opt == "maxfogdistance" || opt == "maxfog" || opt == "fogdistance") { LevelEnv.SetShort(p, value, EnvProp.MaxFog, "max fog distance", 0, ref lvl.Config.MaxFogDistance); } else if (opt == "cloudspeed" || opt == "cloudsspeed") { LevelEnv.SetFloat(p, value, EnvProp.CloudsSpeed, 256, "clouds speed", 256, ref lvl.Config.CloudsSpeed, -0xFFFFFF, 0xFFFFFF); } else if (opt == "weatherspeed") { LevelEnv.SetFloat(p, value, EnvProp.WeatherSpeed, 256, "weather speed", 256, ref lvl.Config.WeatherSpeed, -0xFFFFFF, 0xFFFFFF); } else if (opt == "weatherfade") { LevelEnv.SetFloat(p, value, EnvProp.WeatherFade, 128, "weather fade rate", 128, ref lvl.Config.WeatherFade, 0, 255); } else if (opt == "horizon" || opt == "edge" || opt == "water") { LevelEnv.SetBlock(p, value, EnvProp.EdgeBlock, "edge block", Block.Water, ref lvl.Config.HorizonBlock); } else if (opt == "side" || opt == "border" || opt == "bedrock") { LevelEnv.SetBlock(p, value, EnvProp.SidesBlock, "sides block", Block.Bedrock, ref lvl.Config.EdgeBlock); } else if (opt == "expfog") { LevelEnv.SetBool(p, value, EnvProp.ExpFog, "exp fog", false, ref lvl.Config.ExpFog); } else if (opt == "skyboxhorspeed" || opt == "skyboxhor") { LevelEnv.SetFloat(p, value, EnvProp.SkyboxHorSpeed, 1024, "skybox horizontal speed", 0, ref lvl.Config.SkyboxHorSpeed, -0xFFFFFF, 0xFFFFFF); } else if (opt == "skyboxverspeed" || opt == "skyboxver") { LevelEnv.SetFloat(p, value, EnvProp.SkyboxVerSpeed, 1024, "skybox vertical speed", 0, ref lvl.Config.SkyboxVerSpeed, -0xFFFFFF, 0xFFFFFF); } else { return(false); } Level.SaveSettings(lvl); return(true); }