Files
Paradise/code/game/turfs/space/space.dm
T

247 lines
6.5 KiB
Plaintext

/turf/space
icon = 'icons/turf/space.dmi'
name = "\proper space"
icon_state = "0"
dynamic_lighting = 0
luminosity = 1
temperature = TCMB
thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
heat_capacity = 700000
var/destination_z
var/destination_x
var/destination_y
/turf/space/New()
. = ..()
if(!istype(src, /turf/space/transit))
icon_state = SPACE_ICON_STATE
if(update_starlight() && is_station_level(z))
// before you ask: Yes, this is fucking stupid, but looping through turf/space in world is how you make the server freeze
// so I don't see a better way of doing this
LAZYADD(GLOB.station_level_space_turfs, src)
/turf/space/Destroy(force)
if(force)
. = ..()
else
return QDEL_HINT_LETMELIVE
/turf/space/BeforeChange()
..()
var/datum/space_level/S = space_manager.get_zlev(z)
S.remove_from_transit(src)
if(light_sources) // Turn off starlight, if present
set_light(0)
/turf/space/AfterChange(ignore_air, keep_cabling = FALSE)
..()
var/datum/space_level/S = space_manager.get_zlev(z)
S.add_to_transit(src)
S.apply_transition(src)
/turf/space/proc/update_starlight()
if(!config.starlight)
return FALSE
if(locate(/turf/simulated) in orange(src,1))
set_light(config.starlight)
return TRUE
else
set_light(0)
return FALSE
/turf/space/attackby(obj/item/C as obj, mob/user as mob, params)
..()
if(istype(C, /obj/item/stack/rods))
var/obj/item/stack/rods/R = C
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
if(R.use(1))
to_chat(user, "<span class='notice'>You begin constructing catwalk...</span>")
playsound(src, 'sound/weapons/genhit.ogg', 50, 1)
qdel(L)
ChangeTurf(/turf/simulated/floor/plating/airless/catwalk)
else
to_chat(user, "<span class='warning'>You need two rods to build a catwalk!</span>")
return
if(R.use(1))
to_chat(user, "<span class='notice'>Constructing support lattice...</span>")
playsound(src, 'sound/weapons/genhit.ogg', 50, 1)
ReplaceWithLattice()
else
to_chat(user, "<span class='warning'>You need one rod to build a lattice.</span>")
return
if(istype(C, /obj/item/stack/tile/plasteel))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
var/obj/item/stack/tile/plasteel/S = C
if(S.use(1))
qdel(L)
playsound(src, 'sound/weapons/genhit.ogg', 50, 1)
to_chat(user, "<span class='notice'>You build a floor.</span>")
ChangeTurf(/turf/simulated/floor/plating)
else
to_chat(user, "<span class='warning'>You need one floor tile to build a floor!</span>")
else
to_chat(user, "<span class='warning'>The plating is going to need some support! Place metal rods first.</span>")
/turf/space/Entered(atom/movable/A as mob|obj, atom/OL, ignoreRest = 0)
..()
if(destination_z && A && (src in A.locs))
A.x = destination_x
A.y = destination_y
A.z = destination_z
if(isliving(A))
var/mob/living/L = A
if(L.pulling)
var/turf/T = get_step(L.loc,turn(A.dir, 180))
L.pulling.loc = T
//now we're on the new z_level, proceed the space drifting
sleep(0)//Let a diagonal move finish, if necessary
A.newtonian_move(A.inertia_dir)
/turf/space/proc/Sandbox_Spacemove(atom/movable/A as mob|obj)
var/cur_x
var/cur_y
var/next_x
var/next_y
var/target_z
var/list/y_arr
if(src.x <= 1)
if(istype(A, /obj/effect/meteor)||istype(A, /obj/effect/space_dust))
qdel(A)
return
var/list/cur_pos = src.get_global_map_pos()
if(!cur_pos) return
cur_x = cur_pos["x"]
cur_y = cur_pos["y"]
next_x = (--cur_x||global_map.len)
y_arr = global_map[next_x]
target_z = y_arr[cur_y]
/*
//debug
to_chat(world, "Src.z = [src.z] in global map X = [cur_x], Y = [cur_y]")
to_chat(world, "Target Z = [target_z]")
to_chat(world, "Next X = [next_x]")
//debug
*/
if(target_z)
A.z = target_z
A.x = world.maxx - 2
spawn (0)
if((A && A.loc))
A.loc.Entered(A)
else if(src.x >= world.maxx)
if(istype(A, /obj/effect/meteor))
qdel(A)
return
var/list/cur_pos = src.get_global_map_pos()
if(!cur_pos) return
cur_x = cur_pos["x"]
cur_y = cur_pos["y"]
next_x = (++cur_x > global_map.len ? 1 : cur_x)
y_arr = global_map[next_x]
target_z = y_arr[cur_y]
/*
//debug
to_chat(world, "Src.z = [src.z] in global map X = [cur_x], Y = [cur_y]")
to_chat(world, "Target Z = [target_z]")
to_chat(world, "Next X = [next_x]")
//debug
*/
if(target_z)
A.z = target_z
A.x = 3
spawn (0)
if((A && A.loc))
A.loc.Entered(A)
else if(src.y <= 1)
if(istype(A, /obj/effect/meteor))
qdel(A)
return
var/list/cur_pos = src.get_global_map_pos()
if(!cur_pos) return
cur_x = cur_pos["x"]
cur_y = cur_pos["y"]
y_arr = global_map[cur_x]
next_y = (--cur_y||y_arr.len)
target_z = y_arr[next_y]
/*
//debug
to_chat(world, "Src.z = [src.z] in global map X = [cur_x], Y = [cur_y]")
to_chat(world, "Next Y = [next_y]")
to_chat(world, "Target Z = [target_z]")
//debug
*/
if(target_z)
A.z = target_z
A.y = world.maxy - 2
spawn (0)
if((A && A.loc))
A.loc.Entered(A)
else if(src.y >= world.maxy)
if(istype(A, /obj/effect/meteor)||istype(A, /obj/effect/space_dust))
qdel(A)
return
var/list/cur_pos = src.get_global_map_pos()
if(!cur_pos) return
cur_x = cur_pos["x"]
cur_y = cur_pos["y"]
y_arr = global_map[cur_x]
next_y = (++cur_y > y_arr.len ? 1 : cur_y)
target_z = y_arr[next_y]
/*
//debug
to_chat(world, "Src.z = [src.z] in global map X = [cur_x], Y = [cur_y]")
to_chat(world, "Next Y = [next_y]")
to_chat(world, "Target Z = [target_z]")
//debug
*/
if(target_z)
A.z = target_z
A.y = 3
spawn (0)
if((A && A.loc))
A.loc.Entered(A)
return
/turf/space/singularity_act()
return
/turf/space/can_have_cabling()
return 0
/turf/space/proc/set_transition_north(dest_z)
destination_x = x
destination_y = TRANSITION_BORDER_SOUTH + 1
destination_z = dest_z
/turf/space/proc/set_transition_south(dest_z)
destination_x = x
destination_y = TRANSITION_BORDER_NORTH - 1
destination_z = dest_z
/turf/space/proc/set_transition_east(dest_z)
destination_x = TRANSITION_BORDER_WEST + 1
destination_y = y
destination_z = dest_z
/turf/space/proc/set_transition_west(dest_z)
destination_x = TRANSITION_BORDER_EAST - 1
destination_y = y
destination_z = dest_z
/turf/space/proc/remove_transitions()
destination_z = initial(destination_z)