Skip to content

Commit 7b3e796

Browse files
Add skybox horizontal/vertical rotation to /env.
1 parent af7baf5 commit 7b3e796

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

fCraft/Commands/CpeCommands.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,15 @@ static string Hex(CustomColor c) {
741741
"&NUse \"normal\" instead of a number to reset to default (0)." },
742742
{ "weatherfade","&H/Env <WorldName> weatherfade <#>&N&S" +
743743
"Sets how quickly rain/snow fades, relative to normal rate." +
744-
"&NUse \"normal\" instead of a number to reset to default (0)." }
744+
"&NUse \"normal\" instead of a number to reset to default (0)." },
745+
{ "skyboxhorspeed","&H/Env <WorldName> skyoxhorspeed <#>&N&S" +
746+
"Sets how quickly skybox rotates horizontally around." +
747+
"&Ne.g. a value of 0.5 means it rotates 360 degrees every two seconds." +
748+
"&NUse \"normal\" instead of a number to reset to default (0)." },
749+
{ "skyboxverrspeed","&H/Env <WorldName> skyoxverspeed <#>&N&S" +
750+
"Sets how quickly skybox rotates vertically around." +
751+
"&Ne.g. a value of 0.5 means it rotates 360 degrees every two seconds." +
752+
"&NUse \"normal\" instead of a number to reset to default (0)." },
745753
},
746754
Usage = "/Env <WorldName> <Variable>",
747755
IsConsoleSafe = true,
@@ -844,10 +852,15 @@ static void EnvHandler(Player player, CommandReader cmd) {
844852
SetEnvAppearanceFloat(player, world, value, EnvProp.WeatherSpeed, "weather speed",
845853
-32767, 32767, 256, 256, ref world.WeatherSpeed);
846854
break;
847-
case "cloudspeed":
848-
case "cloudsspeed":
849-
SetEnvAppearanceFloat(player, world, value, EnvProp.CloudsSpeed, "clouds speed",
850-
-32767, 32767, 256, 256, ref world.CloudsSpeed);
855+
case "skyboxhorspeed":
856+
case "skyboxhor":
857+
SetEnvAppearanceFloat(player, world, value, EnvProp.SkyboxHorSpeed, "skybox horizontal speed",
858+
-32767, 32767, 1024, 0, ref world.SkyboxHorSpeed);
859+
break;
860+
case "skyboxverspeed":
861+
case "skyboxver":
862+
SetEnvAppearanceFloat(player, world, value, EnvProp.SkyboxVerSpeed, "skybox vertical speed",
863+
-32767, 32767, 1024, 0, ref world.SkyboxVerSpeed);
851864
break;
852865
case "horizon":
853866
case "edge":
@@ -976,6 +989,8 @@ static void ResetEnv(Player player, World world) {
976989
world.WeatherSpeed = 256;
977990
world.CloudsSpeed = 256;
978991
world.WeatherFade = 128;
992+
world.SkyboxHorSpeed = 0;
993+
world.SkyboxVerSpeed = 0;
979994

980995
Logger.Log(LogType.UserActivity,
981996
"Env: {0} {1} reset environment settings for world {2}",

fCraft/Network/CpeConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ public enum EnvProp : byte {
143143
WeatherFade = 7,
144144
ExpFog = 8,
145145
SidesOffset = 9,
146+
SkyboxHorSpeed = 10,
147+
SkyboxVerSpeed = 11,
146148
}
147149

148150
public enum EntityProp : byte {

fCraft/World/World.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ public World ChangeMap( [NotNull] Map newMap ) {
261261
CloudsSpeed = CloudsSpeed,
262262
WeatherSpeed = WeatherSpeed,
263263
WeatherFade = WeatherFade,
264+
SkyboxHorSpeed = SkyboxHorSpeed,
265+
SkyboxVerSpeed = SkyboxVerSpeed,
264266
Buildable = Buildable,
265267
Deletable = Deletable,
266268
};
@@ -978,6 +980,12 @@ public short GetCloudsHeight() {
978980

979981
/// <summary> Rain/Snow fade speed as seen by the player, in units of 128ths. The default value is 128 (1 speed). </summary>
980982
public short WeatherFade = 128;
983+
984+
/// <summary> Skybox horizontal speed as seen by the player, in units of 1024ths. The default value is 0 (0 speed). </summary>
985+
public short SkyboxHorSpeed = 0;
986+
987+
/// <summary> Skybox vertical speed as seen by the player, in units of 1024ths. The default value is 0 (0 speed). </summary>
988+
public short SkyboxVerSpeed = 0;
981989

982990
/// <summary> The block which will be displayed on the horizon. </summary>
983991
public byte HorizonBlock = (byte)Block.Water;

fCraft/World/WorldManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ static void LoadEnvSettings(World world, string worldName, XElement el) {
357357
if ((attr = el.Attribute("weatherfade")) != null) {
358358
world.WeatherFade = ParseShort(attr, worldName, 128, "normal rate");
359359
}
360+
if ((attr = el.Attribute("skyboxhorspeed")) != null) {
361+
world.SkyboxHorSpeed = ParseShort(attr, worldName, 0, "normal speed");
362+
}
363+
if ((attr = el.Attribute("skyboxverspeed")) != null) {
364+
world.SkyboxVerSpeed = ParseShort(attr, worldName, 0, "normal speed");
365+
}
360366

361367
if ((attr = el.Attribute("terrain")) != null) {
362368
world.Texture = ParseString(attr, worldName);
@@ -628,6 +634,8 @@ static void SaveEnvSettings(World world, XElement temp) {
628634
elEnv.Add(new XAttribute("weatherspeed", world.WeatherSpeed));
629635
elEnv.Add(new XAttribute("cloudsspeed", world.CloudsSpeed));
630636
elEnv.Add(new XAttribute("weatherfade", world.WeatherFade));
637+
elEnv.Add(new XAttribute("skyboxhorspeed", world.SkyboxHorSpeed));
638+
elEnv.Add(new XAttribute("skyboxverspeed", world.SkyboxVerSpeed));
631639
temp.Add(elEnv);
632640
}
633641

0 commit comments

Comments
 (0)