Class LegionBuilder

Namespace
PixelUnitStudio
Assembly
PixelUnitStudio.Runtime.dll

Assembles one hero from the catalog, applies slot options, and plays motions that fit the back-hand weapon type. Used by the edit screen and save/export, and also for assembling heroes at game runtime (Create, LegionRecipe).

public sealed class LegionBuilder
Inheritance
LegionBuilder
Inherited Members

Constructors

LegionBuilder(LegionCatalog, Transform, int)

public LegionBuilder(LegionCatalog catalog, Transform parent, int sortingLayer = 0)

Parameters

catalog LegionCatalog
parent Transform
sortingLayer int

Fields

AttackSlot

Only the back hand attacks. The motion set of this slot's weapon decides the held pose and attack motion.

public const string AttackSlot = "WeaponRight"

Field Value

string

EyeSlot

public const string EyeSlot = "Eye"

Field Value

string

HairSlot

public const string HairSlot = "Hair"

Field Value

string

HelmetSlot

public const string HelmetSlot = "Helmet"

Field Value

string

MaskSlot

public const string MaskSlot = "Mask"

Field Value

string

OffHandHiddenSets

Holding a bow or crossbow aimed with the back hand hides the off-hand gear (the selection is kept). It overlaps the aiming pose.

public static readonly HashSet<string> OffHandHiddenSets

Field Value

HashSet<string>

OffHandSlot

public const string OffHandSlot = "WeaponLeft"

Field Value

string

SkinKey

Name under which the skin color (LegionDye.Skins) is written in recipe text and save records. Not a catalog slot.

public const string SkinKey = "Skin"

Field Value

string

SocketEye

Eye option shown as dark sockets behind a mask when no eyes are chosen (masks have eye holes; bare skin there looks blank).

public const string SocketEye = "eye_dark"

Field Value

string

catalog

public readonly LegionCatalog catalog

Field Value

LegionCatalog

Properties

Actions

Plays custom actions (LegionAction) with this hero's weapon type. Added on first use; set its library to play actions by name.

public LegionActionPlayer Actions { get; }

Property Value

LegionActionPlayer

Animator

public Animator Animator { get; }

Property Value

Animator

Choices

public IReadOnlyDictionary<string, int> Choices { get; }

Property Value

IReadOnlyDictionary<string, int>

CurrentMotion

public LegionCatalog.Motion CurrentMotion { get; }

Property Value

LegionCatalog.Motion

CurrentState

Name of the animator state currently playing (attack@spear, etc.).

public string CurrentState { get; }

Property Value

string

Dyes

Dye name per slot. Slots with their original color have none.

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

Property Value

IReadOnlyDictionary<string, string>

Events

Root component that receives motion events (hit, cast, end).

public LegionEvents Events { get; }

Property Value

LegionEvents

MotionSet

Motion set name of the back-hand weapon. An empty string for the default (sword, axe, blunt).

public string MotionSet { get; }

Property Value

string

OffHandHidden

Whether the off-hand gear is currently hidden because of the back-hand weapon.

public bool OffHandHidden { get; }

Property Value

bool

Root

public GameObject Root { get; }

Property Value

GameObject

Skin

Skin color name (LegionDye.Skins). Null for the default skin.

public string Skin { get; }

Property Value

string

Methods

Apply(LegionRecipe)

Applies a combination. Slots not listed are cleared (if they can be) or set to the default. Returns option names missing from the catalog ("slot/name").

public List<string> Apply(LegionRecipe recipe)

Parameters

recipe LegionRecipe

Returns

List<string>

Apply(LegionUnit)

Reapplies the options of a saved hero. Returns option names missing from the catalog (those slots are cleared or set to the default).

public List<string> Apply(LegionUnit unit)

Parameters

unit LegionUnit

Returns

List<string>

ApplyDefaults()

Sets every slot to its default option.

public void ApplyDefaults()

CanDye(string)

Whether the current option can be dyed (has a main color group).

public bool CanDye(string slotName)

Parameters

slotName string

Returns

bool

Choose(string, int)

Applies a slot's option. -1 clears it. Returns false for a value that cannot be chosen.

public bool Choose(string slotName, int index)

Parameters

slotName string
index int

Returns

bool

Choose(string, string)

Applies an option by name. Empty clears the slot. False for an unknown name or a slot that cannot be cleared.

public bool Choose(string slotName, string optionName)

Parameters

slotName string
optionName string

Returns

bool

Create(LegionCatalog, LegionRecipe, Transform, int)

Creates one hero from a combination at game runtime and plays the idle motion. To remove it, Destroy the Root.

public static LegionBuilder Create(LegionCatalog catalog, LegionRecipe recipe, Transform parent, int sortingLayer = 0)

Parameters

catalog LegionCatalog
recipe LegionRecipe
parent Transform
sortingLayer int

Returns

LegionBuilder

DefaultOption(Slot)

Option chosen on creation. Empty if the slot has no defaultOption; the first option for slots that cannot be empty.

public static int DefaultOption(LegionCatalog.Slot slot)

Parameters

slot LegionCatalog.Slot

Returns

int

Dye(string, string)

Dyes a slot. Null restores the original color. The dye stays on the slot when the option changes and is applied to the new option.

public void Dye(string slotName, string paletteName)

Parameters

slotName string
paletteName string

DyeOf(string)

public string DyeOf(string slotName)

Parameters

slotName string

Returns

string

IndexOf(string)

public int IndexOf(string slotName)

Parameters

slotName string

Returns

int

OptionOf(string)

public LegionCatalog.Option OptionOf(string slotName)

Parameters

slotName string

Returns

LegionCatalog.Option

PiecesFor(string, Option, Option)

Pieces to show for an option. Hair under a helmet that covers the head uses its trimmed version, so tall styles do not poke through.

public static List<LegionCatalog.Piece> PiecesFor(string slotName, LegionCatalog.Option option, LegionCatalog.Option helmet)

Parameters

slotName string
option LegionCatalog.Option
helmet LegionCatalog.Option

Returns

List<LegionCatalog.Piece>

Play(Motion, float)

public void Play(LegionCatalog.Motion motion, float normalizedTime = 0)

Parameters

motion LegionCatalog.Motion
normalizedTime float

Play(string, float)

Plays a motion by state name (idle, running, attack, damaged, death, cast, stun). If a state fits the weapon type, that one is chosen.

public void Play(string motion, float normalizedTime = 0)

Parameters

motion string
normalizedTime float

SetSkin(string)

Changes the skin color. Null or an unknown name gives the default skin.

public void SetSkin(string skinName)

Parameters

skinName string

Slot(string)

public LegionCatalog.Slot Slot(string slotName)

Parameters

slotName string

Returns

LegionCatalog.Slot

TakesSkin(string)

Skin color is not painted on weapons (handles etc. may contain similar colors).

public static bool TakesSkin(string slotName)

Parameters

slotName string

Returns

bool