From 158d7f68e2318fb2e2afea2127883dfb8c138066 Mon Sep 17 00:00:00 2001 From: Wildkins Date: Sat, 12 Nov 2022 16:41:52 -0500 Subject: [PATCH] Fix exoplanet theming and lighting (#15083) --- code/game/turfs/turf.dm | 5 ++ code/game/turfs/turf_changing.dm | 5 ++ code/modules/mining/mine_turfs.dm | 21 ++++++++ code/modules/overmap/exoplanets/exoplanet.dm | 11 ++-- .../overmap/exoplanets/exoplanet_skybox.dm | 2 +- code/modules/overmap/exoplanets/random_map.dm | 7 ++- code/modules/overmap/exoplanets/theme.dm | 53 ++++++++++--------- code/modules/overmap/exoplanets/turfs.dm | 2 +- code/modules/random_map/automata/automata.dm | 2 + html/changelogs/johnwildkins-exofix.yml | 7 +++ 10 files changed, 83 insertions(+), 32 deletions(-) create mode 100644 html/changelogs/johnwildkins-exofix.yml diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 6701c5c370a..35ccab7ed5d 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -95,6 +95,11 @@ if (z_flags & ZM_MIMIC_BELOW) setup_zmimic(mapload) + if (current_map.use_overmap && istype(A, /area/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/E = map_sectors["[z]"] + if (istype(E) && istype(E.theme)) + E.theme.on_turf_generation(src, E.planetary_area) + return INITIALIZE_HINT_NORMAL /turf/Destroy() diff --git a/code/game/turfs/turf_changing.dm b/code/game/turfs/turf_changing.dm index 668eab2793c..b1622c9085d 100644 --- a/code/game/turfs/turf_changing.dm +++ b/code/game/turfs/turf_changing.dm @@ -23,6 +23,11 @@ else queue_smooth(src) + if (current_map.use_overmap && istype(loc, /area/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/E = map_sectors["[z]"] + if (istype(E) && istype(E.theme)) + E.theme.on_turf_generation(src, E.planetary_area) + // Helper to change this turf into an appropriate openturf type, generally you should use this instead of ChangeTurf(/turf/simulated/open). /turf/proc/ChangeToOpenturf() . = ChangeTurf(/turf/space) diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index 24af80b690c..69eadb8b868 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -89,6 +89,17 @@ var/list/mineral_can_smooth_with = list( rock_health = rand(10,20) + var/area/A = loc + + if(!baseturf) + // Hard-coding this for performance reasons. + baseturf = A.base_turf || current_map.base_turf_by_z["[z]"] || /turf/space + + if (current_map.use_overmap && istype(A, /area/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/E = map_sectors["[z]"] + if (istype(E) && istype(E.theme)) + E.theme.on_turf_generation(src, E.planetary_area) + return INITIALIZE_HINT_NORMAL /turf/simulated/mineral/examine(mob/user) @@ -202,6 +213,11 @@ var/list/mineral_can_smooth_with = list( if(!mapload) queue_smooth_neighbors(src) + if (current_map.use_overmap && istype(loc, /area/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/E = map_sectors["[z]"] + if (istype(E) && istype(E.theme)) + E.theme.on_turf_generation(src, E.planetary_area) + return INITIALIZE_HINT_NORMAL #define SPREAD(the_dir) \ @@ -642,6 +658,11 @@ var/list/asteroid_floor_smooth = list( if(light_range && light_power) update_light() + if (current_map.use_overmap && istype(loc, /area/exoplanet)) + var/obj/effect/overmap/visitable/sector/exoplanet/E = map_sectors["[z]"] + if (istype(E) && istype(E.theme)) + E.theme.on_turf_generation(src, E.planetary_area) + return INITIALIZE_HINT_NORMAL /turf/unsimulated/floor/asteroid/ex_act(severity) diff --git a/code/modules/overmap/exoplanets/exoplanet.dm b/code/modules/overmap/exoplanets/exoplanet.dm index b545d04fa72..48b38adc8ff 100644 --- a/code/modules/overmap/exoplanets/exoplanet.dm +++ b/code/modules/overmap/exoplanets/exoplanet.dm @@ -34,7 +34,7 @@ var/repopulate_types = list() // animals which have died that may come back var/list/possible_themes = list(/datum/exoplanet_theme) - var/list/themes = list() + var/datum/exoplanet_theme/theme var/list/map_generators = list() @@ -74,7 +74,7 @@ if(LAZYLEN(possible_themes)) var/datum/exoplanet_theme/T = pick(possible_themes) - themes += new T + theme = new T for(var/T in subtypesof(/datum/map_template/ruin/exoplanet)) var/datum/map_template/ruin/exoplanet/ruin = T @@ -172,8 +172,9 @@ if(length(grasscolors)) grass_color = pick(grasscolors) - for(var/datum/exoplanet_theme/T as anything in themes) - T.before_map_generation(src) + if(istype(theme)) + theme.before_map_generation(src) + for (var/zlevel in map_z) var/list/edges edges += block(locate(1, 1, zlevel), locate(TRANSITIONEDGE, maxy, zlevel)) @@ -185,7 +186,7 @@ var/padding = TRANSITIONEDGE for (var/map_type in map_generators) if (ispath(map_type, /datum/random_map/noise/exoplanet)) - new map_type(null,padding,padding,zlevel,maxx-padding,maxy-padding,0,1,1,planetary_area, plant_colors) + new map_type(null,padding,padding,zlevel,maxx-padding,maxy-padding,0,1,1,planetary_area, plant_colors, theme) else new map_type(null,1,1,zlevel,maxx,maxy,0,1,1,planetary_area) diff --git a/code/modules/overmap/exoplanets/exoplanet_skybox.dm b/code/modules/overmap/exoplanets/exoplanet_skybox.dm index de097422fcb..101ee4187ec 100644 --- a/code/modules/overmap/exoplanets/exoplanet_skybox.dm +++ b/code/modules/overmap/exoplanets/exoplanet_skybox.dm @@ -11,7 +11,7 @@ skybox_image.overlays += get_base_image() - for (var/datum/exoplanet_theme/theme in themes) + if(istype(theme)) skybox_image.overlays += theme.get_planet_image_extra() if (water_color) //TODO: move water levels out of randommap into exoplanet diff --git a/code/modules/overmap/exoplanets/random_map.dm b/code/modules/overmap/exoplanets/random_map.dm index c259a6be5b4..6c097ef3909 100644 --- a/code/modules/overmap/exoplanets/random_map.dm +++ b/code/modules/overmap/exoplanets/random_map.dm @@ -7,6 +7,7 @@ var/water_level_max = 5 var/land_type = /turf/simulated/floor var/water_type + var/datum/exoplanet_theme/planet_theme //intended x*y size, used to adjust spawn probs var/intended_x = 150 @@ -22,7 +23,7 @@ var/list/plantcolors = list("RANDOM") var/list/grass_cache -/datum/random_map/noise/exoplanet/New(var/seed, var/tx, var/ty, var/tz, var/tlx, var/tly, var/do_not_apply, var/do_not_announce, var/never_be_priority = 0, var/used_area, var/list/_plant_colors) +/datum/random_map/noise/exoplanet/New(var/seed, var/tx, var/ty, var/tz, var/tlx, var/tly, var/do_not_apply, var/do_not_announce, var/never_be_priority = 0, var/used_area, var/list/_plant_colors, var/datum/exoplanet_theme/_planet_theme) log_debug("Generating Random Exoplanet Map with tx: [tx], ty: [ty], tz: [tz], tlx: [tlx], tly: [tly]") target_turf_type = world.turf water_level = rand(water_level_min,water_level_max) @@ -32,6 +33,8 @@ fauna_prob *= size_mod if(_plant_colors) plantcolors = _plant_colors + if(istype(_planet_theme)) + planet_theme = _planet_theme generate_flora() ..() @@ -52,6 +55,8 @@ return land_type /datum/random_map/noise/exoplanet/get_additional_spawns(var/value, var/turf/T) + if(istype(planet_theme)) + planet_theme.on_turf_generation(T, use_area) if(is_edge_turf(T)) return if(T.is_wall()) diff --git a/code/modules/overmap/exoplanets/theme.dm b/code/modules/overmap/exoplanets/theme.dm index 6ef0706f67a..9ed20abc3fa 100644 --- a/code/modules/overmap/exoplanets/theme.dm +++ b/code/modules/overmap/exoplanets/theme.dm @@ -1,37 +1,46 @@ /datum/exoplanet_theme var/name = "Nothing Special" + var/list/surface_turfs = list() + var/surface_color /datum/exoplanet_theme/proc/before_map_generation(obj/effect/overmap/visitable/sector/exoplanet/E) + if(E.rock_colors) + surface_color = pick(E.rock_colors) + +/datum/exoplanet_theme/proc/on_turf_generation(turf/T, var/area/use_area) + if(surface_color && is_type_in_list(T, surface_turfs)) + T.color = surface_color /datum/exoplanet_theme/proc/get_planet_image_extra() /datum/exoplanet_theme/mountains name = "Mountains" - var/rock_color + surface_turfs = list( + /turf/simulated/mineral, + /turf/unsimulated/floor/asteroid/ash + ) + var/cave_path = /datum/random_map/automata/cave_system/mountains /datum/exoplanet_theme/mountains/get_planet_image_extra() var/image/res = image('icons/skybox/planet.dmi', "mountains") - res.color = rock_color + res.color = surface_color return res /datum/exoplanet_theme/mountains/before_map_generation(obj/effect/overmap/visitable/sector/exoplanet/E) - if(E.rock_colors) - rock_color = pick(E.rock_colors) + ..() for(var/zlevel in E.map_z) - new /datum/random_map/automata/cave_system/mountains(null,TRANSITIONEDGE,TRANSITIONEDGE,zlevel,E.maxx-TRANSITIONEDGE,E.maxy-TRANSITIONEDGE,0,1,1, E.planetary_area, rock_color) + new cave_path(null,TRANSITIONEDGE,TRANSITIONEDGE,zlevel,E.maxx-TRANSITIONEDGE,E.maxy-TRANSITIONEDGE,0,1,1, E.planetary_area, src) -/datum/exoplanet_theme/mountains/phoron/before_map_generation(obj/effect/overmap/visitable/sector/exoplanet/E) - if(E.rock_colors) - rock_color = pick(E.rock_colors) - for(var/zlevel in E.map_z) - new /datum/random_map/automata/cave_system/mountains/phoron(null,TRANSITIONEDGE,TRANSITIONEDGE,zlevel,E.maxx-TRANSITIONEDGE,E.maxy-TRANSITIONEDGE,0,1,1, E.planetary_area, rock_color) +/datum/exoplanet_theme/mountains/on_turf_generation(turf/simulated/mineral/T, var/area/use_area) + ..() + if(use_area && istype(T)) + T.mined_turf = use_area.base_turf -/datum/exoplanet_theme/mountains/breathable/before_map_generation(obj/effect/overmap/visitable/sector/exoplanet/E) - if(E.rock_colors) - rock_color = pick(E.rock_colors) - for(var/zlevel in E.map_z) - new /datum/random_map/automata/cave_system/mountains/breathable(null,TRANSITIONEDGE,TRANSITIONEDGE,zlevel,E.maxx-TRANSITIONEDGE,E.maxy-TRANSITIONEDGE,0,1,1, E.planetary_area, rock_color) +/datum/exoplanet_theme/mountains/phoron + cave_path = /datum/random_map/automata/cave_system/mountains/phoron +/datum/exoplanet_theme/mountains/breathable + cave_path = /datum/random_map/automata/cave_system/mountains/breathable /datum/random_map/automata/cave_system/mountains iterations = 2 @@ -51,16 +60,12 @@ floor_type = /turf/simulated/floor/exoplanet/mineral use_area = FALSE -/datum/random_map/automata/cave_system/mountains/New(var/seed, var/tx, var/ty, var/tz, var/tlx, var/tly, var/do_not_apply, var/do_not_announce, var/never_be_priority = 0, var/used_area, var/_rock_color) - if(_rock_color) - rock_color = _rock_color +/datum/random_map/automata/cave_system/mountains/New(var/seed, var/tx, var/ty, var/tz, var/tlx, var/tly, var/do_not_apply, var/do_not_announce, var/never_be_priority = 0, var/used_area, var/datum/exoplanet_theme/_theme) + if(_theme) + planet_theme = _theme target_turf_type = world.turf floor_type = world.turf ..() -/datum/random_map/automata/cave_system/mountains/get_additional_spawns(value, var/turf/simulated/mineral/T) - if(rock_color) - T.color = rock_color - if(use_area) - if(istype(T)) - T.mined_turf = use_area.base_turf +/datum/random_map/automata/cave_system/mountains/get_additional_spawns(value, turf/T) + planet_theme.on_turf_generation(T, use_area) diff --git a/code/modules/overmap/exoplanets/turfs.dm b/code/modules/overmap/exoplanets/turfs.dm index 5d800af7401..e699570e0e7 100644 --- a/code/modules/overmap/exoplanets/turfs.dm +++ b/code/modules/overmap/exoplanets/turfs.dm @@ -17,7 +17,7 @@ else temperature = T0C //Must be done here, as light data is not fully carried over by ChangeTurf (but overlays are). - set_light(E.lightlevel, 0.1, 2) + set_light(MINIMUM_USEFUL_LIGHT_RANGE, E.lightlevel, COLOR_WHITE) if(E.planetary_area && istype(loc, world.area)) ChangeArea(src, E.planetary_area) ..() diff --git a/code/modules/random_map/automata/automata.dm b/code/modules/random_map/automata/automata.dm index 48d919541d2..65d8f68c98a 100644 --- a/code/modules/random_map/automata/automata.dm +++ b/code/modules/random_map/automata/automata.dm @@ -10,6 +10,8 @@ var/cell_dead_value = FLOOR_CHAR // As above for death. var/cell_threshold = 5 // Cell becomes alive with this many live neighbors. + var/datum/exoplanet_theme/planet_theme // Theme used for exoplanet automata + // Automata-specific procs and processing. /datum/random_map/automata/generate_map() for(var/iter = 1 to iterations) diff --git a/html/changelogs/johnwildkins-exofix.yml b/html/changelogs/johnwildkins-exofix.yml new file mode 100644 index 00000000000..64803851fc0 --- /dev/null +++ b/html/changelogs/johnwildkins-exofix.yml @@ -0,0 +1,7 @@ +author: JohnWildkins + +delete-after: True + +changes: + - bugfix: "Non-asteroid exoplanets now correctly have a chance to have ambient lighting." + - bugfix: "Exoplanet theming (rock coloration, etc.) now correctly applies to all exoplanet turfs."