Skip to content

Commit

Permalink
[MIRROR] Allows action buttons from accessories
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimsonShrike authored and SierraHelper committed Dec 20, 2024
1 parent 9b5dd9c commit 2a3921c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
12 changes: 12 additions & 0 deletions code/_onclick/hud/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define AB_CHECK_LYING 4
#define AB_CHECK_ALIVE 8
#define AB_CHECK_INSIDE 16
#define AB_CHECK_INSIDE_ACCESSORY 32


/datum/action
Expand Down Expand Up @@ -112,6 +113,11 @@
if(check_flags & AB_CHECK_INSIDE)
if(!(target in owner))
return 0
if(check_flags & AB_CHECK_INSIDE_ACCESSORY)
if(!(target in owner))
var/obj/item/clothing/C = target.loc
if (!(istype(C) && (C in owner) && (target in C.accessories)))
return 0
return 1

/datum/action/proc/UpdateName()
Expand Down Expand Up @@ -237,6 +243,12 @@
/datum/action/item_action/CheckRemoval(mob/living/user)
return !(target in user)

/datum/action/item_action/accessory
check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_ALIVE|AB_CHECK_INSIDE_ACCESSORY

/datum/action/item_action/accessory/CheckRemoval(mob/living/user)
return !(target in user || (target.loc && (target.loc in user)))

/datum/action/item_action/hands_free
check_flags = AB_CHECK_ALIVE|AB_CHECK_INSIDE

Expand Down
1 change: 1 addition & 0 deletions code/modules/clothing/under/accessories/_accessory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
item_state = "" //no inhands
slot_flags = SLOT_TIE
w_class = ITEM_SIZE_SMALL
default_action_type = /datum/action/item_action/accessory
var/accessory_flags = ACCESSORY_DEFAULT_FLAGS
var/slot = ACCESSORY_SLOT_DECOR
var/body_location = UPPER_TORSO //most accessories are here
Expand Down
29 changes: 23 additions & 6 deletions code/modules/clothing/under/accessories/goggle_mods.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
)
activation_sound = 'sound/items/goggles_charge.ogg'

/obj/item/clothing/accessory/glassesmod/attack_self(mob/user)
if(toggleable && !user.incapacitated())
if(active)
deactivate(user)
else
activate(user)

/obj/item/clothing/accessory/glassesmod/proc/process_hud(mob/M)
return

Expand All @@ -29,19 +36,23 @@

/obj/item/clothing/accessory/glassesmod/activate()
..()
parent.CutOverlays(inv_overlay)
if (parent)
parent.CutOverlays(inv_overlay)
inv_overlay = null
inv_overlay = get_inv_overlay()
parent.AddOverlays(inv_overlay)
parent.update_vision()
if (parent)
parent.AddOverlays(inv_overlay)
parent.update_vision()

/obj/item/clothing/accessory/glassesmod/deactivate()
..()
parent.CutOverlays(inv_overlay)
if (parent)
parent.CutOverlays(inv_overlay)
inv_overlay = null
inv_overlay = get_inv_overlay()
parent.AddOverlays(inv_overlay)
parent.update_vision()
if (parent)
parent.AddOverlays(inv_overlay)
parent.update_vision()

/obj/item/clothing/accessory/glassesmod/thermal
name = "thermal sights"
Expand All @@ -57,6 +68,7 @@
tint = TINT_MODERATE
activation_sound = 'sound/items/metal_clicking_4.ogg'
deactivation_sound = 'sound/items/metal_clicking_4.ogg'
action_button_name = "Toggle Thermals"


/obj/item/clothing/accessory/glassesmod/nvg
Expand All @@ -73,6 +85,10 @@
tint = TINT_MODERATE
activation_sound = 'sound/items/metal_clicking_4.ogg'
deactivation_sound = 'sound/items/metal_clicking_4.ogg'
action_button_name = "Toggle Night Vision"

/obj/item/clothing/accessory/glassesmod/hud
action_button_name = "Toggle HUD"

/obj/item/clothing/accessory/glassesmod/hud/process_hud(mob/M)
return
Expand Down Expand Up @@ -125,6 +141,7 @@
deactivation_sound = 'sound/items/metal_clicking_13.ogg'
toggle_on_message = "You flip the lenses down to protect your eyes."
toggle_off_message = "You push the lenses up out of your face."
action_button_name = "Toggle welding lenses"

/obj/item/clothing/accessory/glassesmod/vision/welding/activate(mob/usr)
. = ..()
Expand Down
12 changes: 12 additions & 0 deletions code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,18 @@
I.action.name = I.action_button_name
I.action.SetTarget(I)
I.action.Grant(src)

//Clothing accessories
var/obj/item/clothing/C = I
if (istype(C))
for(var/obj/item/clothing/accessory/CA in C.accessories)
if(CA.action_button_name)
if(!CA.action)
CA.action = new CA.default_action_type
CA.action.name = CA.action_button_name
CA.action.SetTarget(CA)
CA.action.Grant(src)

return

/mob/living/update_action_buttons()
Expand Down

0 comments on commit 2a3921c

Please sign in to comment.