From 28ae273ef2c84ae9b7728ef6bd444044d7ec9e52 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 4 Feb 2025 21:14:36 +0000 Subject: [PATCH] More centralised FiR status handing across server --- Libraries/Core/Helpers/ItemHelper.cs | 28 ++++++++++++++++--- Libraries/Core/Helpers/RewardHelper.cs | 2 +- .../Core/Services/CircleOfCultistService.cs | 6 ++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Libraries/Core/Helpers/ItemHelper.cs b/Libraries/Core/Helpers/ItemHelper.cs index 21226147..53d08fa9 100644 --- a/Libraries/Core/Helpers/ItemHelper.cs +++ b/Libraries/Core/Helpers/ItemHelper.cs @@ -1128,17 +1128,37 @@ public class ItemHelper( /// Modifies passed in items /// /// The list of items to mark as FiR - public void SetFoundInRaid(List items) + /// Skip adding FiR status to currency items + public void SetFoundInRaid(List items, bool excludeCurrency = true) { foreach (var item in items) { - if (item.Upd == null) - item.Upd = new(); - + if (excludeCurrency && IsOfBaseclass(item.Template, BaseClasses.MONEY)) + { + continue; + } + item.Upd ??= new(); item.Upd.SpawnedInSession = true; } } + /// + /// Mark the passed in list of items as found in raid. + /// Modifies passed in items + /// + /// The list of items to mark as FiR + /// Skip adding FiR status to currency items + public void SetFoundInRaid(Item item, bool excludeCurrency = true) + { + if (excludeCurrency && IsOfBaseclass(item.Template, BaseClasses.MONEY)) + { + return; + } + + item.Upd ??= new(); + item.Upd.SpawnedInSession = true; + } + /// /// WARNING, SLOW. Recursively loop down through an items hierarchy to see if any of the ids match the supplied list, return true if any do /// diff --git a/Libraries/Core/Helpers/RewardHelper.cs b/Libraries/Core/Helpers/RewardHelper.cs index 51fa07d4..ae23ceb2 100644 --- a/Libraries/Core/Helpers/RewardHelper.cs +++ b/Libraries/Core/Helpers/RewardHelper.cs @@ -288,7 +288,7 @@ namespace Core.Helpers _itemHelper.AddUpdObjectToItem(rewardItem); // Reward items are granted Found in Raid status - rewardItem.Upd.SpawnedInSession = true; + _itemHelper.SetFoundInRaid(rewardItem); // Is root item, fix stacks if (rewardItem.Id == reward.Target) diff --git a/Libraries/Core/Services/CircleOfCultistService.cs b/Libraries/Core/Services/CircleOfCultistService.cs index 2a19fae0..32841437 100644 --- a/Libraries/Core/Services/CircleOfCultistService.cs +++ b/Libraries/Core/Services/CircleOfCultistService.cs @@ -366,11 +366,12 @@ public class CircleOfCultistService( Upd = new Upd { StackObjectsCount = stackSize, - SpawnedInSession = true, }, }, ]; + _itemHelper.SetFoundInRaid(rewardItem); + // Edge case - item is ammo container and needs cartridges added if (_itemHelper.IsOfBaseclass(randomItemTplFromPool, BaseClasses.AMMO_BOX)) { @@ -454,11 +455,12 @@ public class CircleOfCultistService( Upd = new Upd { StackObjectsCount = stackSize, - SpawnedInSession = true, }, }, ]; + _itemHelper.SetFoundInRaid(rewardItem); + // Edge case - item is ammo container and needs cartridges added if (_itemHelper.IsOfBaseclass(rewardTpl, BaseClasses.AMMO_BOX)) {