Skip to content

Commit

Permalink
Merge pull request #22 from MistakeNot4892/cruxflood
Browse files Browse the repository at this point in the history
Crux map flooding update
  • Loading branch information
MistakeNot4892 authored Feb 9, 2024
2 parents a25d891 + bad6701 commit 4fc7054
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 309 deletions.
3 changes: 2 additions & 1 deletion code/controllers/subsystems/fluids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SUBSYSTEM_DEF(fluids)
wait = 1 SECOND
priority = SS_PRIORITY_FLUIDS
flags = SS_NO_INIT
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT // So we can flush our queued activity during lobby setup on ocean maps.

var/tmp/list/water_sources = list()
var/tmp/fluid_sources_copied_yet = FALSE
Expand Down Expand Up @@ -84,7 +85,7 @@ SUBSYSTEM_DEF(fluids)
continue
checked_targets[neighbor] = TRUE
flooded_a_neighbor = TRUE
neighbor.add_fluid(/decl/material/liquid/water, FLUID_MAX_DEPTH)
neighbor.add_fluid(current_turf.flooded, FLUID_MAX_DEPTH)

if(!flooded_a_neighbor)
REMOVE_ACTIVE_FLUID_SOURCE(current_turf)
Expand Down
14 changes: 13 additions & 1 deletion code/game/objects/effects/fluids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,19 @@
fluid_initial = 10

// Permaflood overlay.
var/global/obj/effect/flood/flood_object = new
var/global/list/flood_type_overlay_cache = list()
/proc/get_flood_overlay(fluid_type)
if(!ispath(fluid_type, /decl/material))
return null
if(!global.flood_type_overlay_cache[fluid_type])
var/decl/material/fluid_decl = GET_DECL(fluid_type)
var/obj/effect/flood/new_flood = new
new_flood.color = fluid_decl.color
new_flood.alpha = round(fluid_decl.min_fluid_opacity + ((fluid_decl.max_fluid_opacity - fluid_decl.min_fluid_opacity) * 0.5))
global.flood_type_overlay_cache[fluid_type] = new_flood
return new_flood
return global.flood_type_overlay_cache[fluid_type]

