Class BonusContext
Rich context object containing everything needed for bonus evaluation. Passed to BonusCause.IsTriggered() and BonusEffect.TransformValue().
Inheritance
System.Object
BonusContext
Assembly: Eco.Gameplay.dll
Syntax
public class BonusContext : Object
Constructors
BonusContext()
Declaration
Fields
CraftActions
All crafting-related BonusAction values. Used to iterate when describing bonuses across all aspects.
Declaration
public static readonly IReadOnlyList<BonusAction> CraftActions
Field Value
| Type |
Description |
| System.Collections.Generic.IReadOnlyList<BonusAction> |
|
Properties
Action
The type of action being performed.
Declaration
public BonusAction Action { get; set; }
Property Value
BlockType
The block type being targeted (if any).
Declaration
public Type BlockType { get; set; }
Property Value
| Type |
Description |
| System.Type |
|
Item
The item involved in the action (if any).
Declaration
public Item Item { get; set; }
Property Value
Recipe
The recipe being crafted (if any).
Declaration
public RecipeFamily Recipe { get; set; }
Property Value
Source
The user performing the action.
Declaration
public User Source { get; set; }
Property Value
SourceLevel
Level of the bonus source being evaluated (such as per-user talent level). 0 = no source level context.
Declaration
public int SourceLevel { get; set; }
Property Value
| Type |
Description |
| System.Int32 |
|
Tool
The tool being used (if any).
Declaration
public ToolItem Tool { get; set; }
Property Value
WorkOrder
The work order being processed (if any).
Declaration
public WorkOrder WorkOrder { get; set; }
Property Value
WorldObject
The world object involved (if any).
Declaration
public WorldObject WorldObject { get; set; }
Property Value
Methods
ForCraftingPreview(User, RecipeFamily, WorldObject, BonusAction)
Creates a preview context for a specific crafting table. Includes the world object so area bonuses and table-specific bonuses apply.
Declaration
public static BonusContext ForCraftingPreview(User user, RecipeFamily recipe, WorldObject worldObject, BonusAction action)
Parameters
Returns
ForRecipePreview(User, RecipeFamily, BonusAction)
Creates a preview context for recipe browsing (no work order or world object). Applies user talent bonuses only.
Declaration
public static BonusContext ForRecipePreview(User user, RecipeFamily recipe, BonusAction action)
Parameters
Returns
ForWorkOrder(WorkOrder, BonusAction)
Creates a context from a work order for a specific crafting action.
Declaration
public static BonusContext ForWorkOrder(WorkOrder workOrder, BonusAction action)
Parameters
Returns
Sources()
All IHasBonuses sources discoverable from this context. Uses yield to avoid allocations on hot paths.
Declaration
public IEnumerable<IHasBonuses> Sources()
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<IHasBonuses> |
|
Extension Methods