Skip to content

Cooldown Components

Overview

Cooldowns are implemented as temporal duration decorators (buffs, debuffs, item cooldowns). UMIPBaseCooldownComponent lives on an actor and holds a map of decorator type → container; it can add item cooldowns via UItemPiece_Cooldown and manage generic decorators (add/remove, find by type and string). UMIPClientCooldownRelayHandler lives on the client PlayerController and holds client cooldown relays for UI (add/remove by type, find by string); it broadcasts when a new relay is created.

Key traits:

  • UMIPBaseCooldownComponent – Not saveable by default; decorators are keyed by EMIPDurationDecoratorType and optional string ID. Item cooldowns use ItemPiece_Cooldown on the item entry.
  • UMIPClientCooldownRelayHandler – Client-only; relays replicate or are created from server data so UI can show remaining time.

All paths below are relative to Plugins/ModularInventoryPlus/Source/ModularInventoryPlus/.


Key Classes & Files

Class File
UMIPBaseCooldownComponent Public/Cooldown/MIPBaseCooldownComponent.h
UMIPClientCooldownRelayHandler Public/Cooldown/MIPClientCooldownRelayHandler.h

UMIPBaseCooldownComponent

  • Base: UActorComponent.
  • Item cooldown: AddItemCooldown(InItemEntry) returns UItemPiece_Cooldown*; uses ItemPieceCooldownClass (EditDefaultsOnly).
  • Generic decorators: AddTempDurationDecorator(InType, InObject), RemoveTempDurationDecorator(InTemporalDurationDecorator, bCancelled), GetTempDurationDecorator(InType, InString), GetTemporalDurationDecorators(). StartAllTempDurationObjects(), EmptyDecorators().
  • Static: FindCooldownComponent(Actor).
  • Storage: TemporalDurationDecoratorsByType (TMap); CachedAllTemporalDurationDecorators (Transient, rebuilt on demand).

UMIPClientCooldownRelayHandler

  • Base: UMIPClientPlayerControllerComponent.
  • Attachment: PlayerController (client).
  • API: AddCooldownRelay(InType, InCooldownRelay), RemoveCooldownRelay(InType, InCooldownRelay), RemoveCooldownRelayByCooldownString(InType, InCooldownTagString); FindCooldownRelay(InType, InCooldownTagString).
  • Delegate: ClientCooldownRelayCreated – when a new client cooldown relay is created (for UI binding).
  • Storage: CooldownRelayMap (EMIPDurationDecoratorType → FMIPClientCooldownRelayContainer). On PreClientTravel, likely clears or persists as needed.

Cooldown UObjects and decorators

Cooldowns and temporal durations are implemented as UObject decorators and client relays, not only as component state.

UMIPTemporalDurationDecorator

  • File: Public/Cooldown/Decorator/MIPTemporalDurationDecorator.h
  • Base: UObject; implements ISaveIdentifierInterface, ISaveableLoadableObjectInterface.
  • Role: Represents a single temporal duration (item cooldown, buff/debuff, expiring item). Lives in UMIPBaseCooldownComponent’s containers; can be saved/loaded and replicated.
  • API: InitTempDurationDecorator(...) (object, cooldown string, duration, initial duration, count-offline-time, started timestamp), ResetTempDurationDecorator, CancelTempDurationDecorator, StartTempDurationDecoratorPostLoad, TryStartClientCooldown, RemoveDecorator, OnLogout; GetTempDurationString, GetTemporalDurationObject, GetRemainingTime(bInFromTimer), GetDecoratorType().
  • Replication: Client RPCs ClientStartCooldown, ClientRemoveCooldown so the client can create/update/remove UMIPClientCooldownRelay for UI.
  • SaveGame: CooldownString, DecoratorType, InitialCooldownDuration, RemainingCooldownDuration, StartedTimestamp, bCountOfflineTime.

UMIPItemCooldownDecorator

  • File: Public/Cooldown/Decorator/MIPItemCooldownDecorator.h
  • Base: UMIPTemporalDurationDecorator.
  • Role: Item usage cooldown; TemporalDurationObject is the item entry / usage context. Used by AddItemCooldown on the cooldown component (via ItemPiece_Cooldown).

UMIPBaseExpiringItemDurationDecorator

  • File: Public/Cooldown/Decorator/MIPBaseExpiringItemDurationDecorator.h
  • Base: UMIPTemporalDurationDecorator.
  • Role: Expiring-item temporal duration (e.g. limited-time items, vendor repurchase windows). Uses ItemSaveIdentifier and UniqueStorageTag; InitExpiringItemDurationDecorator, PreLoadExpiringItemDurationDecorator, OnPlayerLoadingCompleted. Subclasses (e.g. vendor expiring) use EMIPDurationDecoratorType::ExpiringCooldown / VendorExpiringCooldown.

UMIPClientCooldownRelay

  • File: Public/Cooldown/MIPClientCooldownRelay.h
  • Base: UObject (client-only, not replicated as a UObject; created from server RPC data).
  • Role: Client-side mirror of a cooldown for UI. Holds ItemIndex, InitialCooldownDuration, RemainingTime, CooldownTagString, ItemPrimaryTag, StartedTimestamp, Percentage; runs a timer and broadcasts FClientOnCooldownUpdated for progress.
  • API: Init(...), Reset(...), RemoveClientCooldownRelay. UI binds to ClientOnCooldownUpdated.

Types (MIPCooldownTypes.h)

  • EMIPDurationDecoratorType: UsageCooldown, ExpiringCooldown, VendorExpiringCooldown, None.
  • FMIPTemporalDurationDecoratorContainer: TArray<UMIPTemporalDurationDecorator*> TemporalDurationDecorators.
  • FMIPClientCooldownRelayContainer: TArray<UMIPClientCooldownRelay*> CooldownRelays.
  • FClientCooldownRelayCreated, FClientOnCooldownUpdated, FClientOneSecondCooldownUpdated – delegates for relay creation and cooldown progress.

Integration

  • Item cooldowns are added when an item is used (e.g. from UMIPPlayerServerIMC / usage handler); the piece is stored on the item entry and the component manages lifetime.
  • Client UI that shows cooldown timers subscribes to ClientCooldownRelayCreated and updates from the relay map.