/obj/effect/flood
name = ""
icon = 'icons/effects/liquids.dmi'
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/exterior/exterior_concrete.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var/global/exterior_broken_states = icon_states('icons/turf/exterior/broken.dmi'
return FALSE

/turf/exterior/concrete/flooded
flooded = TRUE
flooded = /decl/material/liquid/water
color = COLOR_LIQUID_WATER

/turf/exterior/concrete/Initialize(var/ml)
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/exterior/exterior_mud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
return dug ? null : list(/obj/item/stack/material/ore/clay = list(3, 2))

/turf/exterior/clay/flooded
flooded = TRUE
flooded = /decl/material/liquid/water

/turf/exterior/mud
name = "mud"
Expand All @@ -19,7 +19,7 @@
footstep_type = /decl/footsteps/mud

/turf/exterior/mud/flooded
flooded = TRUE
flooded = /decl/material/liquid/water

/turf/exterior/dry
name = "dry mud"
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/exterior/exterior_ocean.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
name = "open ocean"
icon = 'icons/turf/exterior/ocean_deep.dmi'
icon_state = "0"
flooded = TRUE
flooded = /decl/material/liquid/water
icon_edge_layer = EXT_EDGE_OCEAN
2 changes: 1 addition & 1 deletion code/game/turfs/exterior/exterior_seafloor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
return dug ? null : list(/obj/item/stack/material/ore/sand = list(3, 2))

/turf/exterior/seafloor/flooded
flooded = TRUE
flooded = /decl/material/liquid/water
color = COLOR_LIQUID_WATER

/turf/exterior/seafloor/Initialize()
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/exterior/exterior_wall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var/global/list/natural_walls = list()
var/static/list/exterior_wall_shine_cache = list()

/turf/exterior/wall/flooded
flooded = TRUE
flooded = /decl/material/liquid/water
color = COLOR_LIQUID_WATER

/turf/exterior/wall/examine(mob/user, distance, infix, suffix)
Expand Down
9 changes: 5 additions & 4 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@
if (z_flags & ZM_MIMIC_BELOW)
setup_zmimic(mapload)

if(flooded && !density)
make_flooded(TRUE)

if(flooded)
set_flooded(flooded, TRUE, skip_vis_contents_update = TRUE, mapload = mapload)
refresh_vis_contents()

return INITIALIZE_HINT_NORMAL
Expand Down Expand Up @@ -542,7 +541,9 @@
if(weather)
LAZYADD(., weather)
if(flooded)
LAZYADD(., global.flood_object)
var/flood_object = get_flood_overlay(flooded)
if(flood_object)
LAZYADD(., flood_object)

/**Whether we can place a cable here
* If you cannot build a cable will return an error code explaining why you cannot.
Expand Down
7 changes: 2 additions & 5 deletions code/game/turfs/turf_changing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@
else if(old_fire)
qdel(old_fire)

if(isnull(W.flooded) && old_flooded != W.flooded)
if(old_flooded && !W.density)
W.make_flooded()
else
W.make_unflooded()
if(old_flooded != W.flooded)
set_flooded(old_flooded && !W.density)

// Raise appropriate events.
W.post_change()
Expand Down
31 changes: 21 additions & 10 deletions code/game/turfs/turf_fluids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,31 @@
/turf/return_fluid()
return (locate(/obj/effect/fluid) in contents)

/turf/proc/make_unflooded(var/force)
if(force || flooded)
flooded = FALSE
REMOVE_ACTIVE_FLUID_SOURCE(src)
remove_vis_contents(src, global.flood_object)
fluid_update() // We are now floodable, so wake up our neighbors.
/turf/proc/set_flooded(new_flooded, force = FALSE, skip_vis_contents_update = FALSE, mapload = FALSE)

// Don't do unnecessary work.
if(!simulated || (!force && new_flooded == flooded))
return

/turf/proc/make_flooded(var/force)
if(force || !flooded)
flooded = TRUE
// Remove our old overlay if necessary.
if(flooded && new_flooded != flooded && !skip_vis_contents_update)
var/flood_object = get_flood_overlay(flooded)
if(flood_object)
remove_vis_contents(src, flood_object)

// Set our flood state.
flooded = new_flooded
if(flooded)
for(var/obj/effect/fluid/fluid in src)
qdel(fluid)
ADD_ACTIVE_FLUID_SOURCE(src)
add_vis_contents(src, global.flood_object)
if(!skip_vis_contents_update)
var/flood_object = get_flood_overlay(flooded)
if(flood_object)
add_vis_contents(src, flood_object)
else if(!mapload)
REMOVE_ACTIVE_FLUID_SOURCE(src)
fluid_update() // We are now floodable, so wake up our neighbors.

/turf/is_flooded(var/lying_mob, var/absolute)
return (flooded || (!absolute && check_fluid_depth(lying_mob ? FLUID_OVER_MOB_HEAD : FLUID_DEEP)))
Expand Down
4 changes: 4 additions & 0 deletions code/game/turfs/unsimulated/floor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
icon = 'icons/turf/walls.dmi'
icon_state = "rockvault"

/turf/unsimulated/mask/flooded
flooded = /decl/material/liquid/water
color = COLOR_LIQUID_WATER

/turf/unsimulated/floor/rescue_base
icon_state = "asteroidfloor"

Expand Down
4 changes: 2 additions & 2 deletions code/modules/multiz/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

/turf/simulated/open/flooded
name = "open water"
flooded = TRUE
flooded = /decl/material/liquid/water

/turf/simulated/open/update_dirt()
return 0
Expand Down Expand Up @@ -130,7 +130,7 @@

/turf/exterior/open/flooded
name = "open water"
flooded = TRUE
flooded = /decl/material/liquid/water

/turf/exterior/open/Entered(var/atom/movable/mover, var/atom/oldloc)
..()
Expand Down
3 changes: 3 additions & 0 deletions code/modules/multiz/turf_mimic_edge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@
return
shared_transition_edge_bumped(src, AM, mimic_z)

/turf/unsimulated/mimic_edge/transition/flooded
flooded = /decl/material/liquid/water

/turf/unsimulated/mimic_edge/transition/setup_mimic()
var/list/coord = shared_transition_edge_get_coordinates_turf_to_mimic(src, shared_transition_edge_get_valid_level_data(src))
set_mimic_turf(coord[1], coord[2], coord[3])
Expand Down
1 change: 1 addition & 0 deletions maps/crux/areas/_areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@
)

/area/crux
has_gravity = TRUE
Loading

0 comments on commit 4fc7054

Please sign in to comment.