public static IWorldSpawnBuilder SetModifierDespawnOnConditionsInvalid(
     this IWorldSpawnBuilder builder,
     bool?conditionAllowDuringDay   = null,
     bool?conditionAllowDuringNight = null,
     List <string> conditionAllowDuringEnvironments = null)
 {
     builder.SetModifier(
         new ModifierDespawnOnConditionsInvalid(
             conditionAllowDuringDay,
             conditionAllowDuringNight,
             conditionAllowDuringEnvironments));
     return(builder);
 }
示例#2
0
    public static IWorldSpawnBuilder WithSettings(this IWorldSpawnBuilder builder, WorldSpawnSettings settings)
    {
        settings.PrefabName.Set(builder.SetPrefabName);
        settings.Enabled.Set(builder.SetEnabled);
        settings.Biomes.Set(builder.SetConditionBiomes);
        settings.MaxSpawned.Set(builder.SetMaxSpawned);
        settings.SpawnInterval.Set(builder.SetSpawnInterval);
        settings.SpawnChance.Set(builder.SetSpawnChance);
        settings.PackSpawnCircleRadius.Set(builder.SetPackSpawnCircleRadius);
        settings.PackSizeMin.Set(builder.SetPackSizeMin);
        settings.PackSizeMax.Set(builder.SetPackSizeMax);
        settings.SpawnInForest.Set(builder.SetSpawnInForest);
        settings.SpawnOutsideForest.Set(builder.SetSpawnOutsideForest);
        settings.DistanceToCenterForLevelUp.Set(builder.SetDistanceToCenterForLevelUp);
        settings.MinLevel.Set(builder.SetMinLevel);
        settings.MaxLevel.Set(builder.SetMaxLevel);
        settings.ConditionMinAltitude.SetNullable(builder.SetConditionAltitudeMin);
        settings.ConditionMaxAltitude.SetNullable(builder.SetConditionAltitudeMax);
        settings.ConditionMinOceanDepth.SetNullable(builder.SetConditionOceanDepthMin);
        settings.ConditionMaxOceanDepth.SetNullable(builder.SetConditionOceanDepthMax);
        settings.ConditionMinTilt.SetNullable(builder.SetConditionTiltMin);
        settings.ConditionMaxTilt.SetNullable(builder.SetConditionTiltMax);
        settings.ConditionEnvironments.Set(builder.SetConditionEnvironments);
        settings.ConditionRequiredGlobalKey.Set(builder.SetConditionRequiredGlobalKey);
        settings.SpawnDuringDay.Set(builder.SetSpawnDuringDay);
        settings.SpawnDuringNight.Set(builder.SetSpawnDuringNight);
        settings.MinDistanceToOther.Set(builder.SetMinDistanceToOther);
        settings.SpawnAtDistanceToPlayerMin.SetNullable(builder.SetSpawnAtDistanceToPlayerMin);
        settings.SpawnAtDistanceToPlayerMax.SetNullable(builder.SetSpawnAtDistanceToPlayerMax);
        settings.SpawnAtDistanceToGround.SetNullable(builder.SetSpawnAtDistanceToGround);

        foreach (var condition in settings.Conditions)
        {
            builder.SetCondition(condition);
        }

        foreach (var condition in settings.PositionConditions)
        {
            builder.SetPositionCondition(condition);
        }

        foreach (var modifier in settings.Modifiers)
        {
            builder = builder.SetModifier(modifier);
        }

        return(builder);
    }
 private static void SetInfusion(IWorldSpawnBuilder builder, string infusionName) => builder.SetModifier(new ModifierCllcInfusion(infusionName));
 private static void SetExtraEffect(IWorldSpawnBuilder builder, CllcCreatureExtraEffect extraEffect) => builder.SetModifier(new ModifierCllcExtraEffect(extraEffect));
 private static void SetExtraEffect(IWorldSpawnBuilder builder, string extraEffectName) => builder.SetModifier(new ModifierCllcExtraEffect(extraEffectName));
 private static void SetBossAffix(IWorldSpawnBuilder builder, CllcBossAffix bossAffix) => builder.SetModifier(new ModifierCllcBossAffix(bossAffix));
 private static void SetBossAffix(IWorldSpawnBuilder builder, string bossAffixName) => builder.SetModifier(new ModifierCllcBossAffix(bossAffixName));
    private static void ApplyConfigToBuilder(SpawnConfiguration config, IWorldSpawnBuilder builder)
    {
        // Default
        config.Name.SetIfHasValue(builder.SetTemplateName);
        config.PrefabName.SetIfHasValue(builder.SetPrefabName);
        config.RequiredGlobalKey.SetIfHasValue(builder.SetConditionRequiredGlobalKey);
        config.RequiredEnvironments.SetIfHasValue(builder.SetConditionEnvironments);

        builder.SetEnabled(config.Enabled.Value);
        builder.SetTemplateEnabled(config.TemplateEnabled.Value);
        builder.SetConditionBiomes(config.ExtractBiomeMask());
        builder.SetModifierHuntPlayer(config.HuntPlayer.Value);
        builder.SetMaxSpawned((uint)config.MaxSpawned.Value);
        builder.SetSpawnInterval(TimeSpan.FromSeconds(config.SpawnInterval.Value));
        builder.SetSpawnChance(config.SpawnChance.Value);
        builder.SetMinLevel((uint)config.LevelMin.Value);
        builder.SetMaxLevel((uint)config.LevelMax.Value);
        builder.SetDistanceToCenterForLevelUp(config.LevelUpMinCenterDistance.Value);
        builder.SetMinDistanceToOther(config.SpawnDistance.Value);
        builder.SetSpawnAtDistanceToPlayerMin(config.SpawnRadiusMin.Value);
        builder.SetSpawnAtDistanceToPlayerMax(config.SpawnRadiusMax.Value);
        builder.SetPackSizeMin((uint)config.GroupSizeMin.Value);
        builder.SetPackSizeMax((uint)config.GroupSizeMax.Value);
        builder.SetPackSpawnCircleRadius(config.GroupRadius.Value);
        builder.SetSpawnAtDistanceToGround(config.GroundOffset.Value);
        builder.SetSpawnDuringDay(config.SpawnDuringDay.Value);
        builder.SetSpawnDuringNight(config.SpawnDuringNight.Value);
        builder.SetConditionAltitude(config.ConditionAltitudeMin.Value, config.ConditionAltitudeMax.Value);
        builder.SetConditionTilt(config.ConditionTiltMin.Value, config.ConditionTiltMax.Value);
        builder.SetSpawnInForest(config.SpawnInForest.Value);
        builder.SetSpawnOutsideForest(config.SpawnOutsideForest.Value);
        builder.SetConditionOceanDepth(config.OceanDepthMin.Value, config.OceanDepthMax.Value);

        // Conditions
        var playerConditionsDistance = (int)config.DistanceToTriggerPlayerConditions.Value;

        config.ConditionLocation.SetIfHasValue(builder.SetConditionLocation);
        config.RequiredNotGlobalKey.SetIfHasValue(builder.SetGlobalKeysRequiredMissing);
        config.ConditionNearbyPlayersCarryValue.SetIfGreaterThanZero(x => builder.SetConditionNearbyPlayersCarryValue(playerConditionsDistance, x));
        config.ConditionNearbyPlayersNoiseThreshold.SetIfGreaterThanZero(x => builder.SetConditionNearbyPlayersNoise(playerConditionsDistance, x));
        config.ConditionAreaSpawnChance.SetIfNotEqual(100, builder.SetConditionAreaSpawnChance);

        builder.SetConditionDistanceToCenter(config.ConditionDistanceToCenterMin.Value, config.ConditionDistanceToCenterMax.Value);
        builder.SetConditionWorldAge((int)config.ConditionWorldAgeDaysMin.Value, (int)config.ConditionWorldAgeDaysMax.Value);

        if (config.ConditionNearbyPlayerCarriesItem.Value.IsNotEmpty())
        {
            builder.SetConditionNearbyPlayersCarryItem((int)config.DistanceToTriggerPlayerConditions.Value, config.ConditionNearbyPlayerCarriesItem.Value.SplitByComma());
        }
        if (config.ConditionNearbyPlayersStatus.Value.IsNotEmpty())
        {
            builder.SetConditionNearbyPlayersStatus((int)config.DistanceToTriggerPlayerConditions.Value, config.ConditionNearbyPlayersStatus.Value.SplitByComma().ToArray());
        }
        if (config.ConditionAreaIds.Value.IsNotEmpty())
        {
            builder.SetConditionAreaIds(config.ConditionAreaIds.Value.SplitByComma().ConvertAll(x => int.Parse(x)));
        }

        // Conditions - Integrations
        Config cfg;

        {
            if (IntegrationManager.InstalledCLLC)
            {
                if (config.TryGet(SpawnSystemConfigCLLC.ModName, out cfg) &&
                    cfg is SpawnSystemConfigCLLC cllcConfig)
                {
                    if (cllcConfig.ConditionWorldLevelMin.Value >= 0 || cllcConfig.ConditionWorldLevelMax.Value >= 0)
                    {
                        builder.SetCllcConditionWorldLevel(cllcConfig.ConditionWorldLevelMin.Value, cllcConfig.ConditionWorldLevelMax.Value);
                    }
                }
            }

            if (IntegrationManager.InstalledEpicLoot)
            {
                if (config.TryGet(SpawnSystemConfigEpicLoot.ModName, out cfg) &&
                    cfg is SpawnSystemConfigEpicLoot elConfig)
                {
                    if (elConfig.ConditionNearbyPlayerCarryLegendaryItem.Value.IsNotEmpty())
                    {
                        builder.SetEpicLootConditionNearbyPlayerCarryLegendaryItem((int)config.DistanceToTriggerPlayerConditions.Value, elConfig.ConditionNearbyPlayerCarryLegendaryItem.Value.SplitByComma());
                    }
                    if (elConfig.ConditionNearbyPlayerCarryItemWithRarity.Value.IsNotEmpty())
                    {
                        builder.SetEpicLootConditionNearbyPlayersCarryItemWithRarity((int)config.DistanceToTriggerPlayerConditions.Value, elConfig.ConditionNearbyPlayerCarryItemWithRarity.Value.SplitByComma());
                    }
                }
            }
        }

        // Position conditions
        config.ConditionLocation.SetIfHasValue(builder.SetPositionConditionLocation);

        // Modifiers
        if (config.SetFaction.Value.IsNotEmpty())
        {
            builder.SetModifier(new ModifierSetFaction(config.SetFaction.Value));
        }

        builder.SetModifierRelentless(config.SetRelentless.Value);

        if (config.SetTryDespawnOnConditionsInvalid.Value)
        {
            builder.SetModifierDespawnOnConditionsInvalid(config.SpawnDuringDay.Value, config.SpawnDuringNight.Value, config.RequiredEnvironments.Value.SplitByComma());
        }

        builder.SetModifierDespawnOnAlert(config.SetTryDespawnOnAlert.Value);

        config.TemplateId.SetIfHasValue(builder.SetModifierTemplateId);

        builder.SetModifierTamed(config.SetTamed.Value);
        builder.SetModifierTamedCommandable(config.SetTamedCommandable.Value);

        // Modifiers - Integrations
        {
            if (IntegrationManager.InstalledCLLC)
            {
                if (config.TryGet(SpawnSystemConfigCLLC.ModName, out cfg) &&
                    cfg is SpawnSystemConfigCLLC cllcConfig)
                {
                    if (cllcConfig.SetBossAffix.Value.IsNotEmpty() &&
                        Enum.TryParse(cllcConfig.SetBossAffix.Value, true, out CllcBossAffix bossAffix))
                    {
                        builder.SetCllcModifierBossAffix(bossAffix);
                    }

                    if (cllcConfig.SetExtraEffect.Value.IsNotEmpty() &&
                        Enum.TryParse(cllcConfig.SetExtraEffect.Value, true, out CllcCreatureExtraEffect extraEffect))
                    {
                        builder.SetCllcModifierExtraEffect(extraEffect);
                    }

                    if (cllcConfig.SetInfusion.Value.IsNotEmpty() &&
                        Enum.TryParse(cllcConfig.SetInfusion.Value, true, out CllcCreatureInfusion infusion))
                    {
                        builder.SetCllcModifierInfusion(infusion);
                    }

                    if (cllcConfig.UseDefaultLevels.Value)
                    {
                        builder.SetModifier(new ModifierDefaultRollLevel(config.LevelMin.Value, config.LevelMax.Value, 0, 10f));
                    }
                }
            }

            if (IntegrationManager.InstalledMobAI)
            {
                if (config.TryGet(SpawnSystemConfigMobAI.ModName, out cfg) &&
                    cfg is SpawnSystemConfigMobAI mobAIConfig)
                {
                    if (mobAIConfig.SetAI.Value.IsNotEmpty())
                    {
                        builder.SetMobAiModifier(mobAIConfig.SetAI.Value, mobAIConfig.AIConfigFile.Value);
                    }
                }
            }
        }
    }
 public static IWorldSpawnBuilder SetModifierRelentless(this IWorldSpawnBuilder builder, bool relentless)
 {
     builder.SetModifier(new ModifierSetRelentless(relentless));
     return(builder);
 }
 public static IWorldSpawnBuilder SetModifierDespawnOnAlert(this IWorldSpawnBuilder builder, bool despawnOnAlert)
 {
     builder.SetModifier(new ModifierDespawnOnAlert(despawnOnAlert));
     return(builder);
 }
 /// <summary>
 /// Sets a custom string on entity zdo with key "spawn_template_id".
 /// Intended for integration between mods, and detecting a modified entity.
 /// </summary>
 public static IWorldSpawnBuilder SetModifierTemplateId(this IWorldSpawnBuilder builder, string templateId)
 {
     builder.SetModifier(new ModifierSetTemplateId(templateId));
     return(builder);
 }
 public static IWorldSpawnBuilder SetModifierTamedCommandable(this IWorldSpawnBuilder builder, bool commandable)
 {
     builder.SetModifier(new ModifierSetTamedCommandable(commandable));
     return(builder);
 }
 public static IWorldSpawnBuilder SetModifierTamed(this IWorldSpawnBuilder builder, bool tamed = true)
 {
     builder.SetModifier(new ModifierSetTamed(tamed));
     return(builder);
 }
 public static IWorldSpawnBuilder SetModifierFaction(this IWorldSpawnBuilder builder, Character.Faction faction)
 {
     builder.SetModifier(new ModifierSetFaction(faction));
     return(builder);
 }
 private static void SetInfusion(IWorldSpawnBuilder builder, CllcCreatureInfusion infusion) => builder.SetModifier(new ModifierCllcInfusion(infusion));
 private static void SetRandomLevel(IWorldSpawnBuilder builder) => builder.SetModifier(new ModifierCllcRandomLevel());
 private static void SetModifier(IWorldSpawnBuilder builder, string aiName, string mobAiConfig) => builder.SetModifier(new ModifierSetAI(aiName, mobAiConfig));