Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaking flooring procs to allow for multiple flooring layers. #4720

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/game/machinery/CableLayer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
if(istype(new_turf, /turf/floor))
var/turf/floor/T = new_turf
if(!T.is_plating())
T.set_flooring(null, place_product = !T.is_floor_damaged())
T.clear_flooring(null, place_product = !T.is_floor_damaged())
return new_turf.is_plating()

/obj/machinery/cablelayer/proc/layCable(var/turf/new_turf,var/M_Dir)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/floorlayer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
if(istype(new_turf, /turf/floor))
var/turf/floor/T = new_turf
if(!T.is_plating())
T.set_flooring(null, place_product = !T.is_floor_damaged())
T.clear_flooring(null, place_product = !T.is_floor_damaged())
return new_turf.is_plating()

/obj/machinery/floorlayer/proc/TakeNewStack()
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/pipe/pipelayer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
if(istype(new_turf, /turf/floor))
var/turf/floor/T = new_turf
if(!T.is_plating())
T.set_flooring(null, place_product = !T.is_floor_damaged())
T.clear_flooring(null, place_product = !T.is_floor_damaged())
return new_turf.is_plating()

/obj/machinery/pipelayer/proc/layPipe(var/turf/w_turf,var/M_Dir,var/old_dir)
Expand Down
12 changes: 6 additions & 6 deletions code/game/turfs/flooring/_flooring.dm
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ var/global/list/flooring_cache = list()
if(!user.do_skilled(remove_timer, SKILL_CONSTRUCTION, floor) || floor.get_topmost_flooring() != src)
return TRUE
to_chat(user, SPAN_NOTICE("You remove the [get_surface_descriptor()] with \the [item]."))
floor.set_flooring(null, place_product = TRUE)
floor.remove_flooring(floor.get_topmost_flooring(), place_product = TRUE)
playsound(floor, 'sound/items/Deconstruct.ogg', 80, 1)
return TRUE

Expand All @@ -313,21 +313,21 @@ var/global/list/flooring_cache = list()
if(floor.get_topmost_flooring() != src)
return
to_chat(user, SPAN_NOTICE("You remove the broken [get_surface_descriptor()]."))
floor.set_flooring(null)
floor.remove_flooring(floor.get_topmost_flooring())
else if(flooring_flags & TURF_IS_FRAGILE)
if(!user.do_skilled(remove_timer, SKILL_CONSTRUCTION, floor, 0.15))
return TRUE
if(floor.get_topmost_flooring() != src)
return
to_chat(user, SPAN_DANGER("You forcefully pry off the [get_surface_descriptor()], destroying them in the process."))
floor.set_flooring(null)
floor.remove_flooring(floor.get_topmost_flooring())
else if(flooring_flags & TURF_REMOVE_CROWBAR)
if(!user.do_skilled(remove_timer, SKILL_CONSTRUCTION, floor))
return TRUE
if(floor.get_topmost_flooring() != src)
return
to_chat(user, SPAN_NOTICE("You lever off the [get_surface_descriptor()]."))
floor.set_flooring(null, place_product = TRUE)
floor.remove_flooring(floor.get_topmost_flooring(), place_product = TRUE)
else
return
playsound(floor, 'sound/items/Crowbar.ogg', 80, 1)
Expand All @@ -339,15 +339,15 @@ var/global/list/flooring_cache = list()
if(!user.do_skilled(remove_timer, SKILL_CONSTRUCTION, floor) || floor.get_topmost_flooring() != src)
return TRUE
to_chat(user, SPAN_NOTICE("You unscrew and remove the [get_surface_descriptor()]."))
floor.set_flooring(null, place_product = TRUE)
floor.remove_flooring(floor.get_topmost_flooring(), place_product = TRUE)
playsound(floor, 'sound/items/Screwdriver.ogg', 80, 1)
return TRUE

if(IS_WRENCH(item) && (flooring_flags & TURF_REMOVE_WRENCH))
if(!user.do_skilled(remove_timer, SKILL_CONSTRUCTION, floor) || floor.get_topmost_flooring() != src)
return TRUE
to_chat(user, SPAN_NOTICE("You unwrench and remove the [get_surface_descriptor()]."))
floor.set_flooring(null, place_product = TRUE)
floor.remove_flooring(floor.get_topmost_flooring(), place_product = TRUE)
playsound(floor, 'sound/items/Ratchet.ogg', 80, 1)
return TRUE

