mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Rewrite mine turf overlay adding
Stop adding overlays on adjacent turfs. Just add them on yourself, and push them sideways.
This commit is contained in:
@@ -97,6 +97,25 @@ var/list/mining_overlay_cache = list()
|
||||
attackby(O, 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()
|
||||
. = ..()
|
||||
if(prob(20))
|
||||
@@ -111,8 +130,9 @@ var/list/mining_overlay_cache = list()
|
||||
|
||||
/turf/simulated/mineral/update_icon(var/update_neighbors)
|
||||
|
||||
overlays.Cut()
|
||||
cut_overlays()
|
||||
|
||||
//We are a wall (why does this system work like this??)
|
||||
if(density)
|
||||
if(mineral)
|
||||
name = "[mineral.display_name] deposit"
|
||||
@@ -122,47 +142,40 @@ var/list/mining_overlay_cache = list()
|
||||
icon = 'icons/turf/walls.dmi'
|
||||
icon_state = "rock"
|
||||
|
||||
//Apply overlays if we should have borders
|
||||
for(var/direction in cardinal)
|
||||
var/turf/T = get_step(src,direction)
|
||||
if(istype(T) && !T.density)
|
||||
var/place_dir = turn(direction, 180)
|
||||
if(!mining_overlay_cache["rock_side_[place_dir]"])
|
||||
mining_overlay_cache["rock_side_[place_dir]"] = image('icons/turf/walls.dmi', "rock_side", dir = place_dir)
|
||||
T.overlays += mining_overlay_cache["rock_side_[place_dir]"]
|
||||
add_overlay(get_cached_border("rock_side",direction,icon,"rock_side"))
|
||||
|
||||
if(archaeo_overlay)
|
||||
overlays += archaeo_overlay
|
||||
add_overlay(archaeo_overlay)
|
||||
|
||||
if(excav_overlay)
|
||||
overlays += excav_overlay
|
||||
add_overlay(excav_overlay)
|
||||
|
||||
//We are a sand floor
|
||||
else
|
||||
|
||||
name = "sand"
|
||||
icon = 'icons/turf/flooring/asteroid.dmi'
|
||||
icon_state = "asteroid"
|
||||
|
||||
if(sand_dug)
|
||||
if(!mining_overlay_cache["dug_overlay"])
|
||||
mining_overlay_cache["dug_overlay"] = image('icons/turf/flooring/asteroid.dmi', "dug_overlay")
|
||||
overlays += mining_overlay_cache["dug_overlay"]
|
||||
add_overlay("dug_overlay")
|
||||
|
||||
//Apply overlays if there's space
|
||||
for(var/direction in cardinal)
|
||||
if(istype(get_step(src, direction), /turf/space) && !istype(get_step(src, direction), /turf/space/cracked_asteroid))
|
||||
if(!mining_overlay_cache["asteroid_edge_[direction]"])
|
||||
mining_overlay_cache["asteroid_edge_[direction]"] = image('icons/turf/flooring/asteroid.dmi', "asteroid_edges", dir = direction)
|
||||
overlays += mining_overlay_cache["asteroid_edge_[direction]"]
|
||||
add_overlay(get_cached_border("asteroid_edge",direction,icon,"asteroid_edges", 0))
|
||||
|
||||
//Or any time
|
||||
else
|
||||
var/turf/simulated/mineral/M = get_step(src, direction)
|
||||
if(istype(M) && M.density)
|
||||
if(!mining_overlay_cache["rock_side_[direction]"])
|
||||
mining_overlay_cache["rock_side_[direction]"] = image('icons/turf/walls.dmi', "rock_side", dir = direction)
|
||||
overlays += mining_overlay_cache["rock_side_[direction]"]
|
||||
add_overlay(get_cached_border("rock_side",direction,'icons/turf/walls.dmi',"rock_side"))
|
||||
|
||||
if(overlay_detail)
|
||||
|
||||
if(!mining_overlay_cache["decal_[overlay_detail]"])
|
||||
mining_overlay_cache["decal_[overlay_detail]"] = image(icon = 'icons/turf/flooring/decals.dmi', icon_state = overlay_detail)
|
||||
overlays += mining_overlay_cache["decal_[overlay_detail]"]
|
||||
add_overlay('icons/turf/flooring/decals.dmi',overlay_detail)
|
||||
|
||||
if(update_neighbors)
|
||||
for(var/direction in alldirs)
|
||||
@@ -414,12 +427,13 @@ var/list/mining_overlay_cache = list()
|
||||
if(!archaeo_overlay && finds && finds.len)
|
||||
var/datum/find/F = finds[1]
|
||||
if(F.excavation_required <= excavation_level + F.view_range)
|
||||
cut_overlay(archaeo_overlay)
|
||||
archaeo_overlay = "overlay_archaeo[rand(1,3)]"
|
||||
updateIcon = 1
|
||||
add_overlay(archaeo_overlay)
|
||||
|
||||
else if(archaeo_overlay && (!finds || !finds.len))
|
||||
cut_overlay(archaeo_overlay)
|
||||
archaeo_overlay = null
|
||||
updateIcon = 1
|
||||
|
||||
//there's got to be a better way to do this
|
||||
var/update_excav_overlay = 0
|
||||
@@ -436,8 +450,9 @@ var/list/mining_overlay_cache = list()
|
||||
//update overlays displaying excavation level
|
||||
if( !(excav_overlay && excavation_level > 0) || update_excav_overlay )
|
||||
var/excav_quadrant = round(excavation_level / 25) + 1
|
||||
cut_overlay(excav_overlay)
|
||||
excav_overlay = "overlay_excv[excav_quadrant]_[rand(1,3)]"
|
||||
updateIcon = 1
|
||||
add_overlay(excav_overlay)
|
||||
|
||||
if(updateIcon)
|
||||
update_icon()
|
||||
|
||||
Reference in New Issue
Block a user