Move planets to SSplanets

This commit is contained in:
Anewbe
2018-06-15 18:05:25 -05:00
committed by VirgoBot
parent c81757bcf9
commit 98b3af60fa
12 changed files with 463 additions and 26 deletions

View File

@@ -31,7 +31,11 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G
#define INIT_ORDER_DEFAULT 0
#define INIT_ORDER_LIGHTING 0
#define INIT_ORDER_AIR -1
<<<<<<< HEAD
#define INIT_ORDER_HOLOMAPS -5
=======
#define INIT_ORDER_PLANETS -4
>>>>>>> 9e28740... Merge pull request #5322 from VOREStation/pol-planetstart
#define INIT_ORDER_OVERLAY -6
#define INIT_ORDER_XENOARCH -20
@@ -44,6 +48,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G
#define FIRE_PRIORITY_AIRFLOW 30
#define FIRE_PRIORITY_AIR 35
#define FIRE_PRIORITY_DEFAULT 50
#define FIRE_PRIORITY_PLANETS 75
#define FIRE_PRIORITY_MACHINES 100
#define FIRE_PRIORITY_OVERLAYS 500

View File

@@ -0,0 +1,183 @@
SUBSYSTEM_DEF(planets)
name = "Planets"
init_order = INIT_ORDER_PLANETS
priority = FIRE_PRIORITY_PLANETS
wait = 2 SECONDS
flags = SS_BACKGROUND
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
var/list/new_outdoor_turfs = list()
var/list/new_outdoor_walls = list()
var/list/planets = list()
var/list/z_to_planet = list()
var/list/currentrun = list()
var/list/needs_sun_update = list()
var/list/needs_temp_update = list()
/datum/controller/subsystem/planets/Initialize(timeofday)
admin_notice("<span class='danger'>Initializing planetary weather.</span>", R_DEBUG)
createPlanets()
allocateTurfs(TRUE)
..()
/datum/controller/subsystem/planets/proc/createPlanets()
var/list/planet_datums = subtypesof(/datum/planet)
for(var/P in planet_datums)
var/datum/planet/NP = new P()
planets.Add(NP)
for(var/Z in NP.expected_z_levels)
if(Z > z_to_planet.len)
z_to_planet.len = Z
if(z_to_planet[Z])
admin_notice("<span class='danger'>Z[Z] is shared by more than one planet!</span>", R_DEBUG)
continue
z_to_planet[Z] = NP
/datum/controller/subsystem/planets/proc/addTurf(var/turf/T,var/is_edge)
if(is_edge)
new_outdoor_walls |= T
else
new_outdoor_turfs |= T
/datum/controller/subsystem/planets/proc/removeTurf(var/turf/T,var/is_edge)
if(is_edge)
new_outdoor_walls -= T
else
new_outdoor_turfs -= T
if(z_to_planet.len >= T.z)
var/datum/planet/P = z_to_planet[T.z]
if(!P)
return
if(is_edge)
P.planet_floors -= T
else
P.planet_walls -= T
/datum/controller/subsystem/planets/proc/allocateTurfs(var/initial = FALSE)
var/list/currentlist = new_outdoor_turfs
while(currentlist.len)
var/turf/simulated/OT = currentlist[currentlist.len]
currentlist.len--
if(istype(OT) && z_to_planet[OT.z])
var/datum/planet/P = z_to_planet[OT.z]
P.planet_floors |= OT
OT.vis_contents |= P.weather_holder.visuals
if(!initial && MC_TICK_CHECK)
return
currentlist = new_outdoor_walls
while(currentlist.len)
var/turf/unsimulated/wall/planetary/PW = currentlist[currentlist.len]
currentlist.len--
if(istype(PW) && z_to_planet[PW.z])
var/datum/planet/P = z_to_planet[PW.z]
P.planet_walls |= PW
if(!initial && MC_TICK_CHECK)
return
/datum/controller/subsystem/planets/proc/unallocateTurf(var/turf/simulated/T)
if(istype(T) && z_to_planet[T.z])
var/datum/planet/P = z_to_planet[T.z]
P.planet_floors -= T
T.vis_contents -= P.weather_holder.visuals
/datum/controller/subsystem/planets/fire(resumed = 0)
if(new_outdoor_turfs.len || new_outdoor_walls.len)
allocateTurfs()
if(!resumed)
src.currentrun = planets.Copy()
var/list/needs_sun_update = src.needs_sun_update
while(needs_sun_update.len)
var/datum/planet/P = needs_sun_update[needs_sun_update.len]
needs_sun_update.len--
updateSunlight(P)
if(MC_TICK_CHECK)
return
var/list/needs_temp_update = src.needs_temp_update
while(needs_temp_update.len)
var/datum/planet/P = needs_temp_update[needs_temp_update.len]
needs_temp_update.len--
updateTemp(P)
if(MC_TICK_CHECK)
return
var/list/currentrun = src.currentrun
while(currentrun.len)
var/datum/planet/P = currentrun[currentrun.len]
currentrun.len--
P.process(last_fire)
//Sun light needs changing
if(P.needs_work & PLANET_PROCESS_SUN)
P.needs_work &= ~PLANET_PROCESS_SUN
needs_sun_update |= P
//Temperature needs updating
if(P.needs_work & PLANET_PROCESS_TEMP)
P.needs_work &= ~PLANET_PROCESS_TEMP
needs_temp_update |= P
if(MC_TICK_CHECK)
return
/datum/controller/subsystem/planets/proc/updateSunlight(var/datum/planet/P)
// Remove old value from corners
var/list/sunlit_corners = P.sunlit_corners
var/old_lum_r = -P.sun["lum_r"]
var/old_lum_g = -P.sun["lum_g"]
var/old_lum_b = -P.sun["lum_b"]
if(old_lum_r || old_lum_g || old_lum_b)
for(var/C in sunlit_corners)
var/datum/lighting_corner/LC = C
LC.update_lumcount(old_lum_r, old_lum_g, old_lum_b)
CHECK_TICK
sunlit_corners.Cut()
// Calculate new values to apply
var/new_brightness = P.sun["brightness"]
var/new_color = P.sun["color"]
var/lum_r = new_brightness * GetRedPart (new_color) / 255
var/lum_g = new_brightness * GetGreenPart(new_color) / 255
var/lum_b = new_brightness * GetBluePart (new_color) / 255
var/static/update_gen = -1 // Used to prevent double-processing corners. Otherwise would happen when looping over adjacent turfs.
for(var/I in P.planet_floors)
var/turf/simulated/T = I
if(!T.lighting_corners_initialised)
T.generate_missing_corners()
for(var/C in T.get_corners())
var/datum/lighting_corner/LC = C
if(LC.update_gen != update_gen && LC.active)
sunlit_corners += LC
LC.update_gen = update_gen
LC.update_lumcount(lum_r, lum_g, lum_b)
CHECK_TICK
update_gen--
P.sun["lum_r"] = lum_r
P.sun["lum_g"] = lum_g
P.sun["lum_b"] = lum_b
/datum/controller/subsystem/planets/proc/updateTemp(var/datum/planet/P)
//Set new temperatures
for(var/W in P.planet_walls)
var/turf/unsimulated/wall/planetary/wall = W
wall.set_temperature(P.weather_holder.temperature)
CHECK_TICK
/datum/controller/subsystem/planets/proc/weatherDisco()
var/count = 100000
while(count > 0)
count--
for(var/planet in planets)
var/datum/planet/P = planet
if(P.weather_holder)
P.weather_holder.change_weather(pick(P.weather_holder.allowed_weather_types))
sleep(3)

