Add skybox horizontal/vertical rotation to /env.

This commit is contained in:
UnknownShadow200 2017-09-27 11:08:59 +10:00
parent 13d78d9d2e
commit 42b232d480
4 changed files with 46 additions and 19 deletions

View File

@ -18,6 +18,7 @@
using System; using System;
using System.IO; using System.IO;
using MCGalaxy.Commands.Building; using MCGalaxy.Commands.Building;
using MCGalaxy.Network;
namespace MCGalaxy.Commands.CPE { namespace MCGalaxy.Commands.CPE {
public sealed class CmdEnvironment : Command { public sealed class CmdEnvironment : Command {
@ -90,6 +91,12 @@ namespace MCGalaxy.Commands.CPE {
} else if (opt == "expfog") { } else if (opt == "expfog") {
LevelEnv.SetBool(p, value, EnvProp.ExpFog, LevelEnv.SetBool(p, value, EnvProp.ExpFog,
"exp fog", false, ref lvl.Config.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, -32767, 32767);
} else if (opt == "skyboxverspeed" || opt == "skyboxver") {
LevelEnv.SetFloat(p, value, EnvProp.SkyboxVerSpeed, 1024, "skybox vertical speed",
0, ref lvl.Config.SkyboxVerSpeed, -32767, 32767);
} else { } else {
return false; return false;
} }
@ -99,20 +106,32 @@ namespace MCGalaxy.Commands.CPE {
static void ResetEnv(Player p) { static void ResetEnv(Player p) {
Level lvl = p.level; Level lvl = p.level;
LevelConfig cfg = lvl.Config;
SetPreset(p, "normal"); SetPreset(p, "normal");
LevelEnv.SetWeather(p, lvl, "normal"); cfg.Weather = 0;
cfg.CloudsHeight = (short)(lvl.Height + 2);
LevelEnv.SetBlock(p, "normal", EnvProp.EdgeBlock, cfg.EdgeLevel = (short)(lvl.Height / 2);
"edge block", Block.Water, ref lvl.Config.HorizonBlock); cfg.SidesOffset = -2;
LevelEnv.SetBlock(p, "normal", EnvProp.SidesBlock, cfg.MaxFogDistance = 0;
"sides block", Block.Bedrock, ref lvl.Config.EdgeBlock); cfg.CloudsSpeed = 256;
cfg.WeatherSpeed = 256;
LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel, cfg.WeatherFade = 128;
"water level", (short)(lvl.Height / 2), ref lvl.Config.EdgeLevel); cfg.EdgeBlock = Block.Bedrock;
LevelEnv.SetShort(p, "normal", EnvProp.SidesOffset, cfg.HorizonBlock = Block.Water;
"bedrock offset", -2, ref lvl.Config.SidesOffset); cfg.ExpFog = false;
LevelEnv.SetShort(p, "normal", EnvProp.CloudsLevel, cfg.SkyboxHorSpeed = 0;
"clouds height", (short)(lvl.Height + 2), ref lvl.Config.CloudsHeight); cfg.SkyboxVerSpeed = 0;
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (pl.level != lvl) continue;
pl.SendCurrentMapAppearance();
if (pl.Supports(CpeExt.EnvWeatherType)) {
pl.Send(Packet.EnvWeatherType(0));
}
}
Level.SaveSettings(lvl);
} }
static bool SetPreset(Player p, string value) { static bool SetPreset(Player p, string value) {
@ -181,9 +200,10 @@ namespace MCGalaxy.Commands.CPE {
public override void Help(Player p) { public override void Help(Player p) {
Player.Message(p, "%T/Environment [variable] [value]"); Player.Message(p, "%T/Environment [variable] [value]");
Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level"); Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level,");
Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight"); Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight, cloudspeed,");
Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog, sidesoffset"); Player.Message(p, "%H weatherspeed, weatherfade, expfog, sidesoffset,");
Player.Message(p, "%H skyboxhorspeed, skyboxverspeed");
Player.Message(p, "%HUsing 'normal' as a value will reset the variable"); Player.Message(p, "%HUsing 'normal' as a value will reset the variable");
Player.Message(p, "%T/Environment normal %H- resets all variables"); Player.Message(p, "%T/Environment normal %H- resets all variables");
} }

View File

@ -94,6 +94,13 @@ namespace MCGalaxy {
/// <summary> Weather fade, in units of 256ths. Default is 256 (1 speed). </summary> /// <summary> Weather fade, in units of 256ths. Default is 256 (1 speed). </summary>
[ConfigInt("weather-fade", "Env", 128, short.MinValue, short.MaxValue)] [ConfigInt("weather-fade", "Env", 128, short.MinValue, short.MaxValue)]
public int WeatherFade = 128; public int WeatherFade = 128;
/// <summary> Skybox horizontal speed, in units of 1024ths. Default is 0 (0 speed). </summary>
[ConfigInt("skybox-hor-speed", "Env", 0, short.MinValue, short.MaxValue)]
public int SkyboxHorSpeed = 0;
/// <summary> Skybox vertical speed, in units of 1024ths. Default is 0 (0 speed). </summary>
[ConfigInt("skybox-ver-speed", "Env", 0, short.MinValue, short.MaxValue)]
public int SkyboxVerSpeed = 0;
/// <summary> The block which will be displayed on the horizon. </summary> /// <summary> The block which will be displayed on the horizon. </summary>
[ConfigByte("HorizonBlock", "Env", Block.Water)] [ConfigByte("HorizonBlock", "Env", Block.Water)]
public byte HorizonBlock = Block.Water; public byte HorizonBlock = Block.Water;

View File

@ -146,11 +146,11 @@ namespace MCGalaxy {
return false; return false;
} else if (value < min || value > max) { } else if (value < min || value > max) {
Player.Message(p, "Env: \"{0}\" must be between {1} and {2}.", Player.Message(p, "Env: \"{0}\" must be between {1} and {2}.",
value, min.ToString("F2"), max.ToString("F2")); value, min.ToString("F4"), max.ToString("F4"));
return false; return false;
} else { } else {
modify = (int)(value * scale); modify = (int)(value * scale);
Player.Message(p, "Set {0} for {1} %Sto {2}", variable, p.level.ColoredName, value.ToString("F2")); Player.Message(p, "Set {0} for {1} %Sto {2}", variable, p.level.ColoredName, value.ToString("F4"));
return true; return true;
} }
} }

View File

@ -239,7 +239,7 @@ namespace MCGalaxy {
SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2, SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2,
CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5, CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5,
WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8, WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8,
SidesOffset = 9, SidesOffset = 9, SkyboxHorSpeed = 10, SkyboxVerSpeed = 11,
} }
public enum EntityProp : byte { public enum EntityProp : byte {