Show / Hide Table of Contents

Class BonusContext

Rich context object containing everything needed for bonus evaluation. Passed to BonusCause.IsTriggered() and BonusEffect.TransformValue().

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

Constructors

BonusContext()

Declaration
public BonusContext()

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
Type Description
BonusAction

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
Type Description
Item

Recipe

The recipe being crafted (if any).

Declaration
public RecipeFamily Recipe { get; set; }
Property Value
Type Description
RecipeFamily

Source

The user performing the action.

Declaration
public User Source { get; set; }
Property Value
Type Description
User

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
Type Description
ToolItem

WorkOrder

The work order being processed (if any).

Declaration
public WorkOrder WorkOrder { get; set; }
Property Value
Type Description
WorkOrder

WorldObject

The world object involved (if any).

Declaration
public WorldObject WorldObject { get; set; }
Property Value
Type Description
WorldObject

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
Type Name Description
User user
RecipeFamily recipe
WorldObject worldObject
BonusAction action
Returns
Type Description
BonusContext

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
Type Name Description
User user
RecipeFamily recipe
BonusAction action
Returns
Type Description
BonusContext

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
Type Name Description
WorkOrder workOrder
BonusAction action
Returns
Type Description
BonusContext

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

TagUtils.TagNames(Object, Boolean)
TagUtils.TagDisplayNames(Object, Boolean)
ClientSetViewExtensions.SetClassOfProperty(Object, Player, String, String, Int32)
TypeTooltipExtensions.UILinkGeneric(Object)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