View File

@@ -133,9 +133,6 @@
if("Vote")
debug_variables(vote)
feedback_add_details("admin_verb", "DVote")
if("Planets")
debug_variables(planet_controller)
feedback_add_details("admin_verb", "DPlanets")
message_admins("Admin [key_name_admin(usr)] is debugging the [controller] controller.")
return

View File

@@ -1,3 +1,4 @@
<<<<<<< HEAD
// Proc: ui_interact()
// Parameters: 4 (standard NanoUI arguments)
// Description: Uses a bunch of for loops to turn lists into lists of lists, so they can be displayed in nanoUI, then displays various buttons to the user.
@@ -251,3 +252,257 @@
nanomanager.update_uis(src)
add_fingerprint(usr)
=======
// Proc: ui_interact()
// Parameters: 4 (standard NanoUI arguments)
// Description: Uses a bunch of for loops to turn lists into lists of lists, so they can be displayed in nanoUI, then displays various buttons to the user.
/obj/item/device/communicator/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/key_state = null)
// this is the data which will be sent to the ui
var/data[0] //General nanoUI information
var/communicators[0] //List of communicators
var/invites[0] //Communicators and ghosts we've invited to our communicator.
var/requests[0] //Communicators and ghosts wanting to go in our communicator.
var/voices[0] //Current /mob/living/voice s inside the device.
var/connected_communicators[0] //Current communicators connected to the device.
var/im_contacts_ui[0] //List of communicators that have been messaged.
var/im_list_ui[0] //List of messages.
var/weather[0]
var/injection = null
var/modules_ui[0] //Home screen info.
//First we add other 'local' communicators.
for(var/obj/item/device/communicator/comm in known_devices)
if(comm.network_visibility && comm.exonet)
communicators[++communicators.len] = list("name" = sanitize(comm.name), "address" = comm.exonet.address)
//Now for ghosts who we pretend have communicators.
for(var/mob/observer/dead/O in known_devices)
if(O.client && O.client.prefs.communicator_visibility == 1 && O.exonet)
communicators[++communicators.len] = list("name" = sanitize("[O.client.prefs.real_name]'s communicator"), "address" = O.exonet.address, "ref" = "\ref[O]")
//Lists all the other communicators that we invited.
for(var/obj/item/device/communicator/comm in voice_invites)
if(comm.exonet)
invites[++invites.len] = list("name" = sanitize(comm.name), "address" = comm.exonet.address, "ref" = "\ref[comm]")
//Ghosts we invited.
for(var/mob/observer/dead/O in voice_invites)
if(O.exonet && O.client)
invites[++invites.len] = list("name" = sanitize("[O.client.prefs.real_name]'s communicator"), "address" = O.exonet.address, "ref" = "\ref[O]")
//Communicators that want to talk to us.
for(var/obj/item/device/communicator/comm in voice_requests)
if(comm.exonet)
requests[++requests.len] = list("name" = sanitize(comm.name), "address" = comm.exonet.address, "ref" = "\ref[comm]")
//Ghosts that want to talk to us.
for(var/mob/observer/dead/O in voice_requests)
if(O.exonet && O.client)
requests[++requests.len] = list("name" = sanitize("[O.client.prefs.real_name]'s communicator"), "address" = O.exonet.address, "ref" = "\ref[O]")
//Now for all the voice mobs inside the communicator.
for(var/mob/living/voice/voice in contents)
voices[++voices.len] = list("name" = sanitize("[voice.name]'s communicator"), "true_name" = sanitize(voice.name))
//Finally, all the communicators linked to this one.
for(var/obj/item/device/communicator/comm in communicating)
connected_communicators[++connected_communicators.len] = list("name" = sanitize(comm.name), "true_name" = sanitize(comm.name), "ref" = "\ref[comm]")
//Devices that have been messaged or recieved messages from.
for(var/obj/item/device/communicator/comm in im_contacts)
if(comm.exonet)
im_contacts_ui[++im_contacts_ui.len] = list("name" = sanitize(comm.name), "address" = comm.exonet.address, "ref" = "\ref[comm]")
for(var/mob/observer/dead/ghost in im_contacts)
if(ghost.exonet)
im_contacts_ui[++im_contacts_ui.len] = list("name" = sanitize(ghost.name), "address" = ghost.exonet.address, "ref" = "\ref[ghost]")
//Actual messages.
for(var/I in im_list)
im_list_ui[++im_list_ui.len] = list("address" = I["address"], "to_address" = I["to_address"], "im" = I["im"])
//Weather reports.
for(var/datum/planet/planet in SSplanets.planets)
if(planet.weather_holder && planet.weather_holder.current_weather)
var/list/W = list(
"Planet" = planet.name,
"Time" = planet.current_time.show_time("hh:mm"),
"Weather" = planet.weather_holder.current_weather.name,
"Temperature" = planet.weather_holder.temperature - T0C,
"High" = planet.weather_holder.current_weather.temp_high - T0C,
"Low" = planet.weather_holder.current_weather.temp_low - T0C)
weather[++weather.len] = W
injection = "<div>Test</div>"
//Modules for homescreen.
for(var/list/R in modules)
modules_ui[++modules_ui.len] = R
data["owner"] = owner ? owner : "Unset"
data["occupation"] = occupation ? occupation : "Swipe ID to set."
data["connectionStatus"] = get_connection_to_tcomms()
data["visible"] = network_visibility
data["address"] = exonet.address ? exonet.address : "Unallocated"
data["targetAddress"] = target_address
data["targetAddressName"] = target_address_name
data["currentTab"] = selected_tab
data["knownDevices"] = communicators
data["invitesSent"] = invites
data["requestsReceived"] = requests
data["voice_mobs"] = voices
data["communicating"] = connected_communicators
data["video_comm"] = video_source ? "\ref[video_source.loc]" : null
data["imContacts"] = im_contacts_ui
data["imList"] = im_list_ui
data["time"] = stationtime2text()
data["ring"] = ringer
data["homeScreen"] = modules_ui
data["note"] = note // current notes
data["weather"] = weather
data["aircontents"] = src.analyze_air()
data["flashlight"] = fon
data["injection"] = injection
// update the ui if it exists, returns null if no ui is passed/found
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
// the ui does not exist, so we'll create a new() one
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
ui = new(user, src, ui_key, "communicator.tmpl", "Communicator", 475, 700, state = key_state)
// add templates for screens in common with communicator.
ui.add_template("atmosphericScan", "atmospheric_scan.tmpl")
// when the ui is first opened this is the data it will use
ui.set_initial_data(data)
// open the new ui window
ui.open()
// auto update every five Master Controller tick
ui.set_auto_update(5)
// Proc: Topic()
// Parameters: 2 (standard Topic arguments)
// Description: Responds to NanoUI button presses.
/obj/item/device/communicator/Topic(href, href_list)
if(..())
return 1
if(href_list["rename"])
var/new_name = sanitizeSafe(input(usr,"Please enter your name.","Communicator",usr.name) )
if(new_name)
register_device(new_name)
if(href_list["toggle_visibility"])
switch(network_visibility)
if(1) //Visible, becoming invisbile
network_visibility = 0
if(camera)
camera.remove_network(NETWORK_COMMUNICATORS)
if(0) //Invisible, becoming visible
network_visibility = 1
if(camera)
camera.add_network(NETWORK_COMMUNICATORS)
if(href_list["toggle_ringer"])
ringer = !ringer
if(href_list["add_hex"])
var/hex = href_list["add_hex"]
add_to_EPv2(hex)
if(href_list["write_target_address"])
var/new_address = sanitizeSafe(input(usr,"Please enter the desired target EPv2 address. Note that you must write the colons \
yourself.","Communicator",src.target_address) )
if(new_address)
target_address = new_address
if(href_list["clear_target_address"])
target_address = ""
if(href_list["dial"])
if(!get_connection_to_tcomms())
usr << "<span class='danger'>Error: Cannot connect to Exonet node.</span>"
return
var/their_address = href_list["dial"]
exonet.send_message(their_address, "voice")
if(href_list["decline"])
var/ref_to_remove = href_list["decline"]
var/atom/decline = locate(ref_to_remove)
if(decline)
del_request(decline)
if(href_list["message"])
if(!get_connection_to_tcomms())
usr << "<span class='danger'>Error: Cannot connect to Exonet node.</span>"
return
var/their_address = href_list["message"]
var/text = sanitizeSafe(input(usr,"Enter your message.","Text Message"))
if(text)
exonet.send_message(their_address, "text", text)
im_list += list(list("address" = exonet.address, "to_address" = their_address, "im" = text))
log_pda("(COMM: [src]) sent \"[text]\" to [exonet.get_atom_from_address(their_address)]", usr)
for(var/mob/M in player_list)
if(M.stat == DEAD && M.is_preference_enabled(/datum/client_preference/ghost_ears))
if(istype(M, /mob/new_player) || M.forbid_seeing_deadchat)
continue
if(exonet.get_atom_from_address(their_address) == M)
continue
M.show_message("Comm IM - [src] -> [exonet.get_atom_from_address(their_address)]: [text]")
if(href_list["disconnect"])
var/name_to_disconnect = href_list["disconnect"]
for(var/mob/living/voice/V in contents)
if(name_to_disconnect == V.name)
close_connection(usr, V, "[usr] hung up")
for(var/obj/item/device/communicator/comm in communicating)
if(name_to_disconnect == comm.name)
close_connection(usr, comm, "[usr] hung up")
if(href_list["startvideo"])
var/ref_to_video = href_list["startvideo"]
var/obj/item/device/communicator/comm = locate(ref_to_video)
if(comm)
connect_video(usr, comm)
if(href_list["endvideo"])
if(video_source)
end_video()
if(href_list["watchvideo"])
if(video_source)
watch_video(usr,video_source.loc)
if(href_list["copy"])
target_address = href_list["copy"]
if(href_list["copy_name"])
target_address_name = href_list["copy_name"]
if(href_list["hang_up"])
for(var/mob/living/voice/V in contents)
close_connection(usr, V, "[usr] hung up")
for(var/obj/item/device/communicator/comm in communicating)
close_connection(usr, comm, "[usr] hung up")
if(href_list["switch_tab"])
selected_tab = href_list["switch_tab"]
if(href_list["edit"])
var/n = input(usr, "Please enter message", name, notehtml)
n = sanitizeSafe(n, extra = 0)
if(n)
note = html_decode(n)
notehtml = note
note = replacetext(note, "\n", "<br>")
else
note = ""
notehtml = note
if(href_list["Light"])
fon = !fon
set_light(fon * flum)
nanomanager.update_uis(src)
add_fingerprint(usr)
>>>>>>> 9e28740... Merge pull request #5322 from VOREStation/pol-planetstart

