Show / Hide Table of Contents

Class Cost

Data type used generally for cost handling, including in shops and y/n dialogue prompts.

Inheritance
object
Cost
ConsumablePDIntCost
GeoCost
CumulativeRancidEggCost
FlameCost
MultiCost
PDBoolCost
PDIntCost
Implements
IEquatable<Cost>
Inherited Members
object.GetType()
object.MemberwiseClone()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: ItemChanger
Assembly: ItemChanger.dll
Syntax
public abstract record Cost : IEquatable<Cost>

Constructors

View Source

Cost()

Declaration
protected Cost()
View Source

Cost(Cost)

Declaration
protected Cost(Cost original)
Parameters
Type Name Description
Cost original

Properties

View Source

DiscountRate

A number between 0 and 1 which modifies numeric costs. Only considered by some costs.
For example, the Leg Eater dung discount sets this to 0.8, to indicate that geo costs should be at 80% price.

Declaration
public virtual float DiscountRate { get; set; }
Property Value
Type Description
float
View Source

EqualityContract

Declaration
protected virtual Type EqualityContract { get; }
Property Value
Type Description
Type
View Source

Paid

Represents whether the cost has been paid yet. Paid costs will be subsequently ignored.

Declaration
public bool Paid { get; set; }
Property Value
Type Description
bool
View Source

Recurring

If true, the cost will not set the value of Paid during Pay. Use for costs which are expected to be paid multiple times.
Note that Paid can still be set independently to indicate when the cost should no longer be required.

Declaration
public virtual bool Recurring { get; set; }
Property Value
Type Description
bool

Methods

View Source

AfterPay()

Method for any effects which should take place after the cost has been paid (e.g. conditionally setting Paid, etc).

Declaration
public virtual void AfterPay()
View Source

CanPay()

Returns whether the cost can currently be paid.

Declaration
public abstract bool CanPay()
Returns
Type Description
bool
View Source

Equals(Cost?)

Declaration
public virtual bool Equals(Cost? other)
Parameters
Type Name Description
Cost other
Returns
Type Description
bool
View Source

Equals(object?)

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj
Returns
Type Description
bool
Overrides
object.Equals(object)
View Source

GetBaseCost()

Points to the root-level cost for pattern-matching contexts such as CostDisplayer. Primarily intended for implementation by costs which wrap a single other cost to apply additional functionality.

Declaration
public virtual Cost GetBaseCost()
Returns
Type Description
Cost
Remarks

Implementers of wrapper costs should keep in mind that costs being wrapped may themselves be wrapper costs. A typical correct implementation would likely be WrappedCost.GetBaseCost().

View Source

GetCostText()

Method which provides the cost text used in y/n prompts.

Declaration
public abstract string GetCostText()
Returns
Type Description
string
View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
object.GetHashCode()
View Source

HasPayEffects()

Does paying this cost have effects (particularly that could prevent paying other costs of the same type)?

Declaration
public abstract bool HasPayEffects()
Returns
Type Description
bool
View Source

Includes(Cost)

Is the other cost a subset of this cost?

Declaration
public virtual bool Includes(Cost c)
Parameters
Type Name Description
Cost c
Returns
Type Description
bool
View Source

Load()

Method which should be called by the Cost's owner during initial loading. Used by certain costs which require global or shared tracking.

Declaration
public virtual void Load()
View Source

NewEssenceCost(int)

Declaration
public static Cost NewEssenceCost(int amount)
Parameters
Type Name Description
int amount
Returns
Type Description
Cost
View Source

NewGeoCost(int)

Declaration
public static Cost NewGeoCost(int amount)
Parameters
Type Name Description
int amount
Returns
Type Description
Cost
View Source

NewGrubCost(int)

Declaration
public static Cost NewGrubCost(int amount)
Parameters
Type Name Description
int amount
Returns
Type Description
Cost
View Source

OnPay()

Method for administering all effects of the cost during Pay.

Declaration
public abstract void OnPay()
View Source

Pay()

Pays the cost, performing any effects and setting the cost to Paid.

Declaration
public void Pay()
View Source

PrintMembers(StringBuilder)

Declaration
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
Type Name Description
StringBuilder builder
Returns
Type Description
bool
View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()
View Source

Unload()

Method which should be called by the Cost's owner during unloading. Used by certain costs which require global or shared tracking.

Declaration
public virtual void Unload()

Operators

View Source

operator +(Cost, Cost)

Combines two costs into a MultiCost. If either argument is null, returns the other argument. If one or both costs is a MultiCost, flattens the result.

Declaration
public static Cost operator +(Cost a, Cost b)
Parameters
Type Name Description
Cost a
Cost b
Returns
Type Description
Cost
View Source

operator ==(Cost?, Cost?)

Declaration
public static bool operator ==(Cost? left, Cost? right)
Parameters
Type Name Description
Cost left
Cost right
Returns
Type Description
bool
View Source

operator !=(Cost?, Cost?)

Declaration
public static bool operator !=(Cost? left, Cost? right)
Parameters
Type Name Description
Cost left
Cost right
Returns
Type Description
bool

Implements

IEquatable<T>

Extension Methods

Extensions.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX