Skip to main content

CosmeticPresetTrophy

A class in Root.Township, Alta.Customization.

A small character figure that shows a saved cosmetic preset and can be picked up and placed in a preset slot. Client-side (not a network entity); it burns away when destroyed.

Constructors​

MemberWhat it is
CosmeticPresetTrophy()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

16 private and internal fields
MemberWhat it is
private static readonly int _ProgressShader property ID for _Progress, the burn or fade amount.
private Material baseBurnMaterialMaterial used for the burn-away effect.
private Material baseFadeMaterialMaterial used for the fade out and in when it returns to its slot.
private float burnDurationSeconds the burn takes.
private float fadeDurationSeconds each half of the fade takes.
private PlayerCustomizationHandler handlerCustomization handler for the dummy character the trophy shows.
private BoneIdentifier headJointHead bone reset to its rest pose after a preset is applied.
private HoverPickup hoverPickupHover pickup that holds the trophy at its slot's position.
private static readonly Logger loggerNLog logger for this class.
private Dictionary<Renderer, Material> originalMaterialsEach renderer's material before the fade, restored afterwards.
private Pickup pickupBacking field for Pickup.
private Renderer[] renderersExtra renderers (besides the dummy's) that burn and fade with it.
private AddressableSession sessionAddressable session that loads the cosmetics; created on the first Apply.
private PlayerCosmeticDefinition standardBodyBody cosmetic replaced on the trophy.
private PlayerCosmeticDefinition trophyBodyBody cosmetic used in its place.
private Dictionary<Material, Material> uniqueMaterialsEffect materials made for the trophy, keyed by the original material.

Properties​

MemberWhat it is
CosmeticPresetData Data { get; private set; }The cosmetic data last applied.
CharacterDummy Dummy { get; }The character dummy that wears the cosmetics.
PlayerCharacterCustomizationManager Manager { get; }Customisation manager for the figure's cosmetics. Uses a trophy body in place of the standard body.
Pickup Pickup { get; }The pickup used to hold the figure.
ICosmeticPresetSlot Slot { get; private set; }The preset slot the figure belongs to, or null.

Events​

MemberWhat it is
event Action<CosmeticPresetTrophy> DestroyedRaised when the burn finishes, just before the object is destroyed.

Methods​

MemberWhat it is
async void Apply(uint[] cosmeticData, int cosmeticBytes)Loads packed cosmetic data onto the figure's dummy character and remembers it as Data.
void Burn()Drops the figure, turns off its colliders and plays the burn effect, then destroys it.
void Destroy()Takes the figure out of its slot and burns it.
void ForceRetreat()Fades the figure out and back in at its slot, or burns it if it has no slot.
void ReenableColliders()Turns the figure's colliders back on.
void RegisterSlot(ICosmeticPresetSlot slot)Sets the slot the figure belongs to and points its hover target at the slot.
8 private and internal methods
MemberWhat it is
private void Awake()Sets the body override (standard body to trophy body), attaches the customization manager to the dummy and hooks the ghost hand toggles.
private IEnumerator BurnAnimation() (iterator)Coroutine: swaps every renderer to a burn material, runs its _Progress from 0 to 1 over burnDuration, raises Destroyed and destroys the object.
private void DisableGhostHands(Interactable interactable, Interactor interactor)Hides the holding hand's ghost hand while the trophy is held.
private void EnableGhostHands(Interactable interactable, Interactor interactor)Shows the ghost hand again when the trophy is let go.
private void OnDestroy()Disposes the addressable session and cleans up the made materials.
private void OnDisable()Puts the original materials back on the renderers.
private void PrepareRenderers(Dictionary<Material, Material> uniqueMaterials, IEnumerable<Renderer> renderers, Material baseMaterial)Gives each renderer a copy of the base material set up from its own material (one copy per original), and widens skinned mesh bounds.
private IEnumerator RetreatAnimation() (iterator)Coroutine: fades the trophy out, moves it back to its slot, fades it in and restores the original materials.

Used in​

Members of other types that take, return or hold a CosmeticPresetTrophy: