예제 #1
0
    private static void ConfigureExistingEntry(SpawnSystem.SpawnData entry, WorldSpawnTemplate template)
    {
        if (!template.Enabled)
        {
            entry.m_enabled = template.Enabled;
        }

        GameObject prefab = entry.m_prefab;

        if (!string.IsNullOrWhiteSpace(template.PrefabName))
        {
            prefab = ZNetScene.instance.GetPrefab(template.PrefabHash);

            if (prefab.IsNull())
            {
                Log.LogWarning($"Unable to find prefab '{template.PrefabName}' for {template.PrefabName}. Skipping world spawn template {template.TemplateName}");
                DetectedUnableToFindPrefab = true;
                return;
            }
        }

        Configure(ref entry.m_name, template.TemplateName);
        Configure(ref entry.m_enabled, template.Enabled);
        Configure(ref entry.m_biome, template.BiomeMask);
        Configure(ref entry.m_prefab, prefab);
        Configure(ref entry.m_huntPlayer, template.ModifierHuntPlayer);
        Configure(ref entry.m_maxSpawned, template.MaxSpawned);
        Configure(ref entry.m_spawnInterval, (float?)template.SpawnInterval?.TotalSeconds);
        Configure(ref entry.m_spawnChance, template.SpawnChance);
        Configure(ref entry.m_minLevel, template.MinLevel);
        Configure(ref entry.m_maxLevel, template.MaxLevel);
        Configure(ref entry.m_levelUpMinCenterDistance, template.DistanceToCenterForLevelUp);
        Configure(ref entry.m_spawnDistance, template.MinDistanceToOther);
        Configure(ref entry.m_spawnRadiusMin, template.SpawnAtDistanceToPlayerMin);
        Configure(ref entry.m_spawnRadiusMax, template.SpawnAtDistanceToPlayerMax);
        Configure(ref entry.m_requiredGlobalKey, template.ConditionRequiredGlobalKey);
        Configure(ref entry.m_requiredEnvironments, template.ConditionEnvironments);
        Configure(ref entry.m_groupSizeMin, template.PackSizeMin);
        Configure(ref entry.m_groupSizeMax, template.PackSizeMax);
        Configure(ref entry.m_groupRadius, template.PackSpawnCircleRadius);
        Configure(ref entry.m_groundOffset, template.SpawnAtDistanceToGround);
        Configure(ref entry.m_spawnAtDay, template.ConditionAllowDuringDay);
        Configure(ref entry.m_spawnAtNight, template.ConditionAllowDuringNight);
        Configure(ref entry.m_minAltitude, template.ConditionMinAltitude);
        Configure(ref entry.m_maxAltitude, template.ConditionMaxAltitude);
        Configure(ref entry.m_minTilt, template.ConditionMinTilt);
        Configure(ref entry.m_maxTilt, template.ConditionMaxTilt);
        Configure(ref entry.m_inForest, template.ConditionAllowInForest);
        Configure(ref entry.m_outsideForest, template.ConditionAllowOutsideForest);
        Configure(ref entry.m_minOceanDepth, template.ConditionMinOceanDepth);
        Configure(ref entry.m_maxOceanDepth, template.ConditionMaxOceanDepth);
    }
    private static void AddMobAiLines(List <string> lines, WorldSpawnTemplate template)
    {
        bool addedHeader = false;

        HashSet <Type> AddedOptions = new();

        foreach (var modifier in template.SpawnModifiers)
        {
            switch (modifier)
            {
            case ModifierSetAI mod:
                if (AddedOptions.Add(mod.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigMobAI.SetAI)}={mod.AiName}");
                }
                break;

            default:
                break;
            }
        }

        if (addedHeader)
        {
            lines.Add("");
        }

        void InsertHeaderIfMissing()
        {
            if (!addedHeader)
            {
                addedHeader = true;
                lines.Add("");
                lines.Add($"[WorldSpawner.{template.Index}.{SpawnSystemConfigMobAI.ModName}]");
            }
        }
    }
    private static void AddEpicLootLines(List <string> lines, WorldSpawnTemplate template)
    {
        bool addedHeader = false;

        HashSet <Type> AddedOptions = new();

        foreach (var condition in template.SpawnConditions)
        {
            switch (condition)
            {
            case ConditionNearbyPlayerCarryItemWithRarity con:
                if (AddedOptions.Add(con.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigEpicLoot.ConditionNearbyPlayerCarryItemWithRarity)}={con.RaritiesRequired.Join()}");
                }
                break;

            case ConditionNearbyPlayerCarryLegendaryItem con:
                if (AddedOptions.Add(con.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigEpicLoot.ConditionNearbyPlayerCarryLegendaryItem)}={con.LegendaryIds.Join()}");
                }
                break;
            }
        }

        void InsertHeaderIfMissing()
        {
            if (!addedHeader)
            {
                addedHeader = true;
                lines.Add("");
                lines.Add($"[WorldSpawner.{template.Index}.{SpawnSystemConfigEpicLoot.ModName}]");
            }
        }
    }
    private static void AddCllcIntegrationLines(List <string> lines, WorldSpawnTemplate template)
    {
        bool addedHeader = false;

        HashSet <Type> AddedOptions = new();

        foreach (var condition in template.SpawnModifiers)
        {
            switch (condition)
            {
            case ConditionWorldLevel con:
                if (AddedOptions.Add(con.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigCLLC.ConditionWorldLevelMin)}={con.MinWorldLevel}");
                    lines.Add($"{nameof(SpawnSystemConfigCLLC.ConditionWorldLevelMax)}={con.MaxWorldLevel}");
                }
                break;

            default:
                break;
            }
        }

        foreach (var modifier in template.SpawnModifiers)
        {
            switch (modifier)
            {
            case ModifierCllcInfusion mod:
                if (AddedOptions.Add(mod.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigCLLC.SetInfusion)}={mod.Infusion}");
                }
                break;

            case ModifierCllcBossAffix mod:
                if (AddedOptions.Add(mod.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigCLLC.SetBossAffix)}={mod.Affix}");
                }
                break;

            case ModifierCllcExtraEffect mod:
                if (AddedOptions.Add(mod.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigCLLC.SetExtraEffect)}={mod.ExtraEffect}");
                }
                break;

            case ModifierDefaultRollLevel mod:
                // Not entirely correct, since this is not necessarily bound to CLLC, but its the closest to old cfg.
                if (AddedOptions.Add(mod.GetType()))
                {
                    InsertHeaderIfMissing();
                    lines.Add($"{nameof(SpawnSystemConfigCLLC.UseDefaultLevels)}=true");
                }
                break;

            default:
                break;
            }
        }

        if (addedHeader)
        {
            lines.Add("");
        }

        void InsertHeaderIfMissing()
        {
            if (!addedHeader)
            {
                addedHeader = true;
                lines.Add("");
                lines.Add($"[WorldSpawner.{template.Index}.{SpawnSystemConfigCLLC.ModName}]");
            }
        }
    }