public void SendCurrentEnv() { Zone zone = ZoneIn; for (int i = 0; i <= 5; i++) { string col = Server.Config.GetColor(i); if (level.Config.GetColor(i) != "") { col = level.Config.GetColor(i); } if (zone != null && zone.Config.GetColor(i) != "") { col = zone.Config.GetColor(i); } Session.SendSetEnvColor((byte)i, col); } if (Supports(CpeExt.EnvMapAspect)) { for (EnvProp i = 0; i < EnvProp.Max; i++) { int value = CurrentEnvProp(i, zone); Send(Packet.EnvMapProperty(i, value)); } } int weather = CurrentEnvProp(EnvProp.Weather, zone); Session.SendSetWeather((byte)weather); }
int CurrentEnvProp(EnvProp i, Zone zone) { int value = Server.Config.GetEnvProp(i); bool block = i == EnvProp.SidesBlock || i == EnvProp.EdgeBlock; int invalid = block ? Block.Invalid : -1; if (level.Config.GetEnvProp(i) != invalid) { value = level.Config.GetEnvProp(i); } if (zone != null && zone.Config.GetEnvProp(i) != invalid) { value = zone.Config.GetEnvProp(i); } if (value == invalid) { value = level.Config.DefaultEnvProp(i, level.Height); } if (block) { value = ConvertBlock((BlockID)value); } return(value); }
int CurrentEnvProp(EnvProp i, Zone zone) { int value = Server.Config.GetEnvProp(i); bool block = i == EnvProp.SidesBlock || i == EnvProp.EdgeBlock; int default_ = block ? Block.Invalid : EnvConfig.ENV_USE_DEFAULT; if (level.Config.GetEnvProp(i) != default_) { value = level.Config.GetEnvProp(i); } if (zone != null && zone.Config.GetEnvProp(i) != default_) { value = zone.Config.GetEnvProp(i); } if (value == default_) { value = level.Config.DefaultEnvProp(i, level.Height); } if (block) { value = Session.ConvertBlock((BlockID)value); } return(value); }
internal static void UpdateAppearance(Predicate <Player> selector, EnvProp prop, int origValue) { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!selector(pl)) { continue; } int value = origValue; if (prop == EnvProp.SidesBlock || prop == EnvProp.EdgeBlock) { value = pl.ConvertBlock((BlockID)value); } if (pl.Supports(CpeExt.EnvMapAspect)) { pl.Send(Packet.EnvMapProperty(prop, value)); } else { pl.SendCurrentTextures(); // Old MapAppearance packets have a few of the map properties } if (pl.ZoneIn != null) { pl.OnChangedZone(); } } }
public int Get(EnvProp i) { int value = Config.GetEnvProp(i); bool block = i == EnvProp.EdgeBlock || i == EnvProp.SidesBlock; int invalid = block ? Block.Invalid : -1; return(value != invalid ? value : Config.DefaultEnvProp(i, Height)); }
public int Get(EnvProp i) { int value = Config.GetEnvProp(i); bool block = i == EnvProp.EdgeBlock || i == EnvProp.SidesBlock; int default_ = block ? Block.Invalid : EnvConfig.ENV_USE_DEFAULT; return(value != default_ ? value : Config.DefaultEnvProp(i, Height)); }
public static byte[] EnvMapProperty(EnvProp prop, int value) { byte[] buffer = new byte[6]; buffer[0] = Opcode.CpeSetMapEnvProperty; buffer[1] = (byte)prop; NetUtils.WriteI32(value, buffer, 2); return(buffer); }
public static Packet MakeEnvSetMapProperty(EnvProp prop, int value) { Packet packet = new Packet(OpCode.SetEnvMapProperty); packet.Bytes[1] = (byte)prop; WriteI32(value, packet.Bytes, 2); return(packet); }
public int GetEnvProp(EnvProp i) { if (i == EnvProp.SidesBlock) { return(EdgeBlock); } if (i == EnvProp.EdgeBlock) { return(HorizonBlock); } if (i == EnvProp.EdgeLevel) { return(EdgeLevel); } if (i == EnvProp.CloudsLevel) { return(CloudsHeight); } if (i == EnvProp.MaxFog) { return(MaxFogDistance); } if (i == EnvProp.CloudsSpeed) { return(CloudsSpeed); } if (i == EnvProp.WeatherSpeed) { return(WeatherSpeed); } if (i == EnvProp.WeatherFade) { return(WeatherFade); } if (i == EnvProp.ExpFog) { return(ExpFog); } if (i == EnvProp.SidesOffset) { return(SidesOffset); } if (i == EnvProp.SkyboxHorSpeed) { return(SkyboxHorSpeed); } if (i == EnvProp.SkyboxVerSpeed) { return(SkyboxVerSpeed); } if (i == EnvProp.Weather) { return(Weather); } return(ENV_USE_DEFAULT); }
public static void SetFloat(Player p, string value, EnvProp prop, int scale, string variable, short defValue, ref int target, int min, int max) { if (IsResetString(value)) { Player.Message(p, "Reset {0} for {0} %Sto normal", variable, p.level.ColoredName); target = defValue; } else { if (!CheckFloat(p, value, variable, ref target, scale, min, max)) return; } SendCurrentMapAppearance(p.level, prop, target); }
public static void SetBlock(Player p, string value, EnvProp prop, string variable, byte defValue, ref int target) { if (IsResetString(value)) { Player.Message(p, "Reset {0} for {1} %Sto normal", variable, p.level.ColoredName); target = defValue; } else { if (!CheckBlock(p, value, variable, ref target)) return; } SendCurrentMapAppearance(p.level, prop, target); }
public void OnChangedZone() { if (Supports(CpeExt.InstantMOTD)) { SendMapMotd(); } Zone zone = ZoneIn; for (int i = 0; i <= 4; i++) { string col = level.Config.GetColor(i); if (zone != null && zone.Config.GetColor(i) != "") { col = zone.Config.GetColor(i); } if (Supports(CpeExt.EnvColors)) { SendEnvColor((byte)i, col); } } for (EnvProp i = 0; i < EnvProp.Max; i++) { int value = level.Config.GetEnvProp(i); if (i == EnvProp.SidesBlock || i == EnvProp.EdgeBlock) { if (zone != null && zone.Config.GetEnvProp(i) != Block.Invalid) { value = zone.Config.GetEnvProp(i); } value = ConvertBlock((BlockID)value); } else { if (zone != null && zone.Config.GetEnvProp(i) != -1) { value = zone.Config.GetEnvProp(i); } } if (Supports(CpeExt.EnvMapAspect)) { Send(Packet.EnvMapProperty(i, value)); } } if (Supports(CpeExt.EnvWeatherType)) { int weather = level.Config.Weather; if (zone != null && zone.Config.Weather != -1) { weather = zone.Config.Weather; } Send(Packet.EnvWeatherType((byte)weather)); } }
static void SendCurrentMapAppearance(Level lvl, EnvProp prop, int value) { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (pl.level != lvl) continue; if (pl.HasCpeExt(CpeExt.EnvMapAspect)) { pl.Send(Packet.EnvMapProperty(prop, value)); } else { pl.SendCurrentMapAppearance(); } } }
public static void SetBool(Player p, string value, EnvProp prop, string variable, bool defValue, ref bool target) { if (IsResetString(value)) { Player.Message(p, "Reset {0} for {1} %Sto normal", variable, p.level.ColoredName); target = defValue; } else { if (!CommandParser.GetBool(p, value, ref target)) { return; } Player.Message(p, "Set {0} for {1} %Sto {2}", variable, p.level.ColoredName, target ? "&aON" : "&cOFF"); } SendCurrentMapAppearance(p.level, prop, target ? 1 : 0); }
/// <summary> Calculates the default value for the given env property </summary> public int DefaultEnvProp(EnvProp i, int height) { if (i == EnvProp.SidesBlock) { return(Block.Bedrock); } if (i == EnvProp.EdgeBlock) { return(Block.Water); } if (i == EnvProp.EdgeLevel) { return(height / 2); } if (i == EnvProp.CloudsLevel) { return(height + 2); } if (i == EnvProp.CloudsSpeed) { return(256); } if (i == EnvProp.WeatherSpeed) { return(256); } if (i == EnvProp.WeatherFade) { return(128); } if (i == EnvProp.SidesOffset) { return(-2); } return(0); }
public string GetSkybox(EnvProp i) { int angle = Get(i); return(angle == 0 ? "none" : (angle / 1024.0).ToString("F3") + "/s"); }