CustomizationWrapper
An abstract class in Root.Township, Alta.Customization.
The set of cosmetics a character is wearing, by item hash, with their arguments (such as colours). Adding an item removes anything in the same slots; changes go to an undo history and to a visual manager that dresses the character.
- Listed in Customization and screenshots
- Inherits or implements
IHasHistory,ICustomizationWrapper - Derived types
PlayerCosmeticWrapper,PlayerEquipmentWrapper - Documented in Customization
Constructors
| Member | What it is |
|---|---|
CustomizationWrapper(ICustomizationVisualManager manager) | Creates a CustomizationWrapper from manager. |
Fields
| Member | What it is |
|---|---|
protected ICustomizationVisualManager visualManager | The visual manager that dresses the character. |
11 private and internal fields
| Member | What it is |
|---|---|
private CancellationTokenSource currentLoad | Cancellation token of the load in progress, if any. |
private IHistoryManager<CustomizationHistoryAction> historyManager | Backing field for History and HistoryManager. |
private const int HistorySize | Undo history length: 50. |
private bool isGroupAction | True between StartGroupAction and EndGroupAction; history pushes wait until the group ends. |
private readonly bool isVisible | Always true in this build; when false, items would be tracked without registering visuals. |
private readonly HashSet<uint> items | Hashes of the customization items currently worn. |
private CosmeticPresetData lastState | The last outfit snapshot pushed to history, used as the undo point for the next change. |
private static readonly Logger logger | NLog logger for this class. |
private int packingCount | Number of handlers still packing cosmetics after ApplyStreamItems. |
private readonly Dictionary<uint, IEnumerable<int>> primaryCache | Primary slots each worn item takes, keyed by item hash, so removal can free them. |
private readonly Dictionary<int, uint> tracked | Which item hash fills each primary slot. |
Properties
| Member | What it is |
|---|---|
Dictionary<uint, CustomizationArguments[]> Arguments { get; } | Arguments for each worn item, by hash. |
IHistoryManager History { get; } | Undo history of up to 50 changes. |
IEnumerable<uint> Items { get; } | Hashes of the worn items. |
uint LastAdded { get; private set; } | Hash of the item added last. |
Dictionary<ICustomizationDefinition, ICustomizationDefinition> OverrideSet { get; set; } | Definitions to swap for others, such as a trophy body in place of the standard body. |
AddressableSession Session { get; private set; } | The addressable session used to load cosmetic assets. |
1 private and internal property
| Member | What it is |
|---|---|
private IHistoryManager<CustomizationHistoryAction> HistoryManager { get; } | Typed undo history, created on first use with room for 50 steps. |
Events
| Member | What it is |
|---|---|
event Action<uint> ItemAdded | Raised with the hash when an item is added. |
event Action<uint> ItemRemoved | Raised with the hash when an item is removed. |
Methods
| Member | What it is |
|---|---|
async Task<bool> Add(uint item, CustomizationArguments[] arguments) | Wears an item, removing items that share its slots. Uses default arguments if none are given. |
bool Add(ICustomizationDefinition definition, CustomizationArguments[] arguments) | Wears an item, removing items that share its slots. Uses default arguments if none are given. |
void ApplyArguments(uint item) | Reapplies an item's stored arguments to the visuals. The item must be worn. |
void ApplyStreamItems(IEnumerable<CustomizationItemAndArguments> items) | Replaces everything with a list of items and arguments, as one history step. On a headless server it only records them. |
void Clear() | Removes every item and clears the visuals. |
void EndGroupAction() | Ends a group of changes and records them as one history step. |
CustomizationArguments[] GetArguments(uint hash) | Arguments for a worn item, or null. |
virtual IEnumerable<uint> GetConflicts(ICustomizationVisual item) (iterator) | Worn items that use any of the given visual's slots. |
abstract Task<ICustomizationDefinition> GetItem(uint hash) | Loads the definition for an item hash. |
uint GetSlot(int slot) | Hash of the item in a slot, or 0. |
bool IsSlotDisabled(int slot) | Asks the visual manager whether a slot is disabled. |
virtual bool IsUnblocked(ICustomizationVisual item) | True if none of the visual's slots are taken. |
virtual uint Remove(int slot, out CustomizationArguments[] arguments, bool isPushingHistory) | Removes an item by hash, or whatever is in a slot, and returns its arguments. |
virtual void Remove(uint item, out CustomizationArguments[] arguments, bool isPushingHistory) | Removes an item by hash, or whatever is in a slot, and returns its arguments. |
void StartGroupAction() | Starts a group of changes that go into history as one step. |
async Task StartSession(AddressableSession session) | Starts an asset loading session and loads all worn items. |
void StopSession(AddressableSession session) | Ends the given session if it is the current one. |
protected virtual bool IsPrimary(ICustomizationPart part) | Whether a part counts as primary. True by default. |
protected virtual void OnItemAdded(uint itemDefinition) | Raises ItemAdded. Subclasses can override it. |
protected virtual void OnItemRemoved(uint itemDefinition) | Raises ItemRemoved. Subclasses can override it. |
5 private and internal methods
| Member | What it is |
|---|---|
private void CheckCleanMemory() | Counts down as each handler's cosmetic packer finishes after ApplyStreamItems, then unhooks itself. |
private void DeregisterInternal(uint item) | Removes an item's visual from the visual manager. Logs an error if the item's definition isn't already cached. |
private void Alta.Customization.ICustomizationWrapper.FinishLoad(CancellationTokenSource source) | Clears the current load token if it matches the one passed. |
private void PushStateToHistory() | Snapshots the outfit as a CosmeticPresetData and pushes an undo step from the last snapshot, unless a group action is running. |
private CancellationTokenSource Alta.Customization.ICustomizationWrapper.StartLoad() | Cancels any running load and returns a new cancellation token for the next one. |
Used in
Members of other types that take, return or hold a CustomizationWrapper: