コード例 #1
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)
            };
        }
コード例 #2
0
        public WeatherEvent(ICoreAPI api, WeatherEventConfig config, int index, LCGRandom rand, int seed)
        {
            this.rand        = rand;
            this.config      = config;
            this.api         = api;
            this.State.Index = index;

            if (config.StrengthNoise != null)
            {
                strengthNoiseGen = new SimplexNoise(config.StrengthNoise.Amplitudes, config.StrengthNoise.Frequencies, seed + index);
            }
        }