TG: - Ported over (Well basically completely recoded) the smooth window code from

Bay 12.
Revision: r3613
Author: 	 baloh.matevz
This commit is contained in:
Erthilo
2012-05-19 01:49:12 +01:00
parent d160e28474
commit 6e3dd19cc7
+37 -42
View File
@@ -79,6 +79,7 @@
src.health = max(0, src.health - tforce)
if (src.health <= 7 && !reinf)
src.anchored = 0
update_nearby_icons()
step(src, get_dir(AM, src))
if (src.health <= 0)
new /obj/item/weapon/shard( src.loc )
@@ -201,22 +202,12 @@
usr << ( state==1? "You have unfastened the window from the frame." : "You have fastened the window to the frame." )
else if(reinf && state == 0)
anchored = !anchored
for(var/obj/structure/window/w in range(src,1))
if (w.anchored)
w.relativewindow()
src.relativewindow()
update_nearby_icons()
playsound(src.loc, 'Screwdriver.ogg', 75, 1)
user << (src.anchored ? "You have fastened the frame to the floor." : "You have unfastened the frame from the floor.")
else if(!reinf)
src.anchored = !( src.anchored )
for(var/obj/structure/window/w in range(src,1))
if (w.anchored)
w.relativewindow()
src.relativewindow()
update_nearby_icons()
playsound(src.loc, 'Screwdriver.ogg', 75, 1)
user << (src.anchored ? "You have fastened the window to the floor." : "You have unfastened the window.")
else if(istype(W, /obj/item/weapon/crowbar) && reinf && state <=1)
@@ -232,12 +223,7 @@
playsound(src.loc, 'Glasshit.ogg', 75, 1)
if (src.health <= 7)
src.anchored = 0
for(var/obj/structure/window/w in range(src,1))
if (w.anchored)
w.relativewindow()
src.relativewindow()
update_nearby_icons()
step(src, get_dir(user, src))
if (src.health <= 0)
if (src.dir == SOUTHWEST)
@@ -328,10 +314,7 @@
icon_state = "window"
update_nearby_tiles(need_rebuild=1)
relativewindow()
for(var/obj/structure/window/w in range(src,1))
if (w.anchored)
w.relativewindow()
update_nearby_icons()
return
@@ -339,10 +322,11 @@
density = 0
update_nearby_tiles()
for(var/obj/structure/window/w in range(src,1))
w.relativewindow()
playsound(src, "shatter", 70, 1)
update_nearby_icons()
..()
/obj/structure/window/Move()
@@ -355,6 +339,7 @@
return
//This proc has to do with airgroups and atmos, it has nothing to do with smoothwindows, that's update_nearby_tiles().
/obj/structure/window/proc/update_nearby_tiles(need_rebuild)
if(!air_master) return 0
@@ -378,30 +363,40 @@
return 1
//checks if this window is full-tile one
/obj/structure/window/proc/is_fulltile()
return (src.dir == SOUTHWEST || src.dir == SOUTHEAST || src.dir == NORTHWEST || src.dir == NORTHEAST)
if(dir in list(5,6,9,10))
return 1
return 0
//This proc is used to update the icons of nearby windows. It should not be confused with update_nearby_tiles(), which is an atmos proc!
/obj/structure/window/proc/update_nearby_icons()
src.update_icon()
for(var/direction in cardinal)
for(var/obj/structure/window/W in get_step(src,direction) )
W.update_icon()
//merges adjacent full-tile windows into one (blatant ripoff from game/smoothwall.dm)
/obj/structure/window/proc/relativewindow()
/obj/structure/window/update_icon()
//A little cludge here, since I don't know how it will work with slim windows. Most likely VERY wrong.
//this way it will only update full-tile ones
if (!is_fulltile())
return
var/junction = 0 //will be used to determine from which side the window is connected to other windows
if (src.anchored)
for(var/obj/structure/window/W in orange(src,1))
if (W.anchored && W.density && W.is_fulltile()) //Only counts anchored, not-destroyed fill-tile windows.
if (abs(src.x-W.x)-abs(src.y-W.y) ) //doesn't count windows, placed diagonally to src
junction |= get_dir(src,W)
if (istype(src,/obj/structure/window/basic))
src.icon_state = "window[junction]"
else if (istype(src,/obj/structure/window/reinforced))
if (istype(src,/obj/structure/window/reinforced/tinted))
//This spawn is here so windows get properly updated when one gets deleted.
spawn(2)
if(!src) return
if (!is_fulltile())
return
var/junction = 0 //will be used to determine from which side the window is connected to other windows
if (src.anchored)
for(var/obj/structure/window/W in orange(src,1))
if (W.anchored && W.density && W.is_fulltile()) //Only counts anchored, not-destroyed fill-tile windows.
if (abs(src.x-W.x)-abs(src.y-W.y) ) //doesn't count windows, placed diagonally to src
junction |= get_dir(src,W)
if (opacity)
src.icon_state = "twindow[junction]"
else
src.icon_state = "rwindow[junction]"
return
if (reinf)
src.icon_state = "rwindow[junction]"
else
src.icon_state = "window[junction]"
return