Class LegionRecipe

Namespace
PixelUnitStudio
Assembly
PixelUnitStudio.Runtime.dll

One hero's combination written as option names. Used to assemble heroes at game runtime (LegionBuilder.Create / Apply). As text, "slot=option[:dye]" entries are joined by spaces. Example: "Helmet=helmet_mitre Cloth=robe_priest:gold WeaponRight=staff_sun". Written by name, so it is found correctly even if the catalog is rebuilt and the order changes. Slots not listed are cleared (if they can be) or set to the default. The skin color is written like "Skin=orc" (LegionDye.Skins). If not written, it is the default skin.

public sealed class LegionRecipe
Inheritance
LegionRecipe
Inherited Members

Constructors

LegionRecipe()

public LegionRecipe()

Fields

DyeChance

Probability that a dyeable part is dyed in a random combination.

public const float DyeChance = 0.4

Field Value

float

FillChance

Probability of filling a slot in a random combination. Slots not listed get 0.5; slots that cannot be cleared are always filled.

public static readonly IReadOnlyDictionary<string, float> FillChance

Field Value

IReadOnlyDictionary<string, float>

OffHandRandomSets

Motion sets a random combination puts in the off hand. The off hand is decoration, so only one-handed weapons and shields (default) and daggers are chosen.

public static readonly HashSet<string> OffHandRandomSets

Field Value

HashSet<string>

SkinChance

Probability that a random combination picks a non-default skin color.

public const float SkinChance = 0.3

Field Value

float

Properties

Dyes

public IReadOnlyDictionary<string, string> Dyes { get; }

Property Value

IReadOnlyDictionary<string, string>

Options

public IReadOnlyDictionary<string, string> Options { get; }

Property Value

IReadOnlyDictionary<string, string>

Skin

public string Skin { get; }

Property Value

string

Methods

DyeFor(string)

public string DyeFor(string slot)

Parameters

slot string

Returns

string

From(LegionBuilder)

Reads the current combination of a hero being assembled.

public static LegionRecipe From(LegionBuilder builder)

Parameters

builder LegionBuilder

Returns

LegionRecipe

From(LegionUnit)

Reads the combination of a saved hero prefab.

public static LegionRecipe From(LegionUnit unit)

Parameters

unit LegionUnit

Returns

LegionRecipe

Missing(LegionCatalog)

Returns option and dye names ("slot/name") not in the catalog.

public List<string> Missing(LegionCatalog catalog)

Parameters

catalog LegionCatalog

Returns

List<string>

OptionFor(string)

public string OptionFor(string slot)

Parameters

slot string

Returns

string

Parse(string)

Reads "slot=option[:dye] ..." text. FormatException if any piece is malformed.

public static LegionRecipe Parse(string text)

Parameters

text string

Returns

LegionRecipe

Random(LegionCatalog, Random)

Builds a random combination from the catalog. The same seed gives the same combination (for the same catalog).

public static LegionRecipe Random(LegionCatalog catalog, Random random)

Parameters

catalog LegionCatalog
random Random

Returns

LegionRecipe

Set(string, string, string)

Writes an option into a slot. If option is empty the slot is cleared. If dye is empty, the original color.

public LegionRecipe Set(string slot, string option, string dye = null)

Parameters

slot string
option string
dye string

Returns

LegionRecipe

ToString()

public override string ToString()

Returns

string