Esempio n. 1
0
    public static void MergeInto(this SpawnSystemConfigurationFile source, SpawnSystemConfigurationFile target)
    {
        var sourceTemplates = source?.Subsections?.Values?.FirstOrDefault();
        var targetTemplates = target?.Subsections?.Values?.FirstOrDefault();

        if (sourceTemplates is null)
        {
            return;
        }

        if (targetTemplates is null)
        {
            var sourceEntry = source.Subsections.First();
            target.Subsections[sourceEntry.Key] = sourceEntry.Value;
            return;
        }

        foreach (var sourceTemplate in sourceTemplates.Subsections)
        {
            if (!sourceTemplate.Value.Enabled.Value)
            {
                continue;
            }

            if (targetTemplates.Subsections.TryGetValue(sourceTemplate.Key, out var targetConfig))
            {
                if (targetConfig.TemplateEnabled.Value)
                {
                    Log.LogWarning($"Overlapping world spawner configs for {sourceTemplate.Value.SectionKey}, overriding existing.");
                }
            }

            targetTemplates.Subsections[sourceTemplate.Key] = sourceTemplate.Value;
        }
    }
    public static void LoadAllConfigurations()
    {
        Stopwatch stopwatch = Stopwatch.StartNew();

        SimpleConfig      = LoadSimpleConfig();
        SpawnSystemConfig = LoadSpawnSystemConfiguration();

        stopwatch.Stop();

        Log.LogInfo("Config loading took: " + stopwatch.Elapsed);
        if (stopwatch.Elapsed > TimeSpan.FromSeconds(5) &&
            ConfigurationManager.GeneralConfig?.StopTouchingMyConfigs?.Value == false)
        {
            Log.LogInfo("Long loading time detected. Consider setting \"StopTouchingMyConfigs=true\" in spawn_that.cfg to improve loading speed.");
        }
    }