View File

@@ -1,5 +1,4 @@
var/list/turf_edge_cache = list()
var/list/outdoor_turfs = list()
/turf/
// If greater than 0, this turf will apply edge overlays on top of other turfs cardinally adjacent to it, if those adjacent turfs are of a different icon_state,
@@ -24,24 +23,21 @@ var/list/outdoor_turfs = list()
/turf/simulated/floor/New()
if(outdoors)
outdoor_turfs.Add(src)
SSplanets.addTurf(src)
..()
/turf/simulated/floor/Destroy()
if(outdoors)
planet_controller.unallocateTurf(src)
SSplanets.removeTurf(src)
return ..()
/turf/simulated/proc/make_outdoors()
outdoors = TRUE
outdoor_turfs.Add(src)
SSplanets.addTurf(src)
/turf/simulated/proc/make_indoors()
outdoors = FALSE
if(planet_controller)
planet_controller.unallocateTurf(src)
else // This is happening during map gen, if there's no planet_controller (hopefully).
outdoor_turfs -= src
SSplanets.removeTurf(src)
/turf/simulated/post_change()
..()

View File

@@ -14,7 +14,7 @@
/turf/simulated/sky/initialize()
. = ..()
outdoor_turfs.Add(src)
SSplanets.addTurf(src)
set_light(2, 2, "#FFFFFF")
/turf/simulated/sky/north

