Files
Bubberstation/code/modules/unit_tests/ablative_hud.dm
Bloop df074b9966 [MANUAL FIXED MIRROR] 22129 and 22154 (#22379)
* Makes hoods into a component (#75977)

## About The Pull Request

Refactors the behaviour of "one clothing item deploying another clothing
item" from `/obj/item/clothing/suit/hooded` and makes it into a
component.
This allows you to make hooded items which are not part of that
typepath. It also means you could make (for instance) a hat which can
deploy a pair of sunglasses into the eye slot or a jumpsuit with
deployable clown shoes or something.

I need to pass in an assload of callbacks because we have a bunch of
special hoodies that want to do things when you raise and lower the
hood, but for a normal item you would not need these.

## Why It's Good For The Game

Frees people from the tyrrany of typepaths, mostly.
Plausibly you could use it to do something fun we don't currently do.

## Changelog

Not player facing, hopefully. As long as I did this all right.

* Makes hoods into a component

* [no gbp] Fixes item action buttons

* Update items.dm

* Fix mirror 22129

* Some last minute updates -- comment and small optimization

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
2023-07-11 19:57:19 -04:00

28 lines
1.8 KiB
Plaintext

/// Check that player gains and loses sec hud when toggling the ablative hood
/datum/unit_test/ablative_hood_hud
/datum/unit_test/ablative_hood_hud/Run()
var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent)
var/obj/item/clothing/suit/hooded/ablative/coat = allocate(/obj/item/clothing/suit/hooded/ablative)
var/datum/component/toggle_attached_clothing/hood = coat.GetComponent(/datum/component/toggle_attached_clothing)
person.equip_to_slot(coat, ITEM_SLOT_OCLOTHING)
TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person already had a sechud before trying to equip the ablative hood.")
hood.toggle_deployable()
TEST_ASSERT(HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person toggled the ablative hood but didn't gain a sechud.")
hood.toggle_deployable()
TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person lowered their ablative hood but still has a sechud.")
// Check that player doesn't gain sec hud if the hood is toggled when already wearing a helmet
/datum/unit_test/ablative_hood_hud_with_helmet
/datum/unit_test/ablative_hood_hud_with_helmet/Run()
var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent)
var/obj/item/clothing/suit/hooded/ablative/coat = allocate(/obj/item/clothing/suit/hooded/ablative)
var/datum/component/toggle_attached_clothing/hood = coat.GetComponent(/datum/component/toggle_attached_clothing)
var/obj/item/clothing/head/helmet/hat = allocate(/obj/item/clothing/head/helmet)
person.equip_to_slot(coat, ITEM_SLOT_OCLOTHING)
person.equip_to_slot(hat, ITEM_SLOT_HEAD)
TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person already had a sechud before trying to equip the ablative hood.")
hood.toggle_deployable()
TEST_ASSERT(!HAS_TRAIT(person, TRAIT_SECURITY_HUD), "Person has gained a sechud from toggling the ablative hood despite already wearing a helmet.")