Skip to content

Commit

Permalink
Clean up preview items
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Feb 1, 2024
1 parent 368c7c5 commit 00aca0b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/OutfitSystem.reds
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class OutfitSystem extends ScriptableSystem {

private func OnRestored(saveVersion: Int32, gameVersion: Int32) {
this.InitializePlayerAndSystems();
this.CleanUpPreviewItems();
this.MigrateState();

if this.m_state.IsActive() {
Expand Down Expand Up @@ -142,6 +143,18 @@ public class OutfitSystem extends ScriptableSystem {
this.m_state.ClearParts();
}

private func CleanUpPreviewItems() {
let playerItems: array<wref<gameItemData>>;
if this.m_transactionSystem.GetItemList(this.m_player, playerItems) {
for itemData in playerItems {
let itemID = itemData.GetID();
if ItemID.HasFlag(itemID, gameEItemIDFlag.Preview) {
this.m_transactionSystem.RemoveItem(this.m_player, itemID, 1);
}
}
}
}

private func MigrateState() {
for part in this.m_state.GetParts() {
let itemID = part.GetItemID();
Expand Down

0 comments on commit 00aca0b

Please sign in to comment.