Accessory Weight Handling (#19309)

* Added a system that lets accessories increase the weight class / size
of the items they attach to. Currently only implemented on modular
armour's arm and leg guards, which will now not fit into bags if those
are attached.
This commit is contained in:
Geeves
2024-06-10 11:54:25 +00:00
committed by GitHub
parent c40a37db22
commit 9d9c2bfb88
5 changed files with 36 additions and 0 deletions
+13
View File
@@ -1,3 +1,5 @@
// Accesssory Slots
#define ACCESSORY_SLOT_GENERIC "decor"
#define ACCESSORY_SLOT_UTILITY "utility"
#define ACCESSORY_SLOT_UTILITY_MINOR "minor utility"
@@ -9,3 +11,14 @@
#define ACCESSORY_SLOT_ARMOR_PIN "armor pin"
#define ACCESSORY_SLOT_ARMOR_POCKETS "armor pockets"
#define ACCESSORY_SLOT_HEAD "head"
// Accessory Weight Classes
/// Doesn't increase size
#define ACCESSORY_WEIGHT_NONE 0
/// Two accessories can be attached but will only increase size by one
#define ACCESSORY_WEIGHT_HALF_UNIT 0.5
// This accessory will increase the size by one
#define ACCESSORY_WEIGHT_ONE_UNIT 1
@@ -115,6 +115,7 @@
update_clothing_icon()
update_accessory_slowdown()
recalculate_body_temperature_change()
recalculate_item_size()
/obj/item/clothing/proc/remove_accessory(mob/user, obj/item/clothing/accessory/A)
if(!(A in accessories))
@@ -125,6 +126,15 @@
update_clothing_icon()
update_accessory_slowdown()
recalculate_body_temperature_change()
recalculate_item_size()
/obj/item/clothing/proc/recalculate_item_size()
w_class = initial(w_class)
for(var/obj/item/clothing/accessory/accessory as anything in accessories)
w_class += accessory.accessory_w_class_adjustment
w_class = Clamp(Ceil(w_class), ITEMSIZE_TINY, ITEMSIZE_IMMENSE)
/obj/item/clothing/proc/removetie_verb()
set name = "Remove Accessory"
@@ -7,7 +7,12 @@
overlay_state = null
slot_flags = SLOT_TIE
w_class = ITEMSIZE_SMALL
var/slot = ACCESSORY_SLOT_GENERIC
/// When attached to another piece of clothing, it'll increase the size by this amount. Accepts the ACCESSORY_WEIGHT_* define, which can be found in code/__DEFINES/accessories.dm. The final result is rounded up
var/accessory_w_class_adjustment = ACCESSORY_WEIGHT_NONE
var/obj/item/clothing/has_suit = null //the suit the tie may be attached to
var/image/inv_overlay = null //overlay used when attached to clothing.
var/overlay_in_inventory = TRUE // Whether the worn_overlay should apply when attached to an item of clothing.
@@ -8,6 +8,7 @@
item_state = "legguards_sec"
contained_sprite = TRUE
slot = ACCESSORY_SLOT_LEG_GUARDS
accessory_w_class_adjustment = ACCESSORY_WEIGHT_HALF_UNIT
w_class = ITEMSIZE_NORMAL
armor = list(
melee = ARMOR_MELEE_KEVLAR,
@@ -148,6 +149,7 @@
item_state = "armguards_sec"
contained_sprite = TRUE
slot = ACCESSORY_SLOT_ARM_GUARDS
accessory_w_class_adjustment = ACCESSORY_WEIGHT_HALF_UNIT
body_parts_covered = HANDS|ARMS
armor = list(
melee = ARMOR_MELEE_KEVLAR,