Ejemplo n.º 1
0
 public WeatherPattern(WeatherSystemBase ws, WeatherPatternConfig config, LCGRandom rand, int cloudTilebasePosX, int cloudTilebasePosZ)
 {
     this.ws                = ws;
     this.rand              = rand;
     this.config            = config;
     this.api               = ws.api;
     this.cloudTilebasePosX = cloudTilebasePosX;
     this.cloudTilebasePosZ = cloudTilebasePosZ;
 }
Ejemplo n.º 2
0
        public void LoadConfigs(bool isReload = false)
        {
            // Thread safe assignment
            var nowconfig = api.Assets.Get <WeatherSystemConfig>(new AssetLocation("config/weather.json"));

            if (isReload)
            {
                nowconfig.Init(api.World);
            }

            GeneralConfig = nowconfig;

            var dictWeatherPatterns    = api.Assets.GetMany <WeatherPatternConfig[]>(api.World.Logger, "config/weatherpatterns/");
            var orderedWeatherPatterns = dictWeatherPatterns.OrderBy(val => val.Key.ToString()).Select(val => val.Value).ToArray();

            WeatherConfigs = new WeatherPatternConfig[0];
            foreach (var val in orderedWeatherPatterns)
            {
                WeatherConfigs = WeatherConfigs.Append(val);
            }

            var dictWindPatterns    = api.Assets.GetMany <WindPatternConfig[]>(api.World.Logger, "config/windpatterns/");
            var orderedWindPatterns = dictWindPatterns.OrderBy(val => val.Key.ToString()).Select(val => val.Value).ToArray();

            WindConfigs = new WindPatternConfig[0];
            foreach (var val in orderedWindPatterns)
            {
                WindConfigs = WindConfigs.Append(val);
            }

            var dictweatherEventConfigs    = api.Assets.GetMany <WeatherEventConfig[]>(api.World.Logger, "config/weatherevents/");
            var orderedweatherEventConfigs = dictweatherEventConfigs.OrderBy(val => val.Key.ToString()).Select(val => val.Value).ToArray();

            WeatherEventConfigs = new WeatherEventConfig[0];
            foreach (var val in orderedweatherEventConfigs)
            {
                WeatherEventConfigs = WeatherEventConfigs.Append(val);
            }

            api.World.Logger.Notification("Reloaded {0} weather patterns, {1} wind patterns and {2} weather events", WeatherConfigs.Length, WindConfigs.Length, WeatherEventConfigs.Length);

            WeatherPatternAssets p = new WeatherPatternAssets()
            {
                GeneralConfig       = GeneralConfig,
                WeatherConfigs      = WeatherConfigs,
                WindConfigs         = WindConfigs,
                WeatherEventConfigs = WeatherEventConfigs
            };

            packetForClient = new WeatherPatternAssetsPacket()
            {
                Data = JsonUtil.ToString(p)
            };
        }