Revert "Singletons + refactor of /datum/observ (#15487)" (#15515)

This commit is contained in:
Matt Atlas
2023-01-05 19:21:22 +01:00
committed by GitHub
parent 34b1bcd055
commit b1869884c1
506 changed files with 7214 additions and 7561 deletions

View File

@@ -1,15 +1,15 @@
/var/singleton/overmap_event_handler/overmap_event_handler = new()
/var/decl/overmap_event_handler/overmap_event_handler = new()
/singleton/overmap_event_handler
/decl/overmap_event_handler
var/list/hazard_by_turf
var/list/datum/event/ship_events
/singleton/overmap_event_handler/New()
/decl/overmap_event_handler/New()
..()
hazard_by_turf = list()
ship_events = list()
/singleton/overmap_event_handler/proc/create_events(var/z_level, var/overmap_size, var/number_of_events)
/decl/overmap_event_handler/proc/create_events(var/z_level, var/overmap_size, var/number_of_events)
// Acquire the list of not-yet utilized overmap turfs on this Z-level
var/list/candidate_turfs = block(locate(OVERMAP_EDGE, OVERMAP_EDGE, z_level),locate(overmap_size - OVERMAP_EDGE, overmap_size - OVERMAP_EDGE,z_level))
candidate_turfs = where(candidate_turfs, /proc/can_not_locate, /obj/effect/overmap/visitable)
@@ -29,7 +29,7 @@
qdel(datum_spawn)//idk help how do I do this better?
/singleton/overmap_event_handler/proc/acquire_event_turfs(var/number_of_turfs, var/distance_from_origin, var/list/candidate_turfs, var/continuous = TRUE)
/decl/overmap_event_handler/proc/acquire_event_turfs(var/number_of_turfs, var/distance_from_origin, var/list/candidate_turfs, var/continuous = TRUE)
number_of_turfs = min(number_of_turfs, candidate_turfs.len)
candidate_turfs = candidate_turfs.Copy() // Not this proc's responsibility to adjust the given lists
@@ -52,7 +52,7 @@
return selected_turfs
/singleton/overmap_event_handler/proc/get_random_neighbour(var/turf/origin_turf, var/list/candidate_turfs, var/continuous = TRUE, var/range)
/decl/overmap_event_handler/proc/get_random_neighbour(var/turf/origin_turf, var/list/candidate_turfs, var/continuous = TRUE, var/range)
var/fitting_turfs
if(continuous)
fitting_turfs = origin_turf.CardinalTurfs(FALSE)
@@ -63,7 +63,7 @@
if(T in candidate_turfs)
return T
/singleton/overmap_event_handler/proc/start_hazard(var/obj/effect/overmap/visitable/ship/ship, var/obj/effect/overmap/event/hazard)//make these accept both hazards or events
/decl/overmap_event_handler/proc/start_hazard(var/obj/effect/overmap/visitable/ship/ship, var/obj/effect/overmap/event/hazard)//make these accept both hazards or events
if(!(ship in ship_events))
ship_events += ship
@@ -79,14 +79,14 @@
E.vars["victim"] = ship
LAZYADD(ship_events[ship], E)
/singleton/overmap_event_handler/proc/stop_hazard(var/obj/effect/overmap/visitable/ship/ship, var/obj/effect/overmap/event/hazard)
/decl/overmap_event_handler/proc/stop_hazard(var/obj/effect/overmap/visitable/ship/ship, var/obj/effect/overmap/event/hazard)
for(var/event_type in hazard.events)
var/datum/event/E = is_event_active(ship,event_type,hazard.difficulty)
if(E)
E.kill()
LAZYREMOVE(ship_events[ship], E)
/singleton/overmap_event_handler/proc/is_event_active(var/ship, var/event_type, var/severity)
/decl/overmap_event_handler/proc/is_event_active(var/ship, var/event_type, var/severity)
if(!ship_events[ship])
return
var/list/active_ship_events = ship_events[ship]
@@ -94,7 +94,7 @@
if(E.type == event_type && E.severity == severity)
return E
/singleton/overmap_event_handler/proc/on_turf_entered(var/turf/new_loc, var/obj/effect/overmap/visitable/ship/ship, var/old_loc)
/decl/overmap_event_handler/proc/on_turf_entered(var/turf/new_loc, var/obj/effect/overmap/visitable/ship/ship, var/old_loc)
if(!istype(ship))
return
if(new_loc == old_loc)
@@ -103,7 +103,7 @@
for(var/obj/effect/overmap/event/E in hazard_by_turf[new_loc])
start_hazard(ship, E)
/singleton/overmap_event_handler/proc/on_turf_exited(var/turf/old_loc, var/obj/effect/overmap/visitable/ship/ship, var/new_loc)
/decl/overmap_event_handler/proc/on_turf_exited(var/turf/old_loc, var/obj/effect/overmap/visitable/ship/ship, var/new_loc)
if(!istype(ship))
return
if(new_loc == old_loc)
@@ -114,7 +114,7 @@
continue
stop_hazard(ship,E)
/singleton/overmap_event_handler/proc/update_hazards(var/turf/T)//catch all updater
/decl/overmap_event_handler/proc/update_hazards(var/turf/T)//catch all updater
if(!istype(T))
return
@@ -126,13 +126,13 @@
if(!active_hazards.len)
hazard_by_turf -= T
entered_event.unregister(T, src, /singleton/overmap_event_handler/proc/on_turf_entered)
exited_event.unregister(T, src, /singleton/overmap_event_handler/proc/on_turf_exited)
entered_event.unregister(T, src, /decl/overmap_event_handler/proc/on_turf_entered)
exited_event.unregister(T, src, /decl/overmap_event_handler/proc/on_turf_exited)
else
hazard_by_turf |= T
hazard_by_turf[T] = active_hazards
entered_event.register(T, src,/singleton/overmap_event_handler/proc/on_turf_entered)
exited_event.register(T, src, /singleton/overmap_event_handler/proc/on_turf_exited)
entered_event.register(T, src,/decl/overmap_event_handler/proc/on_turf_entered)
exited_event.register(T, src, /decl/overmap_event_handler/proc/on_turf_exited)
for(var/obj/effect/overmap/visitable/ship/ship in T)
var/list/active_ship_events = ship_events[ship]
@@ -145,12 +145,12 @@
for(var/obj/effect/overmap/event/E in active_hazards)
start_hazard(ship,E)
/singleton/overmap_event_handler/proc/is_event_in_turf(var/datum/event/E, var/turf/T)
/decl/overmap_event_handler/proc/is_event_in_turf(var/datum/event/E, var/turf/T)
for(var/obj/effect/overmap/event/hazard in hazard_by_turf[T])
if(E in hazard.events && E.severity == hazard.difficulty)
return TRUE
/singleton/overmap_event_handler/proc/is_event_included(var/list/hazards, var/obj/effect/overmap/event/E, var/equal_or_better)//this proc is only used so it can break out of 2 loops cleanly
/decl/overmap_event_handler/proc/is_event_included(var/list/hazards, var/obj/effect/overmap/event/E, var/equal_or_better)//this proc is only used so it can break out of 2 loops cleanly
for(var/obj/effect/overmap/event/A in hazards)
if(istype(A,E.type) || istype(E,A.type))
if(same_entries(A.events, E.events))

View File

@@ -3,7 +3,7 @@
icon = 'icons/turf/desert.dmi'
icon_state = "desert"
has_resources = 1
footstep_sound = /singleton/sound_category/asteroid_footstep
footstep_sound = /decl/sound_category/asteroid_footstep
var/diggable = 1
var/dirt_color = "#7c5e42"
var/has_edge_icon = TRUE
@@ -81,8 +81,8 @@
name = "shallow water"
icon = 'icons/misc/beach.dmi'
icon_state = "seashallow"
footstep_sound = /singleton/sound_category/water_footstep
var/reagent_type = /singleton/reagent/water
footstep_sound = /decl/sound_category/water_footstep
var/reagent_type = /decl/reagent/water
/turf/simulated/floor/exoplanet/water/shallow/attackby(obj/item/O, var/mob/living/user)
var/obj/item/reagent_containers/RG = O
@@ -110,7 +110,7 @@
icon = 'icons/turf/snow.dmi'
icon_state = "snow"
dirt_color = "#e3e7e8"
footstep_sound = /singleton/sound_category/snow_footstep
footstep_sound = /decl/sound_category/snow_footstep
/turf/simulated/floor/exoplanet/snow/Initialize()
. = ..()
@@ -122,7 +122,7 @@
/turf/simulated/floor/exoplanet/snow/melt()
name = "permafrost"
icon_state = "permafrost"
footstep_sound = /singleton/sound_category/asteroid_footstep
footstep_sound = /decl/sound_category/asteroid_footstep
//Grass
/turf/simulated/floor/exoplanet/grass
@@ -130,7 +130,7 @@
icon = 'icons/turf/jungle.dmi'
icon_state = "greygrass"
color = "#799c4b"
footstep_sound = /singleton/sound_category/grass_footstep
footstep_sound = /decl/sound_category/grass_footstep
/turf/simulated/floor/exoplanet/grass/Initialize()
. = ..()
@@ -159,7 +159,7 @@
name = "sand"
desc = "It's coarse and gets everywhere."
dirt_color = "#ae9e66"
footstep_sound = /singleton/sound_category/sand_footstep
footstep_sound = /decl/sound_category/sand_footstep
/turf/simulated/floor/exoplanet/desert/Initialize()
. = ..()
@@ -169,7 +169,7 @@
name = "sand"
desc = "It's coarse and gets everywhere."
dirt_color = "#544c31"
footstep_sound = /singleton/sound_category/sand_footstep
footstep_sound = /decl/sound_category/sand_footstep
//Concrete
/turf/simulated/floor/exoplanet/concrete