View File

@@ -1,7 +1,5 @@
// This is a wall you surround the area of your "planet" with, that makes the atmosphere inside stay within bounds, even if canisters
// are opened or other strange things occur.
var/list/planetary_walls = list()
/turf/unsimulated/wall/planetary
name = "railroading"
desc = "Choo choo!"
@@ -21,10 +19,10 @@ var/list/planetary_walls = list()
/turf/unsimulated/wall/planetary/New()
..()
planetary_walls.Add(src)
SSplanets.addTurf(src)
/turf/unsimulated/wall/planetary/Destroy()
planetary_walls.Remove(src)
SSplanets.removeTurf(src)
..()
/turf/unsimulated/wall/planetary/proc/set_temperature(var/new_temperature)

View File

@@ -637,7 +637,7 @@
if(!check_rights(R_DEBUG))
return
var/datum/planet/planet = input(usr, "Which planet do you want to modify the weather on?", "Change Weather") in planet_controller.planets
var/datum/planet/planet = input(usr, "Which planet do you want to modify the weather on?", "Change Weather") in SSplanets.planets
var/datum/weather/new_weather = input(usr, "What weather do you want to change to?", "Change Weather") as null|anything in planet.weather_holder.allowed_weather_types
if(new_weather)
planet.weather_holder.change_weather(new_weather)
@@ -653,7 +653,7 @@
if(!check_rights(R_DEBUG))
return
var/datum/planet/planet = input(usr, "Which planet do you want to modify time on?", "Change Time") in planet_controller.planets
var/datum/planet/planet = input(usr, "Which planet do you want to modify time on?", "Change Time") in SSplanets.planets
var/datum/time/current_time_datum = planet.current_time
var/new_hour = input(usr, "What hour do you want to change to?", "Change Time", text2num(current_time_datum.show_time("hh"))) as null|num

