Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
fixed functionality, made color filter switch reactive
  • Loading branch information
L4rever committed Sep 17, 2024
1 parent 8ab7030 commit 505e5ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
6 changes: 6 additions & 0 deletions code/modules/clothing/glasses/glasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@

/datum/glasses_mode_type_state

/datum/glasses_mode_type_state/proc/change_state(obj/item/clothing/glasses/glasses, state)
if(state)
on(glasses)
else
off(glasses)

/datum/glasses_mode_type_state/proc/on(obj/item/clothing/glasses/glasses)
return

Expand Down
31 changes: 22 additions & 9 deletions code/modules/item_upgrades/item_upgrade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,28 @@
HUD_TOGGLEABLE_MODE_THERMAL_ADVANCED = new /datum/glasses_mode_type_state/thermal_advanced,
)

/obj/item/clothing/glasses/sunglasses/hud/advanced/atom_init()
. = ..()
RegisterSignal(src, COMSIG_ITEM_DROPPED, PROC_REF(handle_drop))

/obj/item/clothing/glasses/sunglasses/hud/advanced/equipped(mob/user, slot)
. = ..()
if(slot != SLOT_GLASSES)
return
apply_effects(current_mode, TRUE)

/obj/item/clothing/glasses/sunglasses/hud/advanced/proc/handle_drop(source, mob/living/carbon/human/user)
if(!istype(user) || user.glasses)
return
apply_effects(current_mode, FALSE)

/obj/item/clothing/glasses/sunglasses/hud/advanced/proc/apply_effects(mode_type, enable)
if(!ishuman(usr))
if(!ishuman(glasses_user))
return
if(mode_type == null)
return
var/mob/living/carbon/glasses_user = usr
var/datum/glasses_mode_type_state/state = glasses_states[mode_type]
if (enable)
state.on()
else
state.off()
state.change_state(src, enable)
playsound(src, activation_sound, VOL_EFFECTS_MASTER, 10, FALSE)
glasses_user.update_sight()
update_item_actions()
Expand Down Expand Up @@ -119,7 +132,7 @@

/obj/item/hud_upgrade/night/upgrade_hud(obj/item/clothing/glasses/sunglasses/hud/advanced/glasses, mob/living/user)
..()
glasses.item_actions.Add(new /datum/action/item_action/hands_free/switch_hud_modes/night(src))
glasses.item_actions.Add(new /datum/action/item_action/hands_free/switch_hud_modes/night(glasses))

/obj/item/hud_upgrade/thermal
name = "Thermal HUD upgrade"
Expand All @@ -133,7 +146,7 @@

/obj/item/hud_upgrade/thermal/upgrade_hud(obj/item/clothing/glasses/sunglasses/hud/advanced/glasses, mob/living/user)
..()
glasses.item_actions.Add(new /datum/action/item_action/hands_free/switch_hud_modes/thermal(src))
glasses.item_actions.Add(new /datum/action/item_action/hands_free/switch_hud_modes/thermal(glasses))

/obj/item/hud_upgrade/thermal_advanced
name = "Advanced Thermal HUD upgrade"
Expand All @@ -153,7 +166,7 @@
for(var/datum/action/item_action/hands_free/switch_hud_modes/thermal/thermal_action in glasses.item_actions)
thermal_action.Remove(user)
glasses.item_actions.Remove(thermal_action)
glasses.item_actions.Add(new /datum/action/item_action/hands_free/switch_hud_modes/thermal_advanced(src))
glasses.item_actions.Add(new /datum/action/item_action/hands_free/switch_hud_modes/thermal_advanced(glasses))


/datum/action/item_action/hands_free/switch_hud_modes
Expand Down

0 comments on commit 505e5ad

Please sign in to comment.