コード例 #1
0
 /// <summary>
 /// Disables default deer template. No more standard deer should show up in starting zone.
 /// </summary>
 private static void ConfigureWorldSpawnerOverrideDefault(ISpawnerConfigurationCollection config)
 {
     try
     {
         config.ConfigureWorldSpawner(0)
         .SetEnabled(false)
         .SetTemplateName("Disabled deer");
     }
     catch (Exception e)
     {
         Log.LogError(e);
     }
 }
コード例 #2
0
    internal static void ApplyBepInExConfigs(ISpawnerConfigurationCollection spawnerConfigs)
    {
#if DEBUG
        Log.LogTrace("SpawnSystemConfigApplier.ApplyBepInExConfigs");
#endif
        var spawnSystemConfigs = SpawnSystemConfigurationManager
                                 .SpawnSystemConfig?
                                 .Subsections?      //[*]
                                 .Values?
                                 .FirstOrDefault()? //SpawnSystem config is only expected to have a single first layer, namely "WorldSpawner", so we just grab the first entry.
                                 .Subsections?      //[WorldSpawner.*]
                                 .Values;

        if ((spawnSystemConfigs?.Count ?? 0) == 0)
        {
            return;
        }

        var configs = spawnSystemConfigs
                      .OrderBy(x => x.Index)
                      .Where(x => x.TemplateEnabled.Value);

        foreach (var spawnConfig in configs)
        {
            if (string.IsNullOrWhiteSpace(spawnConfig.PrefabName?.Value))
            {
                Log.LogWarning($"PrefabName of world spawner config {spawnConfig.SectionKey} is empty. Skipping config.");
                continue;
            }

            if (spawnConfig.Index < 0)
            {
                Log.LogWarning($"Index of world spawner config {spawnConfig.SectionKey} is less than 0. Skipping config.");
                continue;
            }

            var builder = spawnerConfigs.ConfigureWorldSpawner((uint)spawnConfig.Index);

            ApplyConfigToBuilder(spawnConfig, builder);
        }
    }