Files
Bubberstation/code/datums/elements/item_fov.dm
SkyratBot c0706f4a41 [MIRROR] Field of View and Blindness improvements [bounty + upstream push] [MDB IGNORE] (#10060)
* 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>
2021-12-22 14:56:01 +00:00

35 lines
1.2 KiB
Plaintext

/// An element to unconditonally add a FOV trait to the wearer, removing it when an item is unequipped
/datum/element/item_fov
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
id_arg_index = 2
/// Angle of the FoV we will apply when someone wears the clothing this element is attached to.
var/fov_angle
/datum/element/item_fov/Attach(datum/target, fov_angle)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
src.fov_angle = fov_angle
RegisterSignal(target, COMSIG_ITEM_EQUIPPED, .proc/on_equip)
RegisterSignal(target, COMSIG_ITEM_DROPPED, .proc/on_drop)
/datum/element/item_fov/Detach(datum/target)
UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
return ..()
/// On dropping the item, remove the FoV trait.
/datum/element/item_fov/proc/on_drop(datum/source, mob/living/dropper)
SIGNAL_HANDLER
dropper.remove_fov_trait(source.type, fov_angle)
dropper.update_fov()
/// On equipping the item, add the FoV trait.
/datum/element/item_fov/proc/on_equip(obj/item/source, mob/living/equipper, slot)
SIGNAL_HANDLER
if(!(source.slot_flags & slot)) //If EQUIPPED TO HANDS FOR EXAMPLE
return
equipper.add_fov_trait(source.type, fov_angle)
equipper.update_fov()