mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 09:25:06 +01:00
Add default Climates per weather
This commit is contained in:
@@ -32,7 +32,11 @@ public enum ClimateType {
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return this.name().substring(8).toLowerCase();
|
||||
}
|
||||
|
||||
public static ClimateType getTypeByValue(int value) {
|
||||
@@ -42,4 +46,9 @@ public enum ClimateType {
|
||||
public static ClimateType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, CLIMATE_NONE);
|
||||
}
|
||||
|
||||
public static ClimateType getTypeByShortName(String shortName) {
|
||||
String name = "CLIMATE_" + shortName.toUpperCase();
|
||||
return stringMap.getOrDefault(name, CLIMATE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,12 +138,30 @@ public class Scene {
|
||||
return weather;
|
||||
}
|
||||
|
||||
public void setClimate(ClimateType climate) {
|
||||
synchronized public void setClimate(ClimateType climate) {
|
||||
this.climate = climate;
|
||||
for (Player player : this.players) {
|
||||
this.broadcastPacket(new PacketSceneAreaWeatherNotify(player));
|
||||
}
|
||||
}
|
||||
|
||||
public void setWeather(int weather) {
|
||||
synchronized public void setWeather(int weather) {
|
||||
this.setWeather(weather, ClimateType.CLIMATE_NONE);
|
||||
}
|
||||
|
||||
synchronized public void setWeather(int weather, ClimateType climate) {
|
||||
// Lookup default climate for this weather
|
||||
if (climate == ClimateType.CLIMATE_NONE) {
|
||||
WeatherData w = GameData.getWeatherDataMap().get(weather);
|
||||
if (w != null) {
|
||||
climate = w.getDefaultClimate();
|
||||
}
|
||||
}
|
||||
this.weather = weather;
|
||||
this.climate = climate;
|
||||
for (Player player : this.players) {
|
||||
this.broadcastPacket(new PacketSceneAreaWeatherNotify(player));
|
||||
}
|
||||
}
|
||||
|
||||
public int getPrevScene() {
|
||||
|
||||
Reference in New Issue
Block a user