From 7bd79ddba1b7f54064ffa7b3f47657bebd55c5a1 Mon Sep 17 00:00:00 2001 From: Waterpig <49160555+Majkl-J@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:22:48 +0200 Subject: [PATCH] [NO-GBP] Last loadout fixes to make it on par with the old system (#28684) Last loadout fixes to make it on par with the old system --- code/modules/loadout/loadout_helpers.dm | 2 +- .../modules/loadout/category_rebalance.dm | 25 +++++++++++++++++++ tgstation.dme | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 modular_skyrat/master_files/code/modules/loadout/category_rebalance.dm diff --git a/code/modules/loadout/loadout_helpers.dm b/code/modules/loadout/loadout_helpers.dm index c2f83fb3ca7..ee270693ced 100644 --- a/code/modules/loadout/loadout_helpers.dm +++ b/code/modules/loadout/loadout_helpers.dm @@ -55,7 +55,7 @@ to_chat(preference_source.parent, span_warning("You were unable to get a loadout item ([initial(item.item_path.name)]) due to CKEY restrictions!")) continue - if(loadout_placement_preference == LOADOUT_OVERRIDE_CASE) + if(loadout_placement_preference == LOADOUT_OVERRIDE_CASE && !visuals_only) if(!travel_suitcase) travel_suitcase = new(loc) new item.item_path(travel_suitcase) diff --git a/modular_skyrat/master_files/code/modules/loadout/category_rebalance.dm b/modular_skyrat/master_files/code/modules/loadout/category_rebalance.dm new file mode 100644 index 00000000000..334f9a6ee66 --- /dev/null +++ b/modular_skyrat/master_files/code/modules/loadout/category_rebalance.dm @@ -0,0 +1,25 @@ +/datum/loadout_category/pocket + max_allowed = 3 + +/datum/loadout_category/toys + VAR_PRIVATE/max_allowed = 3 + +/datum/loadout_category/toys/New() + . = ..() + category_info = "([max_allowed] allowed)" + +/datum/loadout_category/toys/handle_duplicate_entires( + datum/preference_middleware/loadout/manager, + datum/loadout_item/conflicting_item, + datum/loadout_item/added_item, + list/datum/loadout_item/all_loadout_items, +) + var/list/datum/loadout_item/toys/other_toys_items = list() + for(var/datum/loadout_item/toys/other_toys_item in all_loadout_items) + other_toys_items += other_toys_item + + if(length(other_toys_items) >= max_allowed) + // We only need to deselect something if we're above the limit + // (And if we are we prioritize the first item found, FIFO) + manager.deselect_item(other_toys_items[1]) + return TRUE diff --git a/tgstation.dme b/tgstation.dme index 71fddd79922..9fee05772d9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6675,6 +6675,7 @@ #include "modular_skyrat\master_files\code\modules\jobs\job_types\warden.dm" #include "modular_skyrat\master_files\code\modules\language\_language.dm" #include "modular_skyrat\master_files\code\modules\language\language_holder.dm" +#include "modular_skyrat\master_files\code\modules\loadout\category_rebalance.dm" #include "modular_skyrat\master_files\code\modules\loadout\categories\accessories.dm" #include "modular_skyrat\master_files\code\modules\loadout\categories\belts.dm" #include "modular_skyrat\master_files\code\modules\loadout\categories\donator_personal.dm"