- Ported BS12 code for smart tables. They now include T tables and full tables which continue into 1-tile thick tables. You still can't do everything ever but you can at least make T shaped table pieces.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3612 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-05-18 22:08:49 +00:00
parent 5ac7eaac10
commit b31ce8e533
2 changed files with 180 additions and 120 deletions

View File

@@ -629,133 +629,193 @@
layer = 2.8 layer = 2.8
throwpass = 1 //You can throw objects over this, despite it's density. throwpass = 1 //You can throw objects over this, despite it's density.
New() /obj/structure/table/New()
..() ..()
for(var/obj/structure/table/T in src.loc) for(var/obj/structure/table/T in src.loc)
if(T != src) if(T != src)
del(T) del(T)
update_icon()
for(var/direction in list(1,2,4,8,5,6,9,10))
if(locate(/obj/structure/table,get_step(src,direction)))
var/obj/structure/table/T = locate(/obj/structure/table,get_step(src,direction))
T.update_icon()
Del()
for(var/direction in list(1,2,4,8,5,6,9,10))
if(locate(/obj/structure/table,get_step(src,direction)))
var/obj/structure/table/T = locate(/obj/structure/table,get_step(src,direction))
T.update_icon()
..()
update_icon() update_icon()
spawn(2) //So it properly updates when deleting for(var/direction in list(1,2,4,8,5,6,9,10))
var/dir_sum = 0 if(locate(/obj/structure/table,get_step(src,direction)))
for(var/direction in cardinal) var/obj/structure/table/T = locate(/obj/structure/table,get_step(src,direction))
var/skip_sum = 0 T.update_icon()
for(var/obj/structure/window/W in src.loc)
if(W.dir == direction) //So smooth tables don't go smooth through windows /obj/structure/table/Del()
skip_sum = 1 for(var/direction in list(1,2,4,8,5,6,9,10))
continue if(locate(/obj/structure/table,get_step(src,direction)))
var/inv_direction //inverse direction var/obj/structure/table/T = locate(/obj/structure/table,get_step(src,direction))
switch(direction) T.update_icon()
if(1) ..()
inv_direction = 2
if(2) /obj/structure/table/update_icon()
inv_direction = 1 spawn(2) //So it properly updates when deleting
if(4) var/dir_sum = 0
inv_direction = 8 for(var/direction in list(1,2,4,8,5,6,9,10))
if(8) var/skip_sum = 0
inv_direction = 4 for(var/obj/structure/window/W in src.loc)
for(var/obj/structure/window/W in get_step(src,direction)) if(W.dir == direction) //So smooth tables don't go smooth through windows
if(W.dir == inv_direction) //So smooth tables don't go smooth through windows when the window is on the other table's tile skip_sum = 1
skip_sum = 1 continue
continue var/inv_direction //inverse direction
if(!skip_sum) //means there is a window between the two tiles in this direction switch(direction)
if(locate(/obj/structure/table,get_step(src,direction))) if(1)
inv_direction = 2
if(2)
inv_direction = 1
if(4)
inv_direction = 8
if(8)
inv_direction = 4
if(5)
inv_direction = 10
if(6)
inv_direction = 9
if(9)
inv_direction = 6
if(10)
inv_direction = 5
for(var/obj/structure/window/W in get_step(src,direction))
if(W.dir == inv_direction) //So smooth tables don't go smooth through windows when the window is on the other table's tile
skip_sum = 1
continue
if(!skip_sum) //means there is a window between the two tiles in this direction
if(locate(/obj/structure/table,get_step(src,direction)))
if(direction <5)
dir_sum += direction dir_sum += direction
else
if(direction == 5) //This permits the use of all table directions. (Set up so clockwise around the central table is a higher value, from north)
dir_sum += 16
if(direction == 6)
dir_sum += 32
if(direction == 8) //Aherp and Aderp. Jezes I am stupid. -- SkyMarshal
dir_sum += 8
if(direction == 10)
dir_sum += 64
if(direction == 9)
dir_sum += 128
//dir_sum: var/table_type = 0 //stand_alone table
// 1,2,4,8 = endtable if(dir_sum%16 in cardinal)
// 3,12 = streight 1 tile thick table table_type = 1 //endtable
// 5,6,9,10 = corner, if it finds a table in get_step(src,dir_sum) then it's a full corner table, else it's a 1 tile chick corner table dir_sum %= 16
// 7,11,13,14 = three way intersection = full side table piece (north ,south, east or west) if(dir_sum%16 in list(3,12))
// 15 = four way intersection = center (aka middle) table piece table_type = 2 //1 tile thick, streight table
// if(dir_sum%16 == 3) //3 doesn't exist as a dir
//table_type: dir_sum = 2
// 0 = stand-alone table if(dir_sum%16 == 12) //12 doesn't exist as a dir.
// 1 = end table (1 tile thick, 1 connection) dir_sum = 4
// 2 = 1 tile thick table (1 tile thick, 2 connections) if(dir_sum%16 in list(5,6,9,10))
// 3 = full table (full, 3 connections) if(locate(/obj/structure/table,get_step(src.loc,dir_sum%16)))
// 4 = middle table (full, 4 connections) table_type = 3 //full table (not the 1 tile thick one, but one of the 'tabledir' tables)
else
var/table_type = 0 //stand_alone table table_type = 2 //1 tile thick, corner table (treated the same as streight tables in code later on)
if(dir_sum in cardinal) dir_sum %= 16
table_type = 1 //endtable if(dir_sum%16 in list(13,14,7,11)) //Three-way intersection
if(dir_sum in list(3,12)) table_type = 5 //full table as three-way intersections are not sprited, would require 64 sprites to handle all combinations. TOO BAD -- SkyMarshal
table_type = 2 //1 tile thick, streight table switch(dir_sum%16) //Begin computation of the special type tables. --SkyMarshal
if(dir_sum == 3) //3 doesn't exist as a dir if(7)
dir_sum = 2 if(dir_sum == 23)
if(dir_sum == 12) //12 doesn't exist as a dir. table_type = 6
dir_sum = 4
if(dir_sum in list(5,6,9,10))
if(locate(/obj/structure/table,get_step(src.loc,dir_sum)))
table_type = 3 //full table (not the 1 tile thick one, but one of the 'tabledir' tables)
else
table_type = 2 //1 tile thick, corner table (treated the same as streight tables in code later on)
if(dir_sum in list(13,14,7,11)) //Three-way intersection
table_type = 3 //full table as three-way intersections are not sprited, would require 64 sprites to handle all combinations
switch(dir_sum)
if(7)
dir_sum = 4
if(11)
dir_sum = 8 dir_sum = 8
if(13) else if(dir_sum == 39)
dir_sum = 4
table_type = 6
else if(dir_sum == 55 || dir_sum == 119 || dir_sum == 247 || dir_sum == 183)
dir_sum = 4
table_type = 3
else
dir_sum = 4
if(11)
if(dir_sum == 75)
dir_sum = 5
table_type = 6
else if(dir_sum == 139)
dir_sum = 9
table_type = 6
else if(dir_sum == 203 || dir_sum == 219 || dir_sum == 251 || dir_sum == 235)
dir_sum = 8
table_type = 3
else
dir_sum = 8
if(13)
if(dir_sum == 29)
dir_sum = 10
table_type = 6
else if(dir_sum == 141)
dir_sum = 6
table_type = 6
else if(dir_sum == 189 || dir_sum == 221 || dir_sum == 253 || dir_sum == 157)
dir_sum = 1 dir_sum = 1
if(14) table_type = 3
else
dir_sum = 1
if(14)
if(dir_sum == 46)
dir_sum = 1
table_type = 6
else if(dir_sum == 78)
dir_sum = 2
table_type = 6
else if(dir_sum == 110 || dir_sum == 254 || dir_sum == 238 || dir_sum == 126)
dir_sum = 2
table_type = 3
else
dir_sum = 2 //These translate the dir_sum to the correct dirs from the 'tabledir' icon_state. dir_sum = 2 //These translate the dir_sum to the correct dirs from the 'tabledir' icon_state.
if(dir_sum == 15) if(dir_sum%16 == 15)
table_type = 4 //4-way intersection, the 'middle' table sprites will be used. table_type = 4 //4-way intersection, the 'middle' table sprites will be used.
if(istype(src,/obj/structure/table/reinforced)) if(istype(src,/obj/structure/table/reinforced))
switch(table_type) switch(table_type)
if(0) if(0)
icon_state = "reinf_table" icon_state = "reinf_table"
if(1) if(1)
icon_state = "reinf_1tileendtable" icon_state = "reinf_1tileendtable"
if(2) if(2)
icon_state = "reinf_1tilethick" icon_state = "reinf_1tilethick"
if(3) if(3)
icon_state = "reinf_tabledir" icon_state = "reinf_tabledir"
if(4) if(4)
icon_state = "reinf_middle" icon_state = "reinf_middle"
else if(istype(src,/obj/structure/table/woodentable)) if(5)
switch(table_type) icon_state = "reinf_tabledir2"
if(0) if(6)
icon_state = "wood_table" icon_state = "reinf_tabledir3"
if(1) else if(istype(src,/obj/structure/table/woodentable))
icon_state = "wood_1tileendtable" switch(table_type)
if(2) if(0)
icon_state = "wood_1tilethick" icon_state = "wood_table"
if(3) if(1)
icon_state = "wood_tabledir" icon_state = "wood_1tileendtable"
if(4) if(2)
icon_state = "wood_middle" icon_state = "wood_1tilethick"
else if(3)
switch(table_type) icon_state = "wood_tabledir"
if(0) if(4)
icon_state = "table" icon_state = "wood_middle"
if(1) if(5)
icon_state = "table_1tileendtable" icon_state = "wood_tabledir2"
if(2) if(6)
icon_state = "table_1tilethick" icon_state = "wood_tabledir3"
if(3) else
icon_state = "tabledir" switch(table_type)
if(4) if(0)
icon_state = "table_middle" icon_state = "table"
if (dir_sum in list(1,2,4,8,5,6,9,10)) if(1)
dir = dir_sum icon_state = "table_1tileendtable"
else if(2)
dir = 2 icon_state = "table_1tilethick"
if(3)
icon_state = "tabledir"
if(4)
icon_state = "table_middle"
if(5)
icon_state = "tabledir2"
if(6)
icon_state = "tabledir3"
if (dir_sum in list(1,2,4,8,5,6,9,10))
dir = dir_sum
else
dir = 2
/obj/structure/table/reinforced /obj/structure/table/reinforced
name = "reinforced table" name = "reinforced table"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 92 KiB