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
EMIPDurationDecoratorTypeand optional string ID. Item cooldowns useItemPiece_Cooldownon 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)returnsUItemPiece_Cooldown*; usesItemPieceCooldownClass(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,ClientRemoveCooldownso 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;
TemporalDurationObjectis the item entry / usage context. Used byAddItemCooldownon the cooldown component (viaItemPiece_Cooldown).
UMIPBaseExpiringItemDurationDecorator¶
- File:
Public/Cooldown/Decorator/MIPBaseExpiringItemDurationDecorator.h - Base: UMIPTemporalDurationDecorator.
- Role: Expiring-item temporal duration (e.g. limited-time items, vendor repurchase windows). Uses
ItemSaveIdentifierandUniqueStorageTag;InitExpiringItemDurationDecorator,PreLoadExpiringItemDurationDecorator,OnPlayerLoadingCompleted. Subclasses (e.g. vendor expiring) useEMIPDurationDecoratorType::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 toClientOnCooldownUpdated.
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
ClientCooldownRelayCreatedand updates from the relay map.