- Ported over (Well basically completely recoded) the smooth window code from Bay 12.

Screenshot:
http://www.kamletos.si/bay12%20windows.png

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3613 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-05-18 22:53:10 +00:00
parent b31ce8e533
commit b4e0c3d850
+48 -1
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 )
@@ -194,10 +195,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
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 )
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)
@@ -213,6 +216,7 @@
playsound(src.loc, 'Glasshit.ogg', 75, 1)
if (src.health <= 7)
src.anchored = 0
update_nearby_icons()
step(src, get_dir(user, src))
if (src.health <= 0)
if (src.dir == SOUTHWEST)
@@ -303,6 +307,7 @@
icon_state = "window"
update_nearby_tiles(need_rebuild=1)
update_nearby_icons()
return
@@ -312,6 +317,9 @@
update_nearby_tiles()
playsound(src, "shatter", 70, 1)
update_nearby_icons()
..()
/obj/structure/window/Move()
@@ -324,6 +332,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
@@ -345,4 +354,42 @@
if(istype(source)) air_master.tiles_to_update += source
if(istype(target)) air_master.tiles_to_update += target
return 1
return 1
//checks if this window is full-tile one
/obj/structure/window/proc/is_fulltile()
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/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
//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
if (reinf)
src.icon_state = "rwindow[junction]"
else
src.icon_state = "window[junction]"
return