Expand Down
6 changes: 3 additions & 3 deletions code/game/turfs/flooring/flooring_grass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

/decl/flooring/grass/fire_act(turf/floor/target, datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(target.get_topmost_flooring() == src && (exposed_temperature > T0C + 200 && prob(5)) || exposed_temperature > T0C + 1000)
target.set_flooring(null)
target.remove_flooring(target.get_topmost_flooring())
return TRUE
return ..()

/decl/flooring/grass/handle_turf_digging(turf/floor/target)
target.set_flooring(null)
target.remove_flooring(target.get_topmost_flooring())
return FALSE

/decl/flooring/grass/wild
Expand All @@ -42,7 +42,7 @@
if(IS_KNIFE(item) && harvestable && istype(floor_material) && floor_material.dug_drop_type)
if(item.do_tool_interaction(TOOL_KNIFE, user, floor, 3 SECONDS, start_message = "harvesting", success_message = "harvesting") && !QDELETED(floor) && floor.get_topmost_flooring() == src)
new floor_material.dug_drop_type(floor, rand(2,5))
floor.set_flooring(/decl/flooring/grass)
floor.remove_flooring(src)
return TRUE
return ..()

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/flooring/flooring_snow.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/decl/flooring/snow/fire_act(turf/floor/target, datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(!target.reagents?.total_volume)
if(target.get_topmost_flooring() == src)
target.set_flooring(/decl/flooring/permafrost)
target.remove_flooring(src)
else if(target.get_base_flooring() == src)
target.set_base_flooring(/decl/flooring/permafrost)
return
Expand Down
133 changes: 4 additions & 129 deletions code/game/turfs/floors/_floor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
// Flooring data.
var/floor_icon_state_override

// TODO:
VAR_PROTECTED/decl/flooring/_base_flooring = /decl/flooring/plating
VAR_PROTECTED/decl/flooring/_flooring

var/const/TRENCH_DEPTH_PER_ACTION = 100

/turf/floor/Initialize(var/ml, var/floortype)
Expand All @@ -39,10 +35,11 @@

set_turf_materials(floor_material, skip_update = TRUE)

if(!floortype && ispath(_flooring))
if(!floortype && (ispath(_flooring) || islist(_flooring)))
floortype = _flooring
if(floortype)
set_flooring(GET_DECL(floortype), skip_update = TRUE)
_flooring = null
set_flooring(floortype, skip_update = TRUE)

if(fill_reagent_type && get_physical_height() < 0)
add_to_reagents(fill_reagent_type, abs(height), phase = MAT_PHASE_LIQUID)
Expand All @@ -66,17 +63,14 @@
. = ..()

/turf/floor/Destroy()
set_flooring(null)
clear_flooring()
if(is_processing)
STOP_PROCESSING(SSobj, src)
return ..()

/turf/floor/can_climb_from_below(var/mob/climber)
return TRUE

/turf/floor/proc/has_flooring()
return istype(_flooring)

/turf/floor/is_plating()
if(density)
return FALSE
Expand All @@ -96,118 +90,6 @@
if(!QDELETED(src) && fill_reagent_type && my_height < 0 && !QDELETED(reagents) && reagents.total_volume < abs(my_height))
add_to_reagents(fill_reagent_type, abs(my_height) - reagents.total_volume)

/turf/floor/proc/set_base_flooring(new_base_flooring, skip_update)
if(ispath(new_base_flooring, /decl/flooring))
new_base_flooring = GET_DECL(new_base_flooring)
else if(!istype(new_base_flooring, /decl/flooring))
new_base_flooring = null
if(_base_flooring == new_base_flooring)
return
_base_flooring = new_base_flooring
if(!_base_flooring) // We can never have a null base flooring.
_base_flooring = GET_DECL(initial(_base_flooring)) || GET_DECL(/decl/flooring/plating)
update_from_flooring(skip_update)

/turf/floor/proc/get_base_flooring()
RETURN_TYPE(/decl/flooring)
if(ispath(_base_flooring))
return GET_DECL(_base_flooring)
return _base_flooring

/turf/floor/proc/get_topmost_flooring()
RETURN_TYPE(/decl/flooring)
if(isnull(_flooring))
return get_base_flooring()
if(ispath(_flooring))
return GET_DECL(_flooring)
return _flooring

/turf/floor/proc/set_flooring(var/decl/flooring/newflooring, skip_update, place_product)

if(ispath(newflooring, /decl/flooring))
newflooring = GET_DECL(newflooring)
else if(!istype(newflooring, /decl/flooring))
newflooring = null

if(_flooring == newflooring)
return FALSE

if(istype(_flooring))

LAZYCLEARLIST(decals)
for(var/obj/effect/decal/writing/W in src)
qdel(W)

_flooring.on_flooring_remove(src)
if(_flooring.build_type && place_product)
// If build type uses material stack, check for it
// Because material stack uses different arguments
// And we need to use build material to spawn stack
if(ispath(_flooring.build_type, /obj/item/stack/material))
var/decl/material/M = GET_DECL(_flooring.build_material)
if(!M)
CRASH("[src] at ([x], [y], [z]) cannot create stack because it has a bad build_material path: '[_flooring.build_material]'")
M.create_object(src, _flooring.build_cost, _flooring.build_type)
else
var/obj/item/stack/tile/new_tile = new _flooring.build_type(src)
if(_flooring.can_paint && paint_color)
new_tile.paint_color = paint_color

if(_flooring.has_environment_proc && is_processing)
STOP_PROCESSING(SSobj, src)

_flooring = null
set_floor_broken(skip_update = TRUE)
set_floor_burned()

else if(is_processing)

STOP_PROCESSING(SSobj, src)

_flooring = newflooring
floor_icon_state_override = null
update_from_flooring(skip_update)

return TRUE

/turf/floor/proc/update_from_flooring(skip_update)

var/decl/flooring/copy_from = get_topmost_flooring()
if(!istype(copy_from))
return // this should never be the case

update_floor_strings()

gender = copy_from.gender
layer = copy_from.floor_layer
turf_flags = copy_from.turf_flags
z_flags = copy_from.z_flags

if(copy_from.turf_light_range || copy_from.turf_light_power || copy_from.turf_light_color)
set_light(copy_from.turf_light_range, copy_from.turf_light_power, copy_from.turf_light_color)
else
set_light(0)

if(z_flags & ZM_MIMIC_BELOW)
enable_zmimic(z_flags)
else
disable_zmimic()

if(copy_from.has_environment_proc && !is_processing)
START_PROCESSING(SSobj, src)

levelupdate()

for(var/obj/effect/footprints/print in src)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self to reimplement this.

qdel(print)

if(!skip_update)
update_icon()
for(var/dir in global.alldirs)
var/turf/neighbor = get_step_resolving_mimic(src, dir)
if(istype(neighbor))
neighbor.update_icon()

/turf/floor/can_engrave()
var/decl/flooring/flooring = get_topmost_flooring()
return flooring ? flooring.can_engrave : can_engrave
Expand Down Expand Up @@ -264,13 +146,6 @@
return my_material.color
return color

/turf/floor/proc/get_all_flooring()
. = list()
if(istype(_flooring))
. += _flooring
if(istype(_base_flooring))
. += _base_flooring

/turf/floor/Process()
for(var/decl/flooring/flooring in get_all_flooring())
if(flooring.has_environment_proc)
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/floors/floor_acts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if(!is_floor_burned() && prob(5))
burn_tile(exposed_temperature)
else if(temp_destroy && exposed_temperature >= (temp_destroy + 100) && prob(1) && has_flooring())
set_flooring(null) //destroy the tile, exposing plating
remove_flooring(get_topmost_flooring()) //destroy the tile, exposing plating
burn_tile(exposed_temperature)
return ..()

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/floors/floor_damage.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/turf/floor/proc/break_tile_to_plating()
if(has_flooring())
set_flooring(null)
clear_flooring()
break_tile()

/turf/floor/proc/break_tile()
Expand Down
Loading