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.
- Listed in Customization and screenshots
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
CosmeticPresetTrophy() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
16 private and internal fields
| Member | What it is |
|---|---|
private static readonly int _Progress | Shader property ID for _Progress, the burn or fade amount. |
private Material baseBurnMaterial | Material used for the burn-away effect. |
private Material baseFadeMaterial | Material used for the fade out and in when it returns to its slot. |
private float burnDuration | Seconds the burn takes. |
private float fadeDuration | Seconds each half of the fade takes. |
private PlayerCustomizationHandler handler | Customization handler for the dummy character the trophy shows. |
private BoneIdentifier headJoint | Head bone reset to its rest pose after a preset is applied. |
private HoverPickup hoverPickup | Hover pickup that holds the trophy at its slot's position. |
private static readonly Logger logger | NLog logger for this class. |
private Dictionary<Renderer, Material> originalMaterials | Each renderer's material before the fade, restored afterwards. |
private Pickup pickup | Backing field for Pickup. |
private Renderer[] renderers | Extra renderers (besides the dummy's) that burn and fade with it. |
private AddressableSession session | Addressable session that loads the cosmetics; created on the first Apply. |
private PlayerCosmeticDefinition standardBody | Body cosmetic replaced on the trophy. |
private PlayerCosmeticDefinition trophyBody | Body cosmetic used in its place. |
private Dictionary<Material, Material> uniqueMaterials | Effect materials made for the trophy, keyed by the original material. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event Action<CosmeticPresetTrophy> Destroyed | Raised when the burn finishes, just before the object is destroyed. |
Methods
| Member | What 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
| Member | What 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:
CosmeticPresetApplier.ApplyTrophy, CosmeticPresetDestroyer.CheckDestroy, CosmeticPresetDestroyer.DestroyTrophy, CosmeticPresetDestroyer.trackedTrophies, CosmeticPresetDestroyer.TrophyEntered, CosmeticPresetDestroyer.TrophyExited, CosmeticPresetSlot.DeregisterTrophy, CosmeticPresetSlot.DisableEffects, CosmeticPresetSlot.EnableEffects, CosmeticPresetSlot.RegisterTrophy, CosmeticPresetSlot.RegisterTrophyInternal, CosmeticPresetSlot.SaveTrophy, CosmeticPresetSlot.Trophy, CosmeticPresetsManager.GetNewTrophy, CosmeticPresetsManager.latestTrophy, CosmeticPresetsManager.trophyPrefab, CosmeticPresetTrophyTrigger.CleanTrophy, CosmeticPresetTrophyTrigger.CurrentTrophies, CosmeticPresetTrophyTrigger.mappedTrophies, CosmeticPresetTrophyTrigger.ReleasedTrophy, CosmeticPresetTrophyTrigger.RemoveTrophy, CosmeticPresetTrophyTrigger.RemoveTrophyCollider, CosmeticPresetTrophyTrigger.trackedTrophies, CosmeticPresetTrophyTrigger.TrophyEntered, CosmeticPresetTrophyTrigger.TrophyExited, CosmeticRotatingSlot.DeregisterTrophy, CosmeticRotatingSlot.DisableEffects, CosmeticRotatingSlot.EnableEffects, CosmeticRotatingSlot.GetDataFrom, CosmeticRotatingSlot.SaveTrophy, CosmeticRotatingSlot.Setup, CosmeticRotatingSlot.Trophy, ICosmeticPresetSlot.DeregisterTrophy.