Skip to content

Commit

Permalink
Add skybox horizontal/vertical rotation to /env.
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Sep 27, 2017
1 parent af7baf5 commit 7b3e796
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
25 changes: 20 additions & 5 deletions fCraft/Commands/CpeCommands.cs
Expand Up @@ -741,7 +741,15 @@ static class CpeCommands {
"&NUse \"normal\" instead of a number to reset to default (0)." },
{ "weatherfade","&H/Env <WorldName> weatherfade <#>&N&S" +
"Sets how quickly rain/snow fades, relative to normal rate." +
"&NUse \"normal\" instead of a number to reset to default (0)." }
"&NUse \"normal\" instead of a number to reset to default (0)." },
{ "skyboxhorspeed","&H/Env <WorldName> skyoxhorspeed <#>&N&S" +
"Sets how quickly skybox rotates horizontally around." +
"&Ne.g. a value of 0.5 means it rotates 360 degrees every two seconds." +
"&NUse \"normal\" instead of a number to reset to default (0)." },
{ "skyboxverrspeed","&H/Env <WorldName> skyoxverspeed <#>&N&S" +
"Sets how quickly skybox rotates vertically around." +
"&Ne.g. a value of 0.5 means it rotates 360 degrees every two seconds." +
"&NUse \"normal\" instead of a number to reset to default (0)." },
},
Usage = "/Env <WorldName> <Variable>",
IsConsoleSafe = true,
Expand Down Expand Up @@ -844,10 +852,15 @@ static class CpeCommands {
SetEnvAppearanceFloat(player, world, value, EnvProp.WeatherSpeed, "weather speed",
-32767, 32767, 256, 256, ref world.WeatherSpeed);
break;
case "cloudspeed":
case "cloudsspeed":
SetEnvAppearanceFloat(player, world, value, EnvProp.CloudsSpeed, "clouds speed",
-32767, 32767, 256, 256, ref world.CloudsSpeed);
case "skyboxhorspeed":
case "skyboxhor":
SetEnvAppearanceFloat(player, world, value, EnvProp.SkyboxHorSpeed, "skybox horizontal speed",
-32767, 32767, 1024, 0, ref world.SkyboxHorSpeed);
break;
case "skyboxverspeed":
case "skyboxver":
SetEnvAppearanceFloat(player, world, value, EnvProp.SkyboxVerSpeed, "skybox vertical speed",
-32767, 32767, 1024, 0, ref world.SkyboxVerSpeed);
break;
case "horizon":
case "edge":
Expand Down Expand Up @@ -976,6 +989,8 @@ static class CpeCommands {
world.WeatherSpeed = 256;
world.CloudsSpeed = 256;
world.WeatherFade = 128;
world.SkyboxHorSpeed = 0;
world.SkyboxVerSpeed = 0;

Logger.Log(LogType.UserActivity,
"Env: {0} {1} reset environment settings for world {2}",
Expand Down
2 changes: 2 additions & 0 deletions fCraft/Network/CpeConstants.cs
Expand Up @@ -143,6 +143,8 @@ public enum EnvProp : byte {
WeatherFade = 7,
ExpFog = 8,
SidesOffset = 9,
SkyboxHorSpeed = 10,
SkyboxVerSpeed = 11,
}

public enum EntityProp : byte {
Expand Down
8 changes: 8 additions & 0 deletions fCraft/World/World.cs
Expand Up @@ -261,6 +261,8 @@ public sealed class World : IClassy {
CloudsSpeed = CloudsSpeed,
WeatherSpeed = WeatherSpeed,
WeatherFade = WeatherFade,
SkyboxHorSpeed = SkyboxHorSpeed,
SkyboxVerSpeed = SkyboxVerSpeed,
Buildable = Buildable,
Deletable = Deletable,
};
Expand Down Expand Up @@ -978,6 +980,12 @@ public sealed class World : IClassy {

/// <summary> Rain/Snow fade speed as seen by the player, in units of 128ths. The default value is 128 (1 speed). </summary>
public short WeatherFade = 128;

/// <summary> Skybox horizontal speed as seen by the player, in units of 1024ths. The default value is 0 (0 speed). </summary>
public short SkyboxHorSpeed = 0;

/// <summary> Skybox vertical speed as seen by the player, in units of 1024ths. The default value is 0 (0 speed). </summary>
public short SkyboxVerSpeed = 0;

/// <summary> The block which will be displayed on the horizon. </summary>
public byte HorizonBlock = (byte)Block.Water;
Expand Down
8 changes: 8 additions & 0 deletions fCraft/World/WorldManager.cs
Expand Up @@ -357,6 +357,12 @@ static void LoadWorldListEntry([NotNull] XElement el)
if ((attr = el.Attribute("weatherfade")) != null) {
world.WeatherFade = ParseShort(attr, worldName, 128, "normal rate");
}
if ((attr = el.Attribute("skyboxhorspeed")) != null) {
world.SkyboxHorSpeed = ParseShort(attr, worldName, 0, "normal speed");
}
if ((attr = el.Attribute("skyboxverspeed")) != null) {
world.SkyboxVerSpeed = ParseShort(attr, worldName, 0, "normal speed");
}

if ((attr = el.Attribute("terrain")) != null) {
world.Texture = ParseString(attr, worldName);
Expand Down Expand Up @@ -628,6 +634,8 @@ static void LoadWorldListEntry([NotNull] XElement el)
elEnv.Add(new XAttribute("weatherspeed", world.WeatherSpeed));
elEnv.Add(new XAttribute("cloudsspeed", world.CloudsSpeed));
elEnv.Add(new XAttribute("weatherfade", world.WeatherFade));
elEnv.Add(new XAttribute("skyboxhorspeed", world.SkyboxHorSpeed));
elEnv.Add(new XAttribute("skyboxverspeed", world.SkyboxVerSpeed));
temp.Add(elEnv);
}

Expand Down

0 comments on commit 7b3e796

Please sign in to comment.