public static IWorldSpawnBuilder SetCllcModifierInfusion(this IWorldSpawnBuilder builder, CllcCreatureInfusion infusion)
    {
        if (IntegrationManager.InstalledCLLC)
        {
            SetInfusion(builder, infusion);
        }

        return(builder);
    }
    public static IWorldSpawnBuilder SetCllcModifierRandomLevel(this IWorldSpawnBuilder builder)
    {
        if (IntegrationManager.InstalledCLLC)
        {
            SetRandomLevel(builder);
        }

        return(builder);
    }
コード例 #3
0
    public static IWorldSpawnBuilder SetCllcConditionWorldLevel(this IWorldSpawnBuilder builder, int?minWorldLevel, int?maxWorldLevel)
    {
        if (IntegrationManager.InstalledCLLC)
        {
            SetConditionWorldLevel(builder, minWorldLevel, maxWorldLevel);
        }

        return(builder);
    }
コード例 #4
0
    public static IWorldSpawnBuilder SetMobAiModifier(this IWorldSpawnBuilder builder, string aiName, string mobAiConfig)
    {
        if (IntegrationManager.InstalledMobAI)
        {
            SetModifier(builder, aiName, mobAiConfig);
        }

        return builder;
    }
    public static IWorldSpawnBuilder SetCllcModifierExtraEffect(this IWorldSpawnBuilder builder, CllcCreatureExtraEffect extraEffect)
    {
        if (IntegrationManager.InstalledCLLC)
        {
            SetExtraEffect(builder, extraEffect);
        }

        return(builder);
    }
    public static IWorldSpawnBuilder SetCllcModifierBossAffix(this IWorldSpawnBuilder builder, string bossAffixName)
    {
        if (IntegrationManager.InstalledCLLC)
        {
            SetBossAffix(builder, bossAffixName);
        }

        return(builder);
    }
 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);
 }
コード例 #8
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);
    }
コード例 #9
0
 /// <summary>
 /// Template only enabled when a player within <c>distance</c> of spawner emits more noise than <c>noiseRequired</c>.
 /// </summary>
 public static IWorldSpawnBuilder SetConditionNearbyPlayersNoise(this IWorldSpawnBuilder builder, int distance, float noiseRequired)
 {
     builder.SetCondition(new ConditionNearbyPlayersNoise(distance, noiseRequired));
     return(builder);
 }
 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));
コード例 #12
0
 /// <summary>
 /// Template only enabled when a player within <c>distance</c> of spawner has a status in <c>statusEffectNames</c>.
 /// </summary>
 public static IWorldSpawnBuilder SetConditionNearbyPlayersStatus(this IWorldSpawnBuilder builder, int distance, params string[] statusEffectNames)
 {
     builder.SetCondition(new ConditionNearbyPlayersStatus(distance, statusEffectNames));
     return(builder);
 }
 private static void SetRandomLevel(IWorldSpawnBuilder builder) => builder.SetModifier(new ModifierCllcRandomLevel());
 private static void SetInfusion(IWorldSpawnBuilder builder, CllcCreatureInfusion infusion) => builder.SetModifier(new ModifierCllcInfusion(infusion));
コード例 #15
0
 /// <summary>
 /// Template only enabled when players within <c>distance</c> of spawner has a combined inventory value greater than <c>combinedValueRequired</c>.
 /// </summary>
 public static IWorldSpawnBuilder SetConditionNearbyPlayersCarryValue(this IWorldSpawnBuilder builder, int distance, int combinedValueRequired)
 {
     builder.SetCondition(new ConditionNearbyPlayersCarryValue(distance, combinedValueRequired));
     return(builder);
 }
コード例 #16
0
 /// <summary>
 /// Sets range from center of world, in which spawning is allowed.
 /// </summary>
 /// <param name="minDistance">Required distance from center.</param>
 /// <param name="maxDistance">Maximum distance from center. If null, there will be no limit.</param>
 public static IWorldSpawnBuilder SetConditionDistanceToCenter(this IWorldSpawnBuilder builder, double?minDistance = null, double?maxDistance = null)
 {
     builder.SetCondition(new ConditionDistanceToCenter(minDistance, maxDistance));
     return(builder);
 }
コード例 #17
0
 /// <summary>
 /// <para>Spawn template is only active when player is within <c>withinDistance</c> to Spawner.</para>
 /// </summary>
 public static IWorldSpawnBuilder SetConditionCloseToPlayer(this IWorldSpawnBuilder builder, float withinDistance)
 {
     builder.SetCondition(new ConditionCloseToPlayer(withinDistance));
     return(builder);
 }
コード例 #18
0
 /// <summary>
 /// <para>Set spawn chance based on each area.</para>
 /// <para>
 ///     Each area rolls chance pr template id once pr seed.
 ///     If the chance roll is less than listed here,
 ///     this area will never activate this template, and vice versa.
 /// </para>
 /// <para>
 ///     This allows for sitations where only some areas (eg., 10% of blackforests) will have a spawn show up.
 /// </para>
 /// </summary>
 public static IWorldSpawnBuilder SetConditionAreaSpawnChance(this IWorldSpawnBuilder builder, float areaChance)
 {
     builder.SetCondition(new ConditionAreaSpawnChance(areaChance, builder.Id));
     return(builder);
 }
