Files
GS13NG/code/datums/components/decal.dm
deathride58 f1739cb482 Upstream fix mirror spree (#7362)
* tgstation/tgstation#39025 - Fixes nukeop eshield not being buyable

* tgstation/tgstation#39011 - [s] Adds missing logging to the staff of storms

* tgstation/tgstation#38980 - Corrects a stat error in the Nuke Ops uplink

* tgstation/tgstation#38988 - Fixes blob victory.

* tgstation/tgstation#38990 - Allow players to un-ignore previously ignored popups for ghostroles, and ignore notifications with no ignore button

needs tgui recompile

* tgstation/tgstation#38994 - Fix timer bug

* TGUI recompile

* tgstation/tgstation#39035 - Fixes navigation computers.

* tgstation/tgstation#39043 - Fixes minor genetics scanner runtime

* tgstation/tgstation#39044 - Fixes burgers icons

* tgstation/tgstation#39055 - Fixes porta_turret and decal shuttle rotations

* tgstation/tgstation#39063 - Stops extinguishers from cooling turfs to absolute zero

* tgstation/tgstation#38967 - Fixes smuggler's satchel init typo

* tgstation/tgstation#38931 - Fixes pulse rifles exploding structures in nullspace and that sort of thing
2018-07-20 03:40:39 -07:00

75 lines
2.2 KiB
Plaintext

/datum/component/decal
dupe_mode = COMPONENT_DUPE_ALLOWED
var/cleanable
var/description
var/mutable_appearance/pic
var/first_dir // This only stores the dir arg from init
/datum/component/decal/Initialize(_icon, _icon_state, _dir, _cleanable=CLEAN_GOD, _color, _layer=TURF_LAYER, _description)
if(!isatom(parent) || !generate_appearance(_icon, _icon_state, _dir, _layer, _color))
return COMPONENT_INCOMPATIBLE
first_dir = _dir
description = _description
cleanable = _cleanable
apply()
/datum/component/decal/RegisterWithParent()
if(first_dir)
RegisterSignal(parent, COMSIG_ATOM_DIR_CHANGE, .proc/rotate_react)
if(cleanable)
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, .proc/clean_react)
if(description)
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/examine)
/datum/component/decal/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ATOM_DIR_CHANGE, COMSIG_COMPONENT_CLEAN_ACT, COMSIG_PARENT_EXAMINE))
/datum/component/decal/Destroy()
remove()
return ..()
/datum/component/decal/PreTransfer()
remove()
/datum/component/decal/PostTransfer()
remove()
apply()
/datum/component/decal/proc/generate_appearance(_icon, _icon_state, _dir, _layer, _color)
if(!_icon || !_icon_state)
return FALSE
// It has to be made from an image or dir breaks because of a byond bug
var/temp_image = image(_icon, null, _icon_state, _layer, _dir)
pic = new(temp_image)
pic.color = _color
return TRUE
/datum/component/decal/proc/apply(atom/thing)
var/atom/master = thing || parent
master.add_overlay(pic, TRUE)
if(isitem(master))
addtimer(CALLBACK(master, /obj/item/.proc/update_slot_icon), 0, TIMER_UNIQUE)
/datum/component/decal/proc/remove(atom/thing)
var/atom/master = thing || parent
master.cut_overlay(pic, TRUE)
if(isitem(master))
addtimer(CALLBACK(master, /obj/item/.proc/update_slot_icon), 0, TIMER_UNIQUE)
/datum/component/decal/proc/rotate_react(old_dir, new_dir)
if(old_dir == new_dir)
return
remove()
pic.dir = turn(pic.dir, dir2angle(old_dir) - dir2angle(new_dir))
apply()
/datum/component/decal/proc/clean_react(strength)
if(strength >= cleanable)
qdel(src)
/datum/component/decal/proc/examine(mob/user)
to_chat(user, description)