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
catalogLegionCatalogparentTransformsortingLayerint
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
EyeSlot
public const string EyeSlot = "Eye"
Field Value
HairSlot
public const string HairSlot = "Hair"
Field Value
HelmetSlot
public const string HelmetSlot = "Helmet"
Field Value
MaskSlot
public const string MaskSlot = "Mask"
Field Value
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
OffHandSlot
public const string OffHandSlot = "WeaponLeft"
Field Value
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
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
catalog
public readonly LegionCatalog catalog
Field Value
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
Animator
public Animator Animator { get; }
Property Value
- Animator
Choices
public IReadOnlyDictionary<string, int> Choices { get; }
Property Value
CurrentMotion
public LegionCatalog.Motion CurrentMotion { get; }
Property Value
CurrentState
Name of the animator state currently playing (attack@spear, etc.).
public string CurrentState { get; }
Property Value
Dyes
Dye name per slot. Slots with their original color have none.
public IReadOnlyDictionary<string, string> Dyes { get; }
Property Value
Events
Root component that receives motion events (hit, cast, end).
public LegionEvents Events { get; }
Property Value
MotionSet
Motion set name of the back-hand weapon. An empty string for the default (sword, axe, blunt).
public string MotionSet { get; }
Property Value
OffHandHidden
Whether the off-hand gear is currently hidden because of the back-hand weapon.
public bool OffHandHidden { get; }
Property Value
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
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
recipeLegionRecipe
Returns
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
unitLegionUnit
Returns
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
slotNamestring
Returns
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
Returns
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
Returns
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
catalogLegionCatalogrecipeLegionRecipeparentTransformsortingLayerint
Returns
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
slotLegionCatalog.Slot
Returns
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
DyeOf(string)
public string DyeOf(string slotName)
Parameters
slotNamestring
Returns
IndexOf(string)
public int IndexOf(string slotName)
Parameters
slotNamestring
Returns
OptionOf(string)
public LegionCatalog.Option OptionOf(string slotName)
Parameters
slotNamestring
Returns
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
slotNamestringoptionLegionCatalog.OptionhelmetLegionCatalog.Option
Returns
Play(Motion, float)
public void Play(LegionCatalog.Motion motion, float normalizedTime = 0)
Parameters
motionLegionCatalog.MotionnormalizedTimefloat
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
SetSkin(string)
Changes the skin color. Null or an unknown name gives the default skin.
public void SetSkin(string skinName)
Parameters
skinNamestring
Slot(string)
public LegionCatalog.Slot Slot(string slotName)
Parameters
slotNamestring
Returns
TakesSkin(string)
Skin color is not painted on weapons (handles etc. may contain similar colors).
public static bool TakesSkin(string slotName)
Parameters
slotNamestring