コード例 #19
0
 /// <summary>
 /// <para>Set area ids in which spawning is enabled.</para>
 /// <para>Should only be used when map is pre-determined.</para>
 /// </summary>
 public static IWorldSpawnBuilder SetConditionAreaIds(this IWorldSpawnBuilder builder, params int[] areaIds)
 {
     builder.SetCondition(new ConditionAreaIds(areaIds.ToList()));
     return(builder);
 }
コード例 #20
0
 /// <summary>
 /// Template only enabled when the world day is within the indicated range.
 /// </summary>
 /// <param name="minDays">Minimum days required before template is activated.</param>
 /// <param name="maxDays">Maximum days after which template is deactivated. If null, there is no limit.</param>
 public static IWorldSpawnBuilder SetConditionWorldAge(this IWorldSpawnBuilder builder, int?minDays = null, int?maxDays = null)
 {
     builder.SetCondition(new ConditionWorldAge(minDays, maxDays));
     return(builder);
 }
コード例 #21
0
 /// <summary>
 /// Template only enabled when a player within <c>distance</c> of spawner has a status in <c>statusEffects</c>.
 /// </summary>
 public static IWorldSpawnBuilder SetConditionNearbyPlayersStatus(this IWorldSpawnBuilder builder, int distance, params StatusEffect[] statusEffects)
 {
     builder.SetCondition(new ConditionNearbyPlayersStatus(distance, statusEffects.Select(x => x.ToString()).ToArray()));
     return(builder);
 }
 private static void SetExtraEffect(IWorldSpawnBuilder builder, string extraEffectName) => builder.SetModifier(new ModifierCllcExtraEffect(extraEffectName));
 private static void SetExtraEffect(IWorldSpawnBuilder builder, CllcCreatureExtraEffect extraEffect) => builder.SetModifier(new ModifierCllcExtraEffect(extraEffect));
コード例 #24
0
 /// <summary>
 /// <para>Sets global keys which must not be present for spawning to be allowed.</para>
 /// <para>
 ///     Eg., if "KilledTroll", "defeated_eikthyr" and world has global key "defeated_eikthyr",
 ///     then this template will be disabled.
 /// </para>
 /// </summary>
 public static IWorldSpawnBuilder SetGlobalKeysRequiredMissing(this IWorldSpawnBuilder builder, params string[] globalKeys)
 {
     builder.SetCondition(new ConditionGlobalKeysRequiredMissing(globalKeys));
     return(builder);
 }
 private static void SetInfusion(IWorldSpawnBuilder builder, string infusionName) => builder.SetModifier(new ModifierCllcInfusion(infusionName));
コード例 #26
0
 /// <summary>
 /// <para>Sets global keys which must not be present for spawning to be allowed.</para>
 /// <para>
 ///     Eg., if GlobalKey.Troll, GlobalKey.Eikthyr and world has global key "defeated_eikthyr",
 ///     then this template will be disabled.
 /// </para>
 /// </summary>
 public static IWorldSpawnBuilder SetGlobalKeysRequiredMissing(this IWorldSpawnBuilder builder, IEnumerable <GlobalKey> globalKeys)
 {
     builder.SetCondition(new ConditionGlobalKeysRequiredMissing(globalKeys.Select(x => x.GetName()).ToArray()));
     return(builder);
 }
コード例 #27
0
 /// <summary>
 /// Template only enabled when a player within <c>distance</c> of spawner has one of the listed items in inventory.
 /// </summary>
 public static IWorldSpawnBuilder SetConditionNearbyPlayersCarryItem(this IWorldSpawnBuilder builder, int distance, params string[] itemPrefabNames)
 {
     builder.SetCondition(new ConditionNearbyPlayersCarryItem(distance, itemPrefabNames));
     return(builder);
 }
コード例 #28
0
    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);
                    }
                }
            }
        }
    }
コード例 #29
0
 /// <summary>
 /// <para>Sets global keys which must not be present for spawning to be allowed.</para>
 /// <para>
 ///     Eg., if "KilledTroll", "defeated_eikthyr" and world has global key "defeated_eikthyr",
 ///     then this template will be disabled.
 /// </para>
 /// </summary>
 public static IWorldSpawnBuilder SetGlobalKeysRequiredMissing(this IWorldSpawnBuilder builder, IEnumerable <string> globalKeys)
 {
     builder.SetCondition(new ConditionGlobalKeysRequiredMissing(globalKeys.ToArray()));
     return(builder);
 }
コード例 #30
0
 /// <summary>
 /// Template only enabled when a player within <c>distance</c> of spawner has a status in <c>statusEffectNames</c>.
 /// </summary>
 public static IWorldSpawnBuilder SetConditionNearbyPlayersStatus(this IWorldSpawnBuilder builder, int distance, IEnumerable <string> statusEffectNames)
 {
     builder.SetCondition(new ConditionNearbyPlayersStatus(distance, statusEffectNames.ToArray()));
     return(builder);
 }