mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
New tables, code section. Changelog entry soon.
This commit is contained in:
116
code/modules/tables/flipping.dm
Normal file
116
code/modules/tables/flipping.dm
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
/obj/structure/table/proc/straight_table_check(var/direction)
|
||||
var/obj/structure/table/T
|
||||
for(var/angle in list(-90,90))
|
||||
T = locate() in get_step(src.loc,turn(direction,angle))
|
||||
if(T && T.flipped == 0 && T.material == material)
|
||||
return 0
|
||||
T = locate() in get_step(src.loc,direction)
|
||||
if (!T || T.flipped == 1 || T.material != material)
|
||||
return 1
|
||||
if(T.health > 100)
|
||||
return 0
|
||||
return T.straight_table_check(direction)
|
||||
|
||||
/obj/structure/table/verb/do_flip()
|
||||
set name = "Flip table"
|
||||
set desc = "Flips a non-reinforced table"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if (!can_touch(usr) || ismouse(usr))
|
||||
return
|
||||
|
||||
if(flipped < 0 || !flip(get_cardinal_dir(usr,src)))
|
||||
usr << "<span class='notice'>It won't budge.</span>"
|
||||
return
|
||||
|
||||
usr.visible_message("<span class='warning'>[usr] flips \the [src]!</span>")
|
||||
|
||||
if(climbable)
|
||||
structure_shaken()
|
||||
|
||||
return
|
||||
|
||||
/obj/structure/table/proc/unflipping_check(var/direction)
|
||||
|
||||
for(var/mob/M in oview(src,0))
|
||||
return 0
|
||||
|
||||
var/obj/occupied = turf_is_crowded()
|
||||
if(occupied)
|
||||
usr << "There's \a [occupied] in the way."
|
||||
return 0
|
||||
|
||||
var/list/L = list()
|
||||
if(direction)
|
||||
L.Add(direction)
|
||||
else
|
||||
L.Add(turn(src.dir,-90))
|
||||
L.Add(turn(src.dir,90))
|
||||
for(var/new_dir in L)
|
||||
var/obj/structure/table/T = locate() in get_step(src.loc,new_dir)
|
||||
if(T && T.material == material)
|
||||
if(T.flipped == 1 && T.dir == src.dir && !T.unflipping_check(new_dir))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/structure/table/proc/do_put()
|
||||
set name = "Put table back"
|
||||
set desc = "Puts flipped table back"
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if (!can_touch(usr))
|
||||
return
|
||||
|
||||
if (!unflipping_check())
|
||||
usr << "<span class='notice'>It won't budge.</span>"
|
||||
return
|
||||
unflip()
|
||||
|
||||
/obj/structure/table/proc/flip(var/direction)
|
||||
if( !straight_table_check(turn(direction,90)) || !straight_table_check(turn(direction,-90)) )
|
||||
return 0
|
||||
|
||||
verbs -=/obj/structure/table/verb/do_flip
|
||||
verbs +=/obj/structure/table/proc/do_put
|
||||
|
||||
var/list/targets = list(get_step(src,dir),get_step(src,turn(dir, 45)),get_step(src,turn(dir, -45)))
|
||||
for (var/atom/movable/A in get_turf(src))
|
||||
if (!A.anchored)
|
||||
spawn(0)
|
||||
A.throw_at(pick(targets),1,1)
|
||||
|
||||
set_dir(direction)
|
||||
if(dir != NORTH)
|
||||
layer = 5
|
||||
climbable = 0 //flipping tables allows them to be used as makeshift barriers
|
||||
flipped = 1
|
||||
flags |= ON_BORDER
|
||||
for(var/D in list(turn(direction, 90), turn(direction, -90)))
|
||||
var/obj/structure/table/T = locate() in get_step(src,D)
|
||||
if(T && T.flipped == 0 && T.material == material && material)
|
||||
T.flip(direction)
|
||||
update_connections(1)
|
||||
update_icon()
|
||||
|
||||
return 1
|
||||
|
||||
/obj/structure/table/proc/unflip()
|
||||
verbs -=/obj/structure/table/proc/do_put
|
||||
verbs +=/obj/structure/table/verb/do_flip
|
||||
|
||||
layer = initial(layer)
|
||||
flipped = 0
|
||||
climbable = initial(climbable)
|
||||
flags &= ~ON_BORDER
|
||||
for(var/D in list(turn(dir, 90), turn(dir, -90)))
|
||||
var/obj/structure/table/T = locate() in get_step(src.loc,D)
|
||||
if(T && T.flipped == 1 && T.dir == src.dir && T.material == material && material)
|
||||
T.unflip()
|
||||
|
||||
update_connections(1)
|
||||
update_icon()
|
||||
|
||||
return 1
|
||||
122
code/modules/tables/interactions.dm
Normal file
122
code/modules/tables/interactions.dm
Normal file
@@ -0,0 +1,122 @@
|
||||
|
||||
/obj/structure/table/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
|
||||
if(air_group || (height==0)) return 1
|
||||
if(istype(mover,/obj/item/projectile))
|
||||
return (check_cover(mover,target))
|
||||
if(istype(mover) && mover.checkpass(PASSTABLE))
|
||||
return 1
|
||||
if(locate(/obj/structure/table) in get_turf(mover))
|
||||
return 1
|
||||
if (flipped == 1)
|
||||
if (get_dir(loc, target) == dir)
|
||||
return !density
|
||||
else
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//checks if projectile 'P' from turf 'from' can hit whatever is behind the table. Returns 1 if it can, 0 if bullet stops.
|
||||
/obj/structure/table/proc/check_cover(obj/item/projectile/P, turf/from)
|
||||
var/turf/cover
|
||||
if(flipped==1)
|
||||
cover = get_turf(src)
|
||||
else if(flipped==0)
|
||||
cover = get_step(loc, get_dir(from, loc))
|
||||
if(!cover)
|
||||
return 1
|
||||
if (get_dist(P.starting, loc) <= 1) //Tables won't help you if people are THIS close
|
||||
return 1
|
||||
if (get_turf(P.original) == cover)
|
||||
var/chance = 20
|
||||
if (ismob(P.original))
|
||||
var/mob/M = P.original
|
||||
if (M.lying)
|
||||
chance += 20 //Lying down lets you catch less bullets
|
||||
if(flipped==1)
|
||||
if(get_dir(loc, from) == dir) //Flipped tables catch mroe bullets
|
||||
chance += 20
|
||||
else
|
||||
return 1 //But only from one side
|
||||
if(prob(chance))
|
||||
health -= P.damage/2
|
||||
if (health > 0)
|
||||
visible_message("<span class='warning'>[P] hits \the [src]!</span>")
|
||||
return 0
|
||||
else
|
||||
visible_message("<span class='warning'>[src] breaks down!</span>")
|
||||
break_to_parts()
|
||||
return 1
|
||||
return 1
|
||||
|
||||
/obj/structure/table/CheckExit(atom/movable/O as mob|obj, target as turf)
|
||||
if(istype(O) && O.checkpass(PASSTABLE))
|
||||
return 1
|
||||
if (flipped==1)
|
||||
if (get_dir(loc, target) == dir)
|
||||
return !density
|
||||
else
|
||||
return 1
|
||||
return 1
|
||||
|
||||
|
||||
/obj/structure/table/MouseDrop_T(obj/O as obj, mob/user as mob)
|
||||
|
||||
if ((!( istype(O, /obj/item/weapon) ) || user.get_active_hand() != O))
|
||||
return ..()
|
||||
if(isrobot(user))
|
||||
return
|
||||
user.drop_item()
|
||||
if (O.loc != src.loc)
|
||||
step(O, get_dir(O, src))
|
||||
return
|
||||
|
||||
|
||||
/obj/structure/table/attackby(obj/item/W as obj, mob/user as mob)
|
||||
if (!W) return
|
||||
|
||||
// Handle harm intent grabbing/tabling.
|
||||
if(istype(W, /obj/item/weapon/grab) && get_dist(src,user)<2)
|
||||
var/obj/item/weapon/grab/G = W
|
||||
if (istype(G.affecting, /mob/living))
|
||||
var/mob/living/M = G.affecting
|
||||
if (G.state < 2)
|
||||
if(user.a_intent == I_HURT)
|
||||
if (prob(15)) M.Weaken(5)
|
||||
M.apply_damage(8,def_zone = "head")
|
||||
visible_message("<span class='danger'>[G.assailant] slams [G.affecting]'s face against \the [src]!</span>")
|
||||
playsound(src.loc, 'sound/weapons/tablehit1.ogg', 50, 1)
|
||||
else
|
||||
user << "<span class='danger'>You need a better grip to do that!</span>"
|
||||
return
|
||||
else
|
||||
G.affecting.loc = src.loc
|
||||
G.affecting.Weaken(5)
|
||||
visible_message("<span class='danger'>[G.assailant] puts [G.affecting] on \the [src].</span>")
|
||||
qdel(W)
|
||||
return
|
||||
|
||||
// Handle dismantling or placing things on the table from here on.
|
||||
if(isrobot(user))
|
||||
return
|
||||
|
||||
if(W.loc != user) // This should stop mounted modules ending up outside the module.
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/weapon/melee/energy/blade))
|
||||
var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread()
|
||||
spark_system.set_up(5, 0, src.loc)
|
||||
spark_system.start()
|
||||
playsound(src.loc, 'sound/weapons/blade1.ogg', 50, 1)
|
||||
playsound(src.loc, "sparks", 50, 1)
|
||||
user.visible_message("<span class='danger'>\The [src] was sliced apart by [user]!</span>")
|
||||
break_to_parts()
|
||||
return
|
||||
|
||||
if(!material)
|
||||
user << "<span class='warning'>There's nothing to put \the [W] on! Try adding plating to \the [src] first.</span>"
|
||||
return
|
||||
|
||||
user.drop_item(src.loc)
|
||||
return
|
||||
|
||||
/obj/structure/table/attack_tk() // no telehulk sorry
|
||||
return
|
||||
110
code/modules/tables/presets.dm
Normal file
110
code/modules/tables/presets.dm
Normal file
@@ -0,0 +1,110 @@
|
||||
var/global/material/material_holographic_steel = null
|
||||
var/global/material/material_holographic_wood = null
|
||||
|
||||
/obj/structure/table
|
||||
|
||||
standard
|
||||
icon_state = "plain_preview"
|
||||
color = "#666666"
|
||||
New()
|
||||
material = name_to_material[DEFAULT_WALL_MATERIAL]
|
||||
..()
|
||||
|
||||
reinforced
|
||||
icon_state = "reinf_preview"
|
||||
color = "#666666"
|
||||
New()
|
||||
material = name_to_material[DEFAULT_WALL_MATERIAL]
|
||||
reinforced = name_to_material[DEFAULT_WALL_MATERIAL]
|
||||
..()
|
||||
|
||||
woodentable
|
||||
icon_state = "plain_preview"
|
||||
color = "#824B28"
|
||||
New()
|
||||
material = name_to_material["wood"]
|
||||
..()
|
||||
|
||||
gamblingtable
|
||||
icon_state = "gamble_preview"
|
||||
New()
|
||||
material = name_to_material["wood"]
|
||||
carpeted = 1
|
||||
..()
|
||||
|
||||
glass
|
||||
icon_state = "plain_preview"
|
||||
color = "#00E1FF"
|
||||
alpha = 77 // 0.3 * 255
|
||||
New()
|
||||
material = name_to_material["glass"]
|
||||
..()
|
||||
|
||||
holotable
|
||||
icon_state = "holo_preview"
|
||||
color = "#666666"
|
||||
New()
|
||||
if(!material_holographic_steel)
|
||||
material_holographic_steel = new /material/steel
|
||||
material_holographic_steel.stack_type = null // Tables with null-stacktype materials cannot be deconstructed
|
||||
material = material_holographic_steel
|
||||
..()
|
||||
|
||||
woodentable/holotable
|
||||
icon_state = "holo_preview"
|
||||
New()
|
||||
if(!material_holographic_wood)
|
||||
material_holographic_wood = new /material/wood
|
||||
material_holographic_wood.stack_type = null // Tables with null-stacktype materials cannot be deconstructed
|
||||
material = material_holographic_wood
|
||||
..()
|
||||
|
||||
/*
|
||||
|
||||
/obj/structure/table/holotable
|
||||
name = "table"
|
||||
desc = "A square piece of metal standing on four metal legs. It can not move."
|
||||
icon = 'icons/obj/structures.dmi'
|
||||
icon_state = "table"
|
||||
density = 1
|
||||
anchored = 1.0
|
||||
layer = 2.8
|
||||
throwpass = 1 //You can throw objects over this, despite it's density.
|
||||
|
||||
/obj/structure/table/holotable/attack_hand(mob/user as mob)
|
||||
return // HOLOTABLE DOES NOT GIVE A FUCK
|
||||
|
||||
|
||||
/obj/structure/table/holotable/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/wrench))
|
||||
user << "It's a holotable! There are no bolts!"
|
||||
return
|
||||
|
||||
if(isrobot(user))
|
||||
return
|
||||
|
||||
..()
|
||||
|
||||
/obj/structure/table/woodentable/holotable
|
||||
name = "table"
|
||||
desc = "A square piece of wood standing on four wooden legs. It can not move."
|
||||
icon = 'icons/obj/structures.dmi'
|
||||
icon_state = "wood_table"
|
||||
|
||||
|
||||
/obj/structure/table/rack/holorack
|
||||
name = "rack"
|
||||
desc = "Different from the Middle Ages version."
|
||||
icon = 'icons/obj/objects.dmi'
|
||||
icon_state = "rack"
|
||||
|
||||
/obj/structure/table/rack/holorack/attack_hand(mob/user as mob)
|
||||
return
|
||||
|
||||
/obj/structure/table/rack/holorack/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/wrench))
|
||||
user << "It's a holorack! You can't unwrench it!"
|
||||
return
|
||||
|
||||
|
||||
*/
|
||||
26
code/modules/tables/rack.dm
Normal file
26
code/modules/tables/rack.dm
Normal file
@@ -0,0 +1,26 @@
|
||||
/obj/structure/table/rack
|
||||
name = "rack"
|
||||
desc = "Different from the Middle Ages version."
|
||||
icon = 'icons/obj/objects.dmi'
|
||||
icon_state = "rack"
|
||||
can_plate = 0
|
||||
can_reinforce = 0
|
||||
flipped = -1
|
||||
|
||||
/obj/structure/table/rack/New()
|
||||
..()
|
||||
verbs -= /obj/structure/table/verb/do_flip
|
||||
verbs -= /obj/structure/table/proc/do_put
|
||||
|
||||
/obj/structure/table/rack/update_connections()
|
||||
return
|
||||
|
||||
/obj/structure/table/rack/update_desc()
|
||||
return
|
||||
|
||||
/obj/structure/table/rack/update_icon()
|
||||
return
|
||||
|
||||
/obj/structure/table/rack/holorack/dismantle(obj/item/weapon/wrench/W, mob/user)
|
||||
user << "<span class='warning'>You cannot dismantle \the [src].</span>"
|
||||
return
|
||||
337
code/modules/tables/tables.dm
Normal file
337
code/modules/tables/tables.dm
Normal file
@@ -0,0 +1,337 @@
|
||||
|
||||
|
||||
/obj/structure/table
|
||||
name = "table frame"
|
||||
icon = 'icons/obj/tables.dmi'
|
||||
icon_state = "frame"
|
||||
desc = "It's a table, for putting things on. Or standing on, if you really want to."
|
||||
density = 1
|
||||
anchored = 1
|
||||
climbable = 1
|
||||
var/flipped = 0
|
||||
var/maxhealth = 10
|
||||
var/health = 10
|
||||
|
||||
// For racks.
|
||||
var/can_reinforce = 1
|
||||
var/can_plate = 1
|
||||
|
||||
var/material/material = null
|
||||
var/material/reinforced = null
|
||||
|
||||
// Gambling tables. I'd prefer reinforced with carpet/felt/cloth/whatever, but AFAIK it's either harder or impossible to get /obj/item/stack/sheet of those.
|
||||
// Convert if/when you can easily get stacks of these.
|
||||
var/carpeted = 0
|
||||
|
||||
var/list/connections = list("nw0", "ne0", "sw0", "se0")
|
||||
|
||||
/obj/structure/table/proc/update_material()
|
||||
var/old_maxhealth = maxhealth
|
||||
if(!material)
|
||||
maxhealth = 10
|
||||
else
|
||||
maxhealth = material.integrity / 2
|
||||
|
||||
if(reinforced)
|
||||
maxhealth += reinforced.integrity / 2
|
||||
|
||||
health += maxhealth - old_maxhealth
|
||||
|
||||
/obj/structure/table/New()
|
||||
..()
|
||||
// One table per turf.
|
||||
for(var/obj/structure/table/T in loc)
|
||||
if(T != src)
|
||||
// There's another table here that's not us, break to metal.
|
||||
// break_to_parts calls qdel(src)
|
||||
break_to_parts(full_return = 1)
|
||||
return
|
||||
|
||||
/obj/structure/table/initialize()
|
||||
..()
|
||||
// reset color/alpha, since they're set for nice map previews
|
||||
color = "#ffffff"
|
||||
alpha = 255
|
||||
update_connections(1)
|
||||
update_icon()
|
||||
update_desc()
|
||||
|
||||
/obj/structure/table/Destroy()
|
||||
material = null
|
||||
update_connections(1) // Update tables around us to ignore us (material=null forces no connections)
|
||||
for(var/obj/structure/table/T in oview(src, 1))
|
||||
T.update_icon()
|
||||
..()
|
||||
|
||||
/obj/structure/table/attackby(obj/item/weapon/W, mob/user)
|
||||
|
||||
if(reinforced && istype(W, /obj/item/weapon/screwdriver))
|
||||
remove_reinforced(W, user)
|
||||
if(!reinforced)
|
||||
update_desc()
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
if(!reinforced && material && istype(W, /obj/item/weapon/wrench))
|
||||
remove_material(W, user)
|
||||
if(!material)
|
||||
update_connections(1)
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
if(!reinforced && !material && istype(W, /obj/item/weapon/wrench))
|
||||
dismantle(W, user)
|
||||
return 1
|
||||
|
||||
if(!material && can_plate && istype(W, /obj/item/stack/sheet))
|
||||
material = common_material_add(W, user, "plat")
|
||||
if(material)
|
||||
update_connections(1)
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/structure/table/MouseDrop_T(obj/item/stack/sheet/what)
|
||||
if(can_reinforce && isliving(usr) && (!usr.stat) && istype(what) && usr.get_active_hand() == what && Adjacent(usr))
|
||||
reinforce_table(what, usr)
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/structure/table/proc/reinforce_table(obj/item/stack/sheet/S, mob/user)
|
||||
if(reinforced)
|
||||
user << "<span class='warning'>\The [src] is already reinforced!</span>"
|
||||
return
|
||||
|
||||
if(!can_reinforce)
|
||||
user << "<span class='warning'>\The [src] cannot be reinforced!</span>"
|
||||
|
||||
reinforced = common_material_add(S, user, "reinforc")
|
||||
if(reinforced)
|
||||
update_desc()
|
||||
update_icon()
|
||||
|
||||
/obj/structure/table/proc/update_desc()
|
||||
if(material)
|
||||
name = "[material.display_name] table"
|
||||
else
|
||||
name = "table frame"
|
||||
|
||||
if(reinforced)
|
||||
name = "reinforced [name]"
|
||||
desc = "[initial(desc)] This one seems to be reinforced with [reinforced.display_name]."
|
||||
else
|
||||
desc = initial(desc)
|
||||
|
||||
// Returns the material to set the table to.
|
||||
/obj/structure/table/proc/common_material_add(obj/item/stack/sheet/S, mob/user, verb) // Verb is actually verb without 'e' or 'ing', which is added. Works for 'plate'/'plating' and 'reinforce'/'reinforcing'.
|
||||
var/material/M = name_to_material[S.sheettype]
|
||||
if(!istype(M))
|
||||
user << "<span class='warning'>You cannot [verb]e \the [src] with \the [S].</span>"
|
||||
return null
|
||||
user << "<span class='notice'>You begin [verb]ing \the [src] with [M.display_name].</span>"
|
||||
if(!do_after(user, 20) || !S.use(1))
|
||||
return null
|
||||
user.visible_message("<span class='notice'>\The [user] [verb]es \the [src] with [M.display_name].</span>", "<span class='notice'>You finish [verb]ing \the [src].</span>")
|
||||
return M
|
||||
|
||||
// Returns the material to set the table to.
|
||||
/obj/structure/table/proc/common_material_remove(mob/user, material/M, delay, what, type_holding)
|
||||
if(!M.stack_type)
|
||||
user << "<span class='warning'>You are unable to remove the [what] from this table!</span>"
|
||||
return M
|
||||
|
||||
user.visible_message("<span class='notice'>\The [user] begins removing the [type_holding] holding \the [src]'s [M.display_name] [what] in place.</span>",
|
||||
"<span class='notice'>You begin removing the [type_holding] holding \the [src]'s [M.display_name] [what] in place.</span>")
|
||||
if(!do_after(user, 40))
|
||||
return M
|
||||
user.visible_message("<span class='notice'>\The [user] removes the [M.display_name] [what] from \the [src].</span>",
|
||||
"<span class='notice'>You remove the [M.display_name] [what] from \the [src].</span>")
|
||||
new M.stack_type(src.loc)
|
||||
return null
|
||||
|
||||
/obj/structure/table/proc/remove_reinforced(obj/item/weapon/screwdriver/S, mob/user)
|
||||
reinforced = common_material_remove(user, reinforced, 40, "reinforcements", "screws")
|
||||
|
||||
/obj/structure/table/proc/remove_material(obj/item/weapon/wrench/W, mob/user)
|
||||
material = common_material_remove(user, material, 20, "plating", "bolts")
|
||||
|
||||
/obj/structure/table/proc/dismantle(obj/item/weapon/wrench/W, mob/user)
|
||||
user.visible_message("<span class='notice'>\The [user] begins dismantling \the [src].</span>",
|
||||
"<span class='notice'>You begin dismantling \the [src].</span>")
|
||||
if(!do_after(user, 20))
|
||||
return
|
||||
user.visible_message("<span class='notice'>\The [user] dismantles \the [src].</span>",
|
||||
"<span class='notice'>You dismantle \the [src].</span>")
|
||||
new /obj/item/stack/sheet/metal(src.loc)
|
||||
|
||||
/obj/structure/table/proc/break_to_parts(full_return = 0)
|
||||
if(reinforced && reinforced.stack_type && (full_return || prob(25)))
|
||||
new reinforced.stack_type(src.loc)
|
||||
if(material && material.stack_type && (full_return || prob(50)))
|
||||
new material.stack_type(src.loc)
|
||||
if(full_return || prob(50))
|
||||
new /obj/item/stack/sheet/metal(src.loc)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
/obj/structure/table/update_icon()
|
||||
if(flipped != 1)
|
||||
icon_state = "blank"
|
||||
overlays.Cut()
|
||||
|
||||
// Base frame shape. Mostly done for glass/diamond tables, where this is visible.
|
||||
for(var/n in connections)
|
||||
overlays += n
|
||||
|
||||
// Standard table image
|
||||
if(material)
|
||||
for(var/n in connections)
|
||||
var/image/I = image(icon, "[material.icon_base]_[n]")
|
||||
I.color = material.icon_colour
|
||||
I.alpha = 255 * material.opacity
|
||||
overlays += I
|
||||
|
||||
// Reinforcements
|
||||
if(reinforced)
|
||||
for(var/n in connections)
|
||||
var/image/I = image(icon, "[reinforced.icon_reinf]_[n]")
|
||||
I.color = reinforced.icon_colour
|
||||
I.alpha = 255 * reinforced.opacity
|
||||
overlays += I
|
||||
|
||||
if(carpeted)
|
||||
for(var/n in connections)
|
||||
overlays += "carpet_[n]"
|
||||
else
|
||||
overlays.Cut()
|
||||
var/type = 0
|
||||
var/tabledirs = 0
|
||||
for(var/direction in list(turn(dir,90), turn(dir,-90)) )
|
||||
var/obj/structure/table/T = locate(/obj/structure/table ,get_step(src,direction))
|
||||
if (T && T.flipped == 1 && T.dir == src.dir && T.material == material)
|
||||
type++
|
||||
tabledirs |= direction
|
||||
|
||||
type = "[type]"
|
||||
if (type=="1")
|
||||
if (tabledirs & turn(dir,90))
|
||||
type += "-"
|
||||
if (tabledirs & turn(dir,-90))
|
||||
type += "+"
|
||||
|
||||
icon_state = "flip[type]"
|
||||
if(material)
|
||||
var/image/I = image(icon, "[material.icon_base]_flip[type]")
|
||||
I.color = material.icon_colour
|
||||
I.alpha = 255 * material.opacity
|
||||
overlays += I
|
||||
name = "[material.display_name] table"
|
||||
else
|
||||
name = "table frame"
|
||||
|
||||
if(reinforced)
|
||||
var/image/I = image(icon, "[reinforced.icon_reinf]_flip[type]")
|
||||
I.color = reinforced.icon_colour
|
||||
I.alpha = 255 * reinforced.opacity
|
||||
overlays += I
|
||||
|
||||
if(carpeted)
|
||||
for(var/n in connections)
|
||||
overlays += "carpet_flip[type]"
|
||||
|
||||
// set propagate if you're updating a table that should update tables around it too, for example if it's a new table or something important has changed (like material).
|
||||
/obj/structure/table/proc/update_connections(propagate=0)
|
||||
if(!material)
|
||||
connections = list("nw0", "ne0", "sw0", "se0")
|
||||
|
||||
if(propagate)
|
||||
for(var/obj/structure/table/T in oview(src, 1))
|
||||
T.update_connections()
|
||||
return
|
||||
|
||||
var/list/blocked_dirs = list()
|
||||
for(var/obj/structure/window/W in get_turf(src))
|
||||
if(W.is_fulltile())
|
||||
connections = list("nw0", "ne0", "sw0", "se0")
|
||||
return
|
||||
blocked_dirs |= W.dir
|
||||
|
||||
for(var/D in list(NORTH, SOUTH, EAST, WEST) - blocked_dirs)
|
||||
var/turf/T = get_step(src, D)
|
||||
for(var/obj/structure/window/W in T)
|
||||
if(W.is_fulltile() || W.dir == reverse_dir[D])
|
||||
blocked_dirs |= D
|
||||
break
|
||||
else
|
||||
if(W.dir != D) // it's off to the side
|
||||
blocked_dirs |= W.dir|D // blocks the diagonal
|
||||
|
||||
for(var/D in list(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST) - blocked_dirs)
|
||||
var/turf/T = get_step(src, D)
|
||||
|
||||
for(var/obj/structure/window/W in T)
|
||||
if(W.is_fulltile() || W.dir & reverse_dir[D])
|
||||
blocked_dirs |= D
|
||||
break
|
||||
|
||||
// Blocked cardinals block the adjacent diagonals too. Prevents weirdness with tables.
|
||||
for(var/x in list(NORTH, SOUTH))
|
||||
for(var/y in list(EAST, WEST))
|
||||
if((x in blocked_dirs) || (y in blocked_dirs))
|
||||
blocked_dirs |= x|y
|
||||
|
||||
var/list/connection_dirs = list()
|
||||
|
||||
for(var/obj/structure/table/T in oview(src, 1))
|
||||
var/T_dir = get_dir(src, T)
|
||||
if(T_dir in blocked_dirs) continue
|
||||
if(material == T.material && flipped == T.flipped)
|
||||
connection_dirs |= T_dir
|
||||
if(propagate)
|
||||
spawn(0)
|
||||
T.update_connections()
|
||||
T.update_icon()
|
||||
|
||||
connections = dirs_to_corner_states(connection_dirs)
|
||||
|
||||
#define CORNER_NONE 0
|
||||
#define CORNER_EASTWEST 1
|
||||
#define CORNER_DIAGONAL 2
|
||||
#define CORNER_NORTHSOUTH 4
|
||||
|
||||
/proc/dirs_to_corner_states(list/dirs)
|
||||
if(!istype(dirs)) return
|
||||
|
||||
var/NE = CORNER_NONE
|
||||
var/NW = CORNER_NONE
|
||||
var/SE = CORNER_NONE
|
||||
var/SW = CORNER_NONE
|
||||
|
||||
if(NORTH in dirs)
|
||||
NE |= CORNER_NORTHSOUTH
|
||||
NW |= CORNER_NORTHSOUTH
|
||||
if(SOUTH in dirs)
|
||||
SW |= CORNER_NORTHSOUTH
|
||||
SE |= CORNER_NORTHSOUTH
|
||||
if(EAST in dirs)
|
||||
SE |= CORNER_EASTWEST
|
||||
NE |= CORNER_EASTWEST
|
||||
if(WEST in dirs)
|
||||
NW |= CORNER_EASTWEST
|
||||
SW |= CORNER_EASTWEST
|
||||
if(NORTHWEST in dirs)
|
||||
NW |= CORNER_DIAGONAL
|
||||
if(NORTHEAST in dirs)
|
||||
NE |= CORNER_DIAGONAL
|
||||
if(SOUTHEAST in dirs)
|
||||
SE |= CORNER_DIAGONAL
|
||||
if(SOUTHWEST in dirs)
|
||||
SW |= CORNER_DIAGONAL
|
||||
|
||||
return list("ne[NE]", "se[SE]", "sw[SW]", "nw[NW]")
|
||||
|
||||
#undef CORNER_NONE
|
||||
#undef CORNER_EASTWEST
|
||||
#undef CORNER_DIAGONAL
|
||||
#undef CORNER_NORTHSOUTH
|
||||
22
code/modules/tables/update_triggers.dm
Normal file
22
code/modules/tables/update_triggers.dm
Normal file
@@ -0,0 +1,22 @@
|
||||
/obj/structure/window/New()
|
||||
..()
|
||||
for(var/obj/structure/table/T in view(src, 1))
|
||||
T.update_connections()
|
||||
T.update_icon()
|
||||
|
||||
/obj/structure/window/Destroy()
|
||||
var/oldloc = loc
|
||||
loc=null
|
||||
for(var/obj/structure/table/T in view(oldloc, 1))
|
||||
T.update_connections()
|
||||
T.update_icon()
|
||||
loc=oldloc
|
||||
..()
|
||||
|
||||
/obj/structure/window/Move()
|
||||
var/oldloc = loc
|
||||
. = ..()
|
||||
if(loc != oldloc)
|
||||
for(var/obj/structure/table/T in view(oldloc, 1) | view(loc, 1))
|
||||
T.update_connections()
|
||||
T.update_icon()
|
||||
Reference in New Issue
Block a user