mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Makes loadout datums more flexible.
Loadout item definitions can now also take a list of tweaks, which will adjust the item after spawn. Currently includes color and icon state changes.
This commit is contained in:
28
code/modules/client/preference_setup/loadout/gear_tweaks.dm
Normal file
28
code/modules/client/preference_setup/loadout/gear_tweaks.dm
Normal file
@@ -0,0 +1,28 @@
|
||||
/datum/gear_tweak/proc/apply_tweak(var/obj/item/I)
|
||||
return
|
||||
|
||||
/*
|
||||
* Color adjustment
|
||||
*/
|
||||
/datum/gear_tweak/color
|
||||
var/item_color
|
||||
|
||||
/datum/gear_tweak/color/New(var/item_color)
|
||||
src.item_color = item_color
|
||||
..()
|
||||
|
||||
/datum/gear_tweak/color/apply_tweak(var/obj/item/I)
|
||||
I.color = item_color
|
||||
|
||||
/*
|
||||
* Icon state adjustment
|
||||
*/
|
||||
/datum/gear_tweak/icon_state
|
||||
var/icon_state
|
||||
|
||||
/datum/gear_tweak/icon_state/New(var/icon_state)
|
||||
src.icon_state = icon_state
|
||||
..()
|
||||
|
||||
/datum/gear_tweak/icon_state/apply_tweak(var/obj/item/I)
|
||||
I.icon_state = icon_state
|
||||
@@ -157,5 +157,10 @@ var/list/gear_datums = list()
|
||||
var/list/allowed_roles //Roles that can spawn with this item.
|
||||
var/whitelisted //Term to check the whitelist for..
|
||||
var/sort_category = "General"
|
||||
var/list/gear_tweaks = list() //List of datums which will alter the item after it has been spawned.
|
||||
|
||||
|
||||
/datum/gear/proc/spawn_item(var/location)
|
||||
var/item = new path(location)
|
||||
for(var/datum/gear_tweak/gt in gear_tweaks)
|
||||
gt.apply_tweak(item)
|
||||
return item
|
||||
|
||||
Reference in New Issue
Block a user