View File

@@ -6,9 +6,8 @@
endWhen = rand(15, 60)
// Setup which levels we will disrupt gravit on.
zLevels = using_map.station_levels.Copy()
if (planet_controller)
for(var/datum/planet/P in planet_controller.planets)
zLevels -= P.expected_z_levels
for(var/datum/planet/P in SSplanets.planets)
zLevels -= P.expected_z_levels
/datum/event/gravity/announce()
command_announcement.Announce("Feedback surge detected in mass-distributions systems. Artificial gravity has been disabled whilst the system \

View File

@@ -30,9 +30,10 @@
current_time = current_time.make_random_time()
update_sun()
/datum/planet/proc/process(amount)
/datum/planet/proc/process(last_fire)
if(current_time)
current_time = current_time.add_seconds(amount)
var/difference = world.time - last_fire
current_time = current_time.add_seconds(difference SECONDS)
update_weather() // We update this first, because some weather types decease the brightness of the sun.
if(sun_last_process <= world.time - sun_process_interval)
update_sun()

View File

@@ -184,7 +184,7 @@ datum/weather/sif
)
/datum/weather/sif/snow/process_effects()
for(var/turf/simulated/floor/outdoors/snow/S in outdoor_turfs)
for(var/turf/simulated/floor/outdoors/snow/S in SSplanets.new_outdoor_turfs) //This didn't make any sense before SSplanets, either
if(S.z in holder.our_planet.expected_z_levels)
for(var/dir_checked in cardinal)
var/turf/simulated/floor/T = get_step(S, dir_checked)
@@ -207,7 +207,7 @@ datum/weather/sif
)
/datum/weather/sif/blizzard/process_effects()
for(var/turf/simulated/floor/outdoors/snow/S in outdoor_turfs)
for(var/turf/simulated/floor/outdoors/snow/S in SSplanets.new_outdoor_turfs) //This didn't make any sense before SSplanets, either
if(S.z in holder.our_planet.expected_z_levels)
for(var/dir_checked in cardinal)
var/turf/simulated/floor/T = get_step(S, dir_checked)

View File

@@ -195,7 +195,6 @@
#include "code\controllers\Processes\inactivity.dm"
#include "code\controllers\Processes\nanoui.dm"
#include "code\controllers\Processes\obj.dm"
#include "code\controllers\Processes\planet.dm"
#include "code\controllers\Processes\radiation.dm"
#include "code\controllers\Processes\scheduler.dm"
#include "code\controllers\Processes\sun.dm"
@@ -217,7 +216,11 @@
#include "code\controllers\subsystems\mobs.dm"
#include "code\controllers\subsystems\orbits.dm"
#include "code\controllers\subsystems\overlays.dm"
<<<<<<< HEAD:vorestation.dme
#include "code\controllers\subsystems\persist_vr.dm"
=======
#include "code\controllers\subsystems\planets.dm"
>>>>>>> 9e28740... Merge pull request #5322 from VOREStation/pol-planetstart:polaris.dme
#include "code\controllers\subsystems\shuttles.dm"
#include "code\controllers\subsystems\transcore_vr.dm"
#include "code\controllers\subsystems\xenoarch.dm"