Skip to main content

CosmeticCustomizationManager

A class in Root.Township, Alta.Customization.

Runs the cosmetic customization room: attaches a player's cosmetics to the dummy, wires up the editable slots and handles undo, redo, randomize and exit. Client side, a component in the customization room.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private bool cacheRedoPossibleLast redo state sent to redoPossibleChanged.
private bool cacheUndoPossibleLast undo state sent to undoPossibleChanged.
private ItemScroller categoryScrollerScroller of cosmetic categories, shown on initialize.
private PlayerCustomizationHandler customizationHandlerBacking field for CustomizationHandler, attached to the player's customization manager.
private GameObject[] detachablePartsObjects destroyed with this manager.
private EditableCosmeticSlot[] editableSlotsCosmetic slots activated with the player's cosmetics on initialize.
private bool isRandomizingStops Randomize running twice at once.
private static Logger loggerNLog logger for this class.
private CosmeticPresetData originalDataCosmetics as they were when customizing started; DefaultToOriginal restores them.
private CosmeticOwnershipManager ownedBacking field for Owned.
private Player playerThe player being customized, kept to unhook input on destroy.
private BoolUnityEvent redoPossibleChangedUnity event raised with whether redo is now possible.
private BoolUnityEvent undoPossibleChangedUnity event raised with whether undo is now possible.

Properties​

MemberWhat it is
PlayerCustomizationHandler CustomizationHandler { get; }The PlayerCustomizationHandler (the character dummy) shown in the room.
PlayerCharacterCustomizationManager Manager { get; private set; }The player's customization manager currently attached to the room.
CosmeticOwnershipManager Owned { get; }The ownership manager used to decide which items can be picked or randomized.
AddressableSession Session { get; private set; }The addressable loading session used for cosmetic assets while the room is open. Disposed on destroy.

Events​

MemberWhat it is
event Action EndButtonPressedRaised when the player chooses to leave the room, by button or debug input.
event Action OnInitializedRaised once the room has finished attaching to a customization manager.

Methods​

MemberWhat it is
async void DefaultToOriginal()Reloads the cosmetics the player had when the room was opened, undoing all changes.
void ExitCustomizationRoom(PlayerInput input)Raises EndButtonPressed. Does not unload anything itself.
void ExitCustomizationRoom()Raises EndButtonPressed. Does not unload anything itself.
static uint[] GetMoreData(uint[] oldData, ref uint wordIndex)Returns a pooled uint buffer twice the size of the old one (128 if none), copying the old data across and releasing it.
async void InitializeForPlayer(Player player, CosmeticOwnershipManager owned)Attaches a player's cosmetics to the dummy and activates the slots. The Player overload also randomizes an empty outfit.
async Task InitializeForPlayer(PlayerCharacterCustomizationManager manager, CosmeticOwnershipManager owned)Attaches a player's cosmetics to the dummy and activates the slots. The Player overload also randomizes an empty outfit.
bool IsUsingOnlyOwnedItems()True if every equipped cosmetic item is in the player's purchased list.
async void Randomize()Randomizes the outfit using only owned items. Ignored while a randomize is already running.
void Redo()Redoes the last undone cosmetic change and updates the undo and redo button events.
void Undo()Undoes the last cosmetic change and updates the undo and redo button events.
5 private and internal methods
MemberWhat it is
private void OnDestroy()Stops the cosmetics session, destroys the handler and detachable parts, and unhooks the debug inputs.
private void OnItemPushed()Called when the cosmetic history gets a new entry; refreshes the undo and redo state.
private void Randomize(PlayerInput input)Randomizes the outfit using only owned items. Ignored while a randomize is already running.
private async Task StartSession(PlayerCharacterCustomizationManager manager)Starts an addressable session on the player's cosmetics if one isn't running.
private void UpdateCache()Fires undoPossibleChanged and redoPossibleChanged when the history's undo or redo state changes.

Used in​

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