mining turfs

This commit is contained in:
silicons
2022-05-14 07:25:46 -07:00
parent 53f48056ab
commit 0509907033
6 changed files with 87 additions and 89 deletions

View File

@@ -17,7 +17,6 @@ GLOBAL_LIST_EMPTY(turf_edge_cache)
var/list/flooring_cache = list()
/turf/simulated/floor/update_icon()
. = ..()
cut_overlays()
if(flooring)
@@ -91,6 +90,9 @@ var/list/flooring_cache = list()
if(isopenturf(above) && !istype(src, /turf/simulated/floor/outdoors)) // This won't apply to outdoor turfs since its assumed they don't have a ceiling anyways.
add_overlay(GLOB.no_ceiling_image)
// ..() has to be last to prevent trampling managed overlays
return ..()
/**
* welcome to the less modular but more sensical and efficient way to do icon edges
* instead of having every turf check, we only have turfs tha can spill onto others check, and apply their edges to other turfs

View File

@@ -32,11 +32,9 @@
update_icon()
/turf/simulated/wall/update_overlays()
. = ..()
// materrialless walls don't use this system.
if(!material)
return
return ..()
cut_overlays()
@@ -48,7 +46,7 @@
I = image('icons/turf/wall_masks.dmi', "[material.icon_base]fwall_open")
I.color = material.icon_colour
add_overlay(I)
return
return ..()
// modern smoothiing when
// sigh
@@ -98,3 +96,6 @@
overlay = damage_overlays.len
add_overlay(damage_overlays[overlay])
// ..() has to be last to prevent trampling managed overlays
return ..()

View File

@@ -94,8 +94,7 @@ VIRGO3B_TURF_CREATE(/turf/simulated/mineral/floor)
MAT_LEAD = 1))
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()
turf/simulated/mineral/rich/make_ore(var/rare_ore)
if(mineral || ignore_mapgen)
@@ -127,8 +126,7 @@ turf/simulated/mineral/rich/make_ore(var/rare_ore)
MAT_VERDANTIUM = 1))
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()
//Unsimulated
/turf/unsimulated/mineral/virgo3b
@@ -168,8 +166,7 @@ turf/simulated/mineral/rich/make_ore(var/rare_ore)
MAT_VERDANTIUM = 1))
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()
// Some turfs to make floors look better in centcom tram station.

View File

@@ -140,8 +140,7 @@ VIRGO2_TURF_CREATE(/turf/simulated/mineral)
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()
VIRGO2_TURF_CREATE(/turf/simulated/mineral/ignore_mapgen)
VIRGO2_TURF_CREATE(/turf/simulated/mineral/floor)

View File

@@ -1,6 +1,3 @@
var/list/mining_overlay_cache = list()
/**********************Mineral deposits**************************/
/turf/unsimulated/mineral
name = "impassable rock"
@@ -12,6 +9,7 @@ var/list/mining_overlay_cache = list()
name = "rock"
icon = 'icons/turf/walls.dmi'
icon_state = "rock"
smoothing_flags = SMOOTH_CUSTOM
var/rock_side_icon_state = "rock_side"
var/sand_icon_state = "asteroid"
var/rock_icon_state = "rock"
@@ -84,35 +82,30 @@ turf/simulated/mineral/floor/light_corner
/turf/simulated/mineral/proc/make_floor()
if(!density && !opacity)
return
density = 0
opacity = 0
density = FALSE
opacity = FALSE
recalc_atom_opacity()
reconsider_lights()
blocks_air = 0
blocks_air = FALSE
can_build_into_floor = TRUE
SSplanets.addTurf(src)
SSair.mark_for_update(src)
update_general()
QUEUE_SMOOTH_NEIGHBORS(src)
/turf/simulated/mineral/proc/make_wall()
if(density && opacity)
return
density = 1
opacity = 1
density = TRUE
opacity = TRUE
recalc_atom_opacity()
reconsider_lights()
blocks_air = 1
blocks_air = TRUE
can_build_into_floor = FALSE
SSplanets.removeTurf(src)
SSair.mark_for_update(src)
update_general()
/turf/simulated/mineral/proc/update_general()
if(!(flags & INITIALIZED))
update_icon(TRUE)
recalc_atom_opacity()
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING)
reconsider_lights()
if(air_master)
air_master.mark_for_update(src)
QUEUE_SMOOTH_NEIGHBORS(src)
/turf/simulated/mineral/Entered(atom/movable/M as mob|obj)
..()
@@ -123,25 +116,6 @@ turf/simulated/mineral/floor/light_corner
O.autoload(R)
return
/turf/simulated/mineral/proc/get_cached_border(var/cache_id, var/direction, var/icon_file, var/icon_state, var/offset = 32)
//Cache miss
if(!mining_overlay_cache["[cache_id]_[direction]"])
var/image/new_cached_image = image(icon_state, dir = direction, layer = ABOVE_TURF_LAYER)
switch(direction)
if(NORTH)
new_cached_image.pixel_y = offset
if(SOUTH)
new_cached_image.pixel_y = -offset
if(EAST)
new_cached_image.pixel_x = offset
if(WEST)
new_cached_image.pixel_x = -offset
mining_overlay_cache["[cache_id]_[direction]"] = new_cached_image
return new_cached_image
//Cache hit
return mining_overlay_cache["[cache_id]_[direction]"]
/turf/simulated/mineral/Initialize(mapload)
. = ..()
if(prob(20))
@@ -150,17 +124,28 @@ turf/simulated/mineral/floor/light_corner
dir = pick(GLOB.alldirs)
if(mineral)
if(density)
MineralSpread(mapload)
MineralSpread()
else
UpdateMineral(!mapload)
else
update_icon(!mapload)
UpdateMineral() // this'll work because we're INITIALIZED
if(!mapload)
QUEUE_SMOOTH_NEIGHBORS(src)
/turf/simulated/mineral/update_icon(var/update_neighbors)
/* custom smoothing code */
/turf/simulated/mineral/find_type_in_direction(direction)
var/turf/T = get_step(src, direction)
if(!T)
return NULLTURF_BORDER
return T.density? ADJ_FOUND : NO_ADJ_FOUND
/turf/simulated/mineral/custom_smooth(dirs)
smoothing_junction = dirs
update_icon()
/turf/simulated/mineral/update_icon()
cut_overlays()
//We are a wall (why does this system work like this??)
// todo: refactor this shitheap because this is pants on fucking head awful
if(density)
if(mineral)
name = "[mineral.display_name] deposit"
@@ -170,17 +155,25 @@ turf/simulated/mineral/floor/light_corner
icon = 'icons/turf/walls.dmi'
icon_state = rock_icon_state
if(smoothing_junction & NORTH_JUNCTION)
add_overlay(get_cached_border(rock_side_icon_state, NORTH, icon, rock_side_icon_state))
if(smoothing_junction & SOUTH_JUNCTION)
add_overlay(get_cached_border(rock_side_icon_state, SOUTH, icon, rock_side_icon_state))
if(smoothing_junction & EAST_JUNCTION)
add_overlay(get_cached_border(rock_side_icon_state, EAST, icon, rock_side_icon_state))
if(smoothing_junction & WEST_JUNCTION)
add_overlay(get_cached_border(rock_side_icon_state, WEST, icon, rock_side_icon_state))
//Apply overlays if we should have borders
for(var/direction in GLOB.cardinal)
var/turf/T = get_step(src,direction)
if(istype(T) && !T.density)
add_overlay(get_cached_border(rock_side_icon_state,direction,icon,rock_side_icon_state))
if(archaeo_overlay)
add_overlay(archaeo_overlay)
if(excav_overlay)
add_overlay(excav_overlay)
if(archaeo_overlay)
add_overlay(archaeo_overlay)
if(excav_overlay)
add_overlay(excav_overlay)
//We are a sand floor
else
@@ -190,26 +183,35 @@ turf/simulated/mineral/floor/light_corner
if(sand_dug)
add_overlay("dug_overlay")
//Apply overlays if there's space
for(var/direction in GLOB.cardinal)
if(istype(get_step(src, direction), /turf/space) && !istype(get_step(src, direction), /turf/space/cracked_asteroid))
add_overlay(get_cached_border("asteroid_edge",direction,icon,"asteroid_edges", 0))
//Or any time
else
var/turf/T = get_step(src, direction)
if(istype(T) && T.density)
add_overlay(get_cached_border(rock_side_icon_state,direction,'icons/turf/walls.dmi',rock_side_icon_state))
if(overlay_detail)
add_overlay('icons/turf/flooring/decals.dmi',overlay_detail)
if(update_neighbors)
for(var/direction in GLOB.alldirs)
if(istype(get_step(src, direction), /turf/simulated/mineral))
var/turf/simulated/mineral/M = get_step(src, direction)
M.update_icon()
// ..() has to be last to prevent trampling managed overlays
return ..()
GLOBAL_LIST_EMPTY(mining_overlay_cache)
/turf/simulated/mineral/proc/get_cached_border(cache_id, direction, icon_file, icon_state)
cache_id = "[cached_id]_[direction]"
//Cache miss
if(!GLOB.mining_overlay_cache[cache_id])
var/image/new_cached_image = image(icon_state, dir = turn(direction, 180), layer = ABOVE_TURF_LAYER)
switch(direction)
if(NORTH)
new_cached_image.pixel_y = 32
if(SOUTH)
new_cached_image.pixel_y = -32
if(EAST)
new_cached_image.pixel_x = 32
if(WEST)
new_cached_image.pixel_x = -32
GLOB.mining_overlay_cache[cache_id] = new_cached_image
return new_cached_image
//Cache hit
return GLOB.mining_overlay_cache[cache_id]
/* smoothing end */
/turf/simulated/mineral/ex_act(severity)
@@ -272,21 +274,22 @@ turf/simulated/mineral/floor/light_corner
if(istype(M.selected,/obj/item/mecha_parts/mecha_equipment/tool/drill))
M.selected.action(src)
/turf/simulated/mineral/proc/MineralSpread(mapload)
UpdateMineral(!mapload)
/turf/simulated/mineral/proc/MineralSpread()
UpdateMineral()
if(mineral && mineral.spread)
for(var/trydir in GLOB.cardinal)
if(prob(mineral.spread_chance))
var/turf/simulated/mineral/target_turf = get_step(src, trydir)
if(istype(target_turf) && target_turf.density && !target_turf.mineral)
target_turf.mineral = mineral
target_turf.MineralSpread(mapload)
target_turf.MineralSpread()
/turf/simulated/mineral/proc/UpdateMineral(update_neighbors)
if(!(flags & INITIALIZED))
return // /Initialize() will handle us
clear_ore_effects()
if(mineral && density)
new /obj/effect/mineral(src, mineral)
update_icon(update_neighbors)
//Not even going to touch this pile of spaghetti
/turf/simulated/mineral/attackby(obj/item/W as obj, mob/user as mob)
@@ -606,7 +609,7 @@ turf/simulated/mineral/floor/light_corner
sand_dug = 1
for(var/i=0;i<5;i++)
new/obj/item/ore/glass(src)
update_icon()
QUEUE_SMOOTH(src)
return
if (mineral && mineral.result_amount)
@@ -639,7 +642,6 @@ turf/simulated/mineral/floor/light_corner
new /obj/structure/closet/crate/secure/loot(src)
make_floor()
update_icon(1)
/turf/simulated/mineral/proc/excavate_find(var/is_clean = 0, var/datum/find/F)
//with skill and luck, players can cleanly extract finds
@@ -708,5 +710,4 @@ turf/simulated/mineral/floor/light_corner
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()

View File

@@ -65,8 +65,7 @@
MAT_URANIUM = 5))
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()
/turf/simulated/mineral/rich/make_ore(var/rare_ore)
if(mineral || ignore_mapgen)
@@ -100,8 +99,7 @@
MAT_VERDANTIUM = 1))
if(mineral_name && (mineral_name in GLOB.ore_data))
mineral = GLOB.ore_data[mineral_name]
if(flags & INITIALIZED)
UpdateMineral()
UpdateMineral()
//Unsimulated
/turf/unsimulated/wall/planetary/triumph