Files
Bubberstation/code/datums/elements/frozen.dm
nevimer 424ed3d160 Revert "Revert "Merge upstream""
This reverts commit e6bb4098c4.

# Conflicts:
#	_maps/RandomRuins/LavaRuins/skyrat/lavaland_surface_syndicate_base1_skyrat.dmm
#	_maps/RandomRuins/SpaceRuins/bus.dmm
#	_maps/RandomZLevels/blackmesa.dmm
#	_maps/map_files/generic/CentCom_skyrat_z2.dmm
#	_maps/shuttles/skyrat/goldeneye_cruiser.dmm
#	_maps/templates/lazy_templates/wizard_den.dmm
#	code/__DEFINES/callbacks.dm
#	code/datums/components/transforming.dm
#	code/datums/elements/bane.dm
#	code/datums/votes/map_vote.dm
#	code/game/objects/items/AI_modules/hacked.dm
#	code/game/objects/items/food/egg.dm
#	code/game/objects/items/stacks/sheets/glass.dm
#	code/modules/antagonists/fugitive/hunters/hunter.dm
#	code/modules/antagonists/traitor/objectives/final_objective/final_objective.dm
#	code/modules/antagonists/traitor/objectives/kidnapping.dm
#	code/modules/art/statues.dm
#	code/modules/events/ghost_role/changeling_event.dm
#	code/modules/events/spacevine.dm
#	code/modules/mining/machine_redemption.dm
#	code/modules/mob/living/simple_animal/friendly/farm_animals.dm
#	code/modules/mob_spawn/mob_spawn.dm
#	code/modules/projectiles/guns/ballistic/pistol.dm
#	code/modules/projectiles/guns/ballistic/rifle.dm
#	code/modules/uplink/uplink_items.dm
#	code/modules/vending/autodrobe.dm
#	html/changelogs/archive/2023-03.yml
#	icons/mob/clothing/feet.dmi
#	icons/mob/clothing/under/costume.dmi
#	icons/mob/inhands/clothing/shoes_lefthand.dmi
#	icons/mob/inhands/clothing/shoes_righthand.dmi
#	icons/mob/inhands/clothing/suits_lefthand.dmi
#	icons/mob/inhands/clothing/suits_righthand.dmi
#	icons/mob/species/human/human_face.dmi
#	icons/obj/clothing/shoes.dmi
#	icons/obj/clothing/under/costume.dmi
#	modular_skyrat/master_files/code/datums/components/fullauto.dm
#	modular_skyrat/master_files/code/modules/clothing/under/jobs/security.dm
#	modular_skyrat/master_files/code/modules/projectiles/guns/gun.dm
#	modular_skyrat/master_files/icons/mob/clothing/under/civilian.dmi
#	modular_skyrat/master_files/icons/mob/clothing/under/civilian_digi.dmi
#	modular_skyrat/modules/aesthetics/guns/code/guns.dm
#	modular_skyrat/modules/aesthetics/guns/icons/guns.dmi
#	modular_skyrat/modules/blueshield/code/blueshield.dm
#	modular_skyrat/modules/customization/modules/clothing/under/misc.dm
#	modular_skyrat/modules/ghostcafe/code/ghost_role_spawners.dm
#	modular_skyrat/modules/gunsgalore/icons/guns/gunsgalore_guns40x32.dmi
#	modular_skyrat/modules/manufacturer_examine/code/gun_company_additions.dm
#	modular_skyrat/modules/manufacturer_examine/code/manufacturer_component.dm
#	modular_skyrat/modules/mapping/code/mob_spawns.dm
#	modular_skyrat/modules/modular_weapons/code/rifle.dm
#	modular_skyrat/modules/novaya_ert/code/automatic.dm
#	modular_skyrat/modules/sec_haul/code/guns/guns.dm
#	modular_skyrat/modules/tribal_extended/code/weapons/bow.dm
#	tgstation.dme
#	tgui/packages/tgui/interfaces/OreRedemptionMachine.js
#	tgui/packages/tgui/interfaces/VotePanel.tsx
2023-05-20 22:06:42 -04:00

80 lines
2.9 KiB
Plaintext

GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0,0,0)))
///simple element to handle frozen obj's
/datum/element/frozen
/datum/element/frozen/Attach(datum/target)
. = ..()
if(!isobj(target))
return ELEMENT_INCOMPATIBLE
var/obj/target_obj = target
if(target_obj.resistance_flags & FREEZE_PROOF)
return ELEMENT_INCOMPATIBLE
if(HAS_TRAIT(target_obj, TRAIT_FROZEN))
return ELEMENT_INCOMPATIBLE
ADD_TRAIT(target_obj, TRAIT_FROZEN, ELEMENT_TRAIT(type))
target_obj.name = "frozen [target_obj.name]"
target_obj.add_atom_colour(GLOB.freon_color_matrix, TEMPORARY_COLOUR_PRIORITY)
target_obj.alpha -= 25
if (isinternalorgan(target))
var/obj/item/organ/internal/organ = target
organ.organ_flags |= ORGAN_FROZEN
else if (isbodypart(target))
for(var/obj/item/organ/internal/organ in target_obj.contents)
organ.organ_flags |= ORGAN_FROZEN
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
RegisterSignal(target, COMSIG_MOVABLE_THROW_LANDED, PROC_REF(shatter_on_throw))
RegisterSignal(target, COMSIG_MOVABLE_IMPACT, PROC_REF(shatter_on_throw))
RegisterSignal(target, COMSIG_OBJ_UNFREEZE, PROC_REF(on_unfreeze))
/datum/element/frozen/Detach(datum/source, ...)
var/obj/obj_source = source
REMOVE_TRAIT(obj_source, TRAIT_FROZEN, ELEMENT_TRAIT(type))
UnregisterSignal(obj_source, list(COMSIG_MOVABLE_MOVED, COMSIG_MOVABLE_THROW_LANDED, COMSIG_MOVABLE_IMPACT, COMSIG_OBJ_UNFREEZE))
obj_source.name = replacetext(obj_source.name, "frozen ", "")
obj_source.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY, GLOB.freon_color_matrix)
obj_source.alpha += 25
if (isinternalorgan(source))
var/obj/item/organ/internal/organ = source
organ.organ_flags &= ~ORGAN_FROZEN
else if (isbodypart(source))
for(var/obj/item/organ/internal/organ in obj_source.contents)
organ.organ_flags &= ~ORGAN_FROZEN
return ..()
///signal handler for COMSIG_OBJ_UNFREEZE that forces us to detach from the target
/datum/element/frozen/proc/on_unfreeze(datum/source)
SIGNAL_HANDLER
Detach(source)
///signal handler for COMSIG_MOVABLE_POST_THROW that shatters our target after impacting after a throw
/datum/element/frozen/proc/shatter_on_throw(datum/target)
SIGNAL_HANDLER
var/obj/obj_target = target
obj_target.visible_message(span_danger("[obj_target] shatters into a million pieces!"))
obj_target.flags_1 |= NODECONSTRUCT_1 // disable item spawning
obj_target.deconstruct(FALSE) // call pre-deletion specialized code -- internals release gas etc
/// signal handler for COMSIG_MOVABLE_MOVED that unfreezes our target if it moves onto an open turf thats hotter than
/// our melting temperature.
/datum/element/frozen/proc/on_moved(datum/target)
SIGNAL_HANDLER
var/atom/movable/movable_target = target
if(movable_target.throwing)
return
if(!isopenturf(movable_target.loc))
return
var/turf/open/turf_loc = movable_target.loc
if(turf_loc.air?.temperature >= T0C)//unfreezes target
Detach(target)