Class Cost
Data type used generally for cost handling, including in shops and y/n dialogue prompts.
Assembly: ItemChanger.dll
Syntax
public abstract record Cost : IEquatable<Cost>
Constructors
View Source
Cost()
Declaration
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
View Source
EqualityContract
Declaration
protected virtual Type EqualityContract { get; }
Property Value
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
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
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
View Source
Equals(Cost?)
Declaration
public virtual bool Equals(Cost? other)
Parameters
| Type |
Name |
Description |
| Cost |
other |
|
Returns
View Source
Equals(object?)
Declaration
public override bool Equals(object? obj)
Parameters
| Type |
Name |
Description |
| object |
obj |
|
Returns
Overrides
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
View Source
GetCostText()
Method which provides the cost text used in y/n prompts.
Declaration
public abstract string GetCostText()
Returns
View Source
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
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
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
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
View Source
NewGeoCost(int)
Declaration
public static Cost NewGeoCost(int amount)
Parameters
| Type |
Name |
Description |
| int |
amount |
|
Returns
View Source
NewGrubCost(int)
Declaration
public static Cost NewGrubCost(int amount)
Parameters
| Type |
Name |
Description |
| int |
amount |
|
Returns
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
View Source
PrintMembers(StringBuilder)
Declaration
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
Returns
View Source
ToString()
Declaration
public override string ToString()
Returns
Overrides
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
Returns
View Source
operator ==(Cost?, Cost?)
Declaration
public static bool operator ==(Cost? left, Cost? right)
Parameters
| Type |
Name |
Description |
| Cost |
left |
|
| Cost |
right |
|
Returns
View Source
operator !=(Cost?, Cost?)
Declaration
public static bool operator !=(Cost? left, Cost? right)
Parameters
| Type |
Name |
Description |
| Cost |
left |
|
| Cost |
right |
|
Returns
Implements
Extension Methods