Fixes turf_decal layering
This commit is contained in:
committed by
CitadelStationBot
parent
36234e94d4
commit
88e7e8d2cb
53
code/datums/components/decal.dm
Normal file
53
code/datums/components/decal.dm
Normal file
@@ -0,0 +1,53 @@
|
||||
/datum/component/decal
|
||||
dupe_mode = COMPONENT_DUPE_ALLOWED
|
||||
|
||||
var/cleanable
|
||||
var/mutable_appearance/pic
|
||||
|
||||
/datum/component/decal/Initialize(_icon, _icon_state, _dir, _cleanable=CLEAN_GOD, _color, _layer=TURF_LAYER)
|
||||
if(!isatom(parent) || !_icon || !_icon_state)
|
||||
. = COMPONENT_INCOMPATIBLE
|
||||
CRASH("A turf decal was applied incorrectly to [parent.type]: icon:[_icon ? _icon : "none"] icon_state:[_icon_state ? _icon_state : "none"]")
|
||||
|
||||
// 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
|
||||
|
||||
cleanable = _cleanable
|
||||
|
||||
apply()
|
||||
|
||||
if(_dir) // If no dir is assigned at start then it follows the atom's dir
|
||||
RegisterSignal(COMSIG_ATOM_DIR_CHANGE, .proc/rotate_react)
|
||||
if(_cleanable)
|
||||
RegisterSignal(COMSIG_COMPONENT_CLEAN_ACT, .proc/clean_react)
|
||||
|
||||
/datum/component/decal/Destroy()
|
||||
remove()
|
||||
return ..()
|
||||
|
||||
/datum/component/decal/OnTransfer(atom/thing)
|
||||
remove()
|
||||
remove(thing)
|
||||
apply(thing)
|
||||
|
||||
/datum/component/decal/proc/apply(atom/thing)
|
||||
var/atom/master = thing || parent
|
||||
master.add_overlay(pic, TRUE)
|
||||
|
||||
/datum/component/decal/proc/remove(atom/thing)
|
||||
var/atom/master = thing || parent
|
||||
master.cut_overlay(pic, TRUE)
|
||||
|
||||
/datum/component/decal/proc/rotate_react(old_dir, new_dir)
|
||||
if(old_dir == new_dir)
|
||||
return
|
||||
remove()
|
||||
var/rotation = SimplifyDegrees(dir2angle(new_dir)-dir2angle(old_dir))
|
||||
pic.dir = turn(pic.dir, rotation)
|
||||
apply()
|
||||
|
||||
/datum/component/decal/proc/clean_react(strength)
|
||||
if(strength >= cleanable)
|
||||
qdel(src)
|
||||
Reference in New Issue
Block a user