mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
## About The Pull Request This PR tackles our piss-poor item action handling. Currently in order to make an item only have actions when its equipped to a certain slot you need to override a proc, which I've changed by introducing an action_slots variable. I've also cleaned up a ton of action code, and most importantly moved a lot of Trigger effects on items to do_effect, which allows actions to not call ui_action_click or attack_self on an item without bypassing IsAvailible and comsigs that parent Trigger has. This resolves issues like jump boots being usable from your hands, HUDs being toggleable out of your pockets, etc. Also moved a few actions from relying on attack_self to individual handling on their side. This also stops welding masks/hardhats from showing their action while you hold them, this part of the change is just something I thought didn't make much sense - you can use their action by using them in-hand, and flickering on your action bar can be annoying when reshuffling your backpack. Closes #89653 ## Why It's Good For The Game Makes action handling significantly less ass, allows us to avoid code like this ```js /obj/item/clothing/mask/gas/sechailer/ui_action_click(mob/user, action) if(istype(action, /datum/action/item_action/halt)) halt() else adjust_visor(user) ```
38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
//Presets for item actions
|
|
/datum/action/item_action
|
|
name = "Item Action"
|
|
check_flags = AB_CHECK_INCAPACITATED|AB_CHECK_HANDS_BLOCKED|AB_CHECK_CONSCIOUS
|
|
button_icon_state = null
|
|
|
|
/datum/action/item_action/New(Target)
|
|
. = ..()
|
|
|
|
// If our button state is null, use the target's icon instead
|
|
if(target && isnull(button_icon_state))
|
|
AddComponent(/datum/component/action_item_overlay, target)
|
|
|
|
/datum/action/item_action/vv_edit_var(var_name, var_value)
|
|
. = ..()
|
|
if(!. || !target)
|
|
return
|
|
|
|
if(var_name == NAMEOF(src, button_icon_state))
|
|
// If someone vv's our icon either add or remove the component
|
|
if(isnull(var_name))
|
|
AddComponent(/datum/component/action_item_overlay, target)
|
|
else
|
|
qdel(GetComponent(/datum/component/action_item_overlay))
|
|
|
|
/datum/action/item_action/Trigger(trigger_flags)
|
|
. = ..()
|
|
if(!.)
|
|
return FALSE
|
|
return do_effect(trigger_flags)
|
|
|
|
/datum/action/item_action/proc/do_effect(trigger_flags)
|
|
if(!target)
|
|
return FALSE
|
|
var/obj/item/item_target = target
|
|
item_target.ui_action_click(owner, src)
|
|
return TRUE
|