Show / Hide Table of Contents

Class BonusManager

Central entry point for bonus resolution and application. Callers build a BonusContext and call ApplyBonuses(BonusContext, Single). Discovers bonuses from context entities that implement IHasBonuses. Handles per-source level resolution (e.g. User's per-talent levels).

Inheritance
System.Object
BonusManager
Namespace: Eco.Gameplay.Bonuses
Assembly: Eco.Gameplay.dll
Syntax
public static class BonusManager : Object

Methods

ApplyBonuses(BonusContext, Single)

Apply all bonuses from context sources to a value. Handles per-talent level resolution for User sources.

Declaration
public static float ApplyBonuses(BonusContext context, float value)
Parameters
Type Name Description
BonusContext context
System.Single value
Returns
Type Description
System.Single

ApplyBonusesFrom(IHasBonuses, BonusContext, Single)

Apply bonuses from a single source directly (no source decomposition or level resolution).

Declaration
public static float ApplyBonusesFrom(IHasBonuses source, BonusContext context, float value)
Parameters
Type Name Description
IHasBonuses source
BonusContext context
System.Single value
Returns
Type Description
System.Single

DescribeApplicableBonuses(BonusContext)

Describe all applicable bonuses from context sources. Handles per-talent level resolution so descriptions show context-aware values.

Declaration
public static IEnumerable<LocString> DescribeApplicableBonuses(BonusContext context)
Parameters
Type Name Description
BonusContext context
Returns
Type Description
System.Collections.Generic.IEnumerable<LocString>

DescribeApplicableBonusesFlat(BonusContext)

Describe applicable bonuses with flat output: each entry is the talent's MarkedUpName followed by its effect description, no nested foldouts. For User sources, resolves the owning TalentGroup to display its MarkedUpName. Non-User sources fall back to the bonus Name.

Declaration
public static IReadOnlyList<LocString> DescribeApplicableBonusesFlat(BonusContext context)
Parameters
Type Name Description
BonusContext context
Returns
Type Description
System.Collections.Generic.IReadOnlyList<LocString>

DescribeApplicableBonusesGrouped(IEnumerable<BonusContext>)

Describe applicable bonuses across multiple contexts (e.g. all craft actions), grouped by source name. Produces one foldout per talent instead of one per bonus×action, dramatically reducing tooltip text length.

Declaration
public static IEnumerable<LocString> DescribeApplicableBonusesGrouped(IEnumerable<BonusContext> contexts)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<BonusContext> contexts
Returns
Type Description
System.Collections.Generic.IEnumerable<LocString>

DescribeTalentBonusesGrouped(User, Func<BonusAction, BonusContext>)

Describes applicable bonuses grouped by source talent, with TalentGroup UILinks as headers. Iterates the user's talents across all craft actions, deduplicates per-talent, and returns one entry per talent with applicable bonuses. contextFactory creates a BonusContext for each BonusAction; callers choose ForRecipePreview or ForWorkOrder.

Declaration
public static IReadOnlyList<LocString> DescribeTalentBonusesGrouped(User user, Func<BonusAction, BonusContext> contextFactory)
Parameters
Type Name Description
User user
System.Func<BonusAction, BonusContext> contextFactory
Returns
Type Description
System.Collections.Generic.IReadOnlyList<LocString>

FindUnlockingTalents(RecipeFamily)

Find all talents whose bonuses would unlock the given recipe. Skips base template classes.

Declaration
public static IEnumerable<Talent> FindUnlockingTalents(RecipeFamily recipe)
Parameters
Type Name Description
RecipeFamily recipe
Returns
Type Description
System.Collections.Generic.IEnumerable<Talent>

IsRecipeUnlocked(BonusContext)

Check whether any bonus unlocks a recipe for the given context. Convention: starts at 0 (locked), any override effect sets it to 1 (unlocked).

Declaration
public static bool IsRecipeUnlocked(BonusContext context)
Parameters
Type Name Description
BonusContext context
Returns
Type Description
System.Boolean
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