mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
* Field of View and Blindness improvements [bounty + upstream push] * Update death.dm * almost done * Update fov_handler.dm * Face mouse when in combat mode, fix * Fixes the category for the fov admin verb. #63401 * Fixes objects with bad planes and FoV bugs #63412 * pain * there we go * face pref Co-authored-by: Azarak <azarak10@gmail.com>
61 lines
2.3 KiB
Plaintext
61 lines
2.3 KiB
Plaintext
/// An element to add a FOV trait to the wearer, removing it when an item is unequipped, but only as long as the visor is up.
|
|
/datum/component/clothing_fov_visor
|
|
/// What's the FOV angle of the trait we're applying to the wearer
|
|
var/fov_angle
|
|
/// Keeping track of the visor of our clothing.
|
|
var/visor_up = FALSE
|
|
/// Because of clothing code not being too good, we need keep track whether we are worn.
|
|
var/is_worn = FALSE
|
|
|
|
/datum/component/clothing_fov_visor/Initialize(fov_angle)
|
|
. = ..()
|
|
if(!isclothing(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/obj/item/clothing/clothing_parent = parent
|
|
src.fov_angle = fov_angle
|
|
src.visor_up = clothing_parent.up //Initial values could vary, so we need to get it.
|
|
|
|
/datum/component/clothing_fov_visor/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/on_equip)
|
|
RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/on_drop)
|
|
RegisterSignal(parent, COMSIG_CLOTHING_VISOR_TOGGLE, .proc/on_visor_toggle)
|
|
|
|
/datum/component/clothing_fov_visor/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED, COMSIG_CLOTHING_VISOR_TOGGLE))
|
|
return ..()
|
|
|
|
/// On dropping the item, remove the FoV trait if visor was down.
|
|
/datum/component/clothing_fov_visor/proc/on_drop(datum/source, mob/living/dropper)
|
|
SIGNAL_HANDLER
|
|
is_worn = FALSE
|
|
if(visor_up)
|
|
return
|
|
dropper.remove_fov_trait(source.type, fov_angle)
|
|
dropper.update_fov()
|
|
|
|
/// On equipping the item, add the FoV trait if visor isn't up.
|
|
/datum/component/clothing_fov_visor/proc/on_equip(obj/item/source, mob/living/equipper, slot)
|
|
SIGNAL_HANDLER
|
|
if(!(source.slot_flags & slot)) //If EQUIPPED TO HANDS FOR EXAMPLE
|
|
return
|
|
is_worn = TRUE
|
|
if(visor_up)
|
|
return
|
|
equipper.add_fov_trait(source.type, fov_angle)
|
|
equipper.update_fov()
|
|
|
|
/// On toggling the visor, we may want to add or remove FOV trait from the wearer.
|
|
/datum/component/clothing_fov_visor/proc/on_visor_toggle(datum/source, visor_state)
|
|
SIGNAL_HANDLER
|
|
visor_up = visor_state
|
|
if(!is_worn)
|
|
return
|
|
var/obj/item/clothing/clothing_parent = parent
|
|
var/mob/living/wearer = clothing_parent.loc //This has to be the case due to equip/dropped keeping track.
|
|
if(visor_up)
|
|
wearer.remove_fov_trait(source.type, fov_angle)
|
|
wearer.update_fov()
|
|
else
|
|
wearer.add_fov_trait(source.type, fov_angle)
|
|
wearer.update_fov()
|