Merge pull request #32462 from ninjanomnom/atom-decal

Cleans up turf decal and lets it be applied to atoms
This commit is contained in:
Jordan Brown
2017-11-07 13:57:28 -05:00
committed by GitHub
7 changed files with 57 additions and 54 deletions
+1
View File
@@ -39,6 +39,7 @@
#define COMSIG_ATOM_SING_PULL "atom_sing_pull" //from base of atom/singularity_pull(): (S, current_size)
#define COMSIG_ATOM_SET_LIGHT "atom_set_light" //from base of atom/set_light(): (l_range, l_power, l_color)
#define COMSIG_ATOM_ROTATE "atom_rotate" //from base of atom/shuttleRotate(): (rotation, params)
#define COMSIG_ATOM_DIR_CHANGE "atom_dir_change" //from base of atom/setDir(): (old_dir, new_dir)
#define COMSIG_CLICK "atom_click" //from base of atom/Click(): (location, control, params)
#define COMSIG_CLICK_SHIFT "shift_click" //from base of atom/ShiftClick(): (/mob)
-1
View File
@@ -146,7 +146,6 @@
return NORTH
//returns the north-zero clockwise angle in degrees, given a direction
/proc/dir2angle(D)
switch(D)
if(NORTH)
+53
View 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_DECAL_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)
-51
View File
@@ -1,51 +0,0 @@
/datum/component/turf_decal
var/dir
var/icon
var/icon_state
var/layer
var/group
/datum/component/turf_decal/Initialize(_dir, _icon, _icon_state, _layer=TURF_DECAL_LAYER, _group=TURF_DECAL_PAINT)
if(!isturf(parent) || !_icon || !_icon_state)
WARNING("A turf decal was applied incorrectly to [parent]: icon:[_icon ? _icon : "none"] icon_state:[_icon_state ? _icon_state : "none"]")
return COMPONENT_INCOMPATIBLE
dir = _dir
icon = _icon
icon_state = _icon_state
layer = _layer
group = _group
apply_decal()
RegisterSignal(COMSIG_ATOM_ROTATE, .proc/rotate_react)
RegisterSignal(COMSIG_COMPONENT_CLEAN_ACT, .proc/clean_react)
/datum/component/turf_decal/Destroy()
remove_decal()
return ..()
/datum/component/turf_decal/OnTransfer(turf/newT)
remove_decal()
remove_decal(newT)
apply_decal(newT)
/datum/component/turf_decal/proc/get_decal()
return image(icon, null, icon_state, layer, dir)
/datum/component/turf_decal/proc/apply_decal(turf/overT)
var/turf/master = overT || parent
master.add_decal(get_decal(), group)
/datum/component/turf_decal/proc/remove_decal(turf/overT)
var/turf/master = overT || parent
master.remove_decal(group)
/datum/component/turf_decal/proc/rotate_react(rotation, params)
if(params & ROTATE_DIR)
dir = angle2dir(rotation+dir2angle(dir))
remove_decal()
apply_decal()
/datum/component/turf_decal/proc/clean_react(strength)
if(strength >= CLEAN_IMPRESSIVE)
qdel(src)
+1
View File
@@ -523,6 +523,7 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
//Hook for running code when a dir change occurs
/atom/proc/setDir(newdir)
SendSignal(COMSIG_ATOM_DIR_CHANGE, dir, newdir)
dir = newdir
/atom/proc/mech_melee_attack(obj/mecha/M)
+1 -1
View File
@@ -30,7 +30,7 @@
var/turf/T = loc
if(!istype(T)) //you know this will happen somehow
CRASH("Turf decal initialized in an object/nullspace")
T.AddComponent(/datum/component/turf_decal, dir, icon, icon_state)
T.AddComponent(/datum/component/decal, icon, icon_state, dir)
/obj/effect/turf_decal/stripes/line
icon_state = "warningline"
+1 -1
View File
@@ -277,6 +277,7 @@
#include "code\datums\antagonists\wizard.dm"
#include "code\datums\components\_component.dm"
#include "code\datums\components\archaeology.dm"
#include "code\datums\components\decal.dm"
#include "code\datums\components\infective.dm"
#include "code\datums\components\material_container.dm"
#include "code\datums\components\paintable.dm"
@@ -287,7 +288,6 @@
#include "code\datums\components\spooky.dm"
#include "code\datums\components\squeek.dm"
#include "code\datums\components\thermite.dm"
#include "code\datums\components\turf_decal.dm"
#include "code\datums\diseases\_disease.dm"
#include "code\datums\diseases\_MobProcs.dm"
#include "code\datums\diseases\anxiety.dm"