Obsolete the PROXMOVE flag and uses

This commit is contained in:
Aronai Sieyes
2020-05-18 13:01:25 -04:00
parent 0adea12715
commit e3b5d24c8b
20 changed files with 125 additions and 78 deletions

View File

@@ -29,8 +29,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define OPENCONTAINER (1<<4) // Is an open container for chemistry purposes. #define OPENCONTAINER (1<<4) // Is an open container for chemistry purposes.
#define PHORONGUARD (1<<5) // Does not get contaminated by phoron. #define PHORONGUARD (1<<5) // Does not get contaminated by phoron.
#define NOREACT (1<<6) // Reagents don't react inside this container. #define NOREACT (1<<6) // Reagents don't react inside this container.
#define PROXMOVE (1<<7)// Does this object require proximity checking in Enter()? #define OVERLAY_QUEUED (1<<7)// Atom queued to SSoverlay for COMPILE_OVERLAYS
#define OVERLAY_QUEUED (1<<8)// Atom queued to SSoverlay for COMPILE_OVERLAYS
//Flags for items (equipment) - Used in /obj/item/var/item_flags //Flags for items (equipment) - Used in /obj/item/var/item_flags
#define THICKMATERIAL (1<<0) // Prevents syringes, parapens and hyposprays if equipped to slot_suit or slot_head. #define THICKMATERIAL (1<<0) // Prevents syringes, parapens and hyposprays if equipped to slot_suit or slot_head.

View File

@@ -0,0 +1,33 @@
// Observer Pattern Implementation: Turf Entered/Exited
// Registration type: /turf
//
// Raised when: A /turf has a new item in contents, or an item has left it's contents
//
// Arguments that the called proc should expect:
// /turf: The turf that was entered/exited
// /atom/movable/moving_instance: The instance that entered/exited
// /atom/old_loc / /atom/new_loc: The previous/new loc of the mover
GLOBAL_DATUM_INIT(turf_entered_event, /decl/observ/turf_entered, new)
GLOBAL_DATUM_INIT(turf_exited_event, /decl/observ/turf_exited, new)
/decl/observ/turf_entered
name = "Turf Entered"
expected_type = /turf
/decl/observ/turf_exited
name = "Turf Exited"
expected_type = /turf
/********************
* Movement Handling *
********************/
/turf/Entered(var/atom/movable/am, var/atom/old_loc)
. = ..()
GLOB.turf_entered_event.raise_event(src, am, old_loc)
/turf/Exited(var/atom/movable/am, var/atom/new_loc)
. = ..()
GLOB.turf_exited_event.raise_event(src, am, new_loc)

View File

@@ -29,7 +29,6 @@
density = 0 density = 0
unacidable = 1//Just to be sure. unacidable = 1//Just to be sure.
var/def_zone var/def_zone
flags = PROXMOVE
pass_flags = PASSTABLE pass_flags = PASSTABLE

View File

@@ -118,15 +118,33 @@
/atom/proc/CheckExit() /atom/proc/CheckExit()
return 1 return 1
// If you want to use this, the atom must have the PROXMOVE flag, and the moving // Used to be for the PROXMOVE flag, but that was terrible, so instead it's just here as a stub for
// atom must also have the PROXMOVE flag currently to help with lag. ~ ComicIronic // all the atoms that still have the proc, but get events other ways.
/atom/proc/HasProximity(atom/movable/AM as mob|obj) /atom/proc/HasProximity(turf/T, atom/movable/AM, old_loc)
return return
//Register listeners on turfs in a certain range
/atom/proc/sense_proximity(var/range = 1, var/callback)
ASSERT(callback)
ASSERT(isturf(loc))
var/list/turfs = trange(range, src)
for(var/t in turfs)
var/turf/T = t
GLOB.turf_entered_event.register(T, src, callback)
//Unregister from prox listening in a certain range. You should do this BEFORE you move, but if you
// really can't, then you can set the center where you moved from.
/atom/proc/unsense_proximity(var/range = 1, var/callback, var/center)
ASSERT(isturf(center) || isturf(loc))
var/list/turfs = trange(range, center ? center : src)
for(var/t in turfs)
var/turf/T = t
GLOB.turf_entered_event.unregister(T, src, callback)
/atom/proc/emp_act(var/severity) /atom/proc/emp_act(var/severity)
return return
/atom/proc/bullet_act(obj/item/projectile/P, def_zone) /atom/proc/bullet_act(obj/item/projectile/P, def_zone)
P.on_hit(src, 0, def_zone) P.on_hit(src, 0, def_zone)
. = 0 . = 0

View File

@@ -87,6 +87,8 @@
// VOREStation Edit End // VOREStation Edit End
/obj/machinery/camera/Destroy() /obj/machinery/camera/Destroy()
if(isMotion())
unsense_proximity(callback = .HasProximity)
deactivate(null, 0) //kick anyone viewing out deactivate(null, 0) //kick anyone viewing out
if(assembly) if(assembly)
qdel(assembly) qdel(assembly)

View File

@@ -3,15 +3,13 @@
var/detectTime = 0 var/detectTime = 0
var/area/ai_monitored/area_motion = null var/area/ai_monitored/area_motion = null
var/alarm_delay = 100 // Don't forget, there's another 10 seconds in queueAlarm() var/alarm_delay = 100 // Don't forget, there's another 10 seconds in queueAlarm()
flags = PROXMOVE
/obj/machinery/camera/internal_process() /obj/machinery/camera/internal_process()
// motion camera event loop // motion camera event loop
if (stat & (EMPED|NOPOWER)) if (stat & (EMPED|NOPOWER))
return return
if(!isMotion()) if(!isMotion())
. = PROCESS_KILL return PROCESS_KILL
return
if (detectTime > 0) if (detectTime > 0)
var/elapsed = world.time - detectTime var/elapsed = world.time - detectTime
if (elapsed > alarm_delay) if (elapsed > alarm_delay)
@@ -56,7 +54,7 @@
detectTime = -1 detectTime = -1
return 1 return 1
/obj/machinery/camera/HasProximity(atom/movable/AM as mob|obj) /obj/machinery/camera/HasProximity(turf/T, atom/movable/AM, old_loc)
// Motion cameras outside of an "ai monitored" area will use this to detect stuff. // Motion cameras outside of an "ai monitored" area will use this to detect stuff.
if (!area_motion) if (!area_motion)
if(isliving(AM)) if(isliving(AM))

View File

@@ -212,9 +212,12 @@ var/global/list/engineering_networks = list(
update_coverage() update_coverage()
/obj/machinery/camera/proc/upgradeMotion() /obj/machinery/camera/proc/upgradeMotion()
if(!isturf(loc))
return //nooooo
assembly.upgrades.Add(new /obj/item/device/assembly/prox_sensor(assembly)) assembly.upgrades.Add(new /obj/item/device/assembly/prox_sensor(assembly))
setPowerUsage() setPowerUsage()
START_MACHINE_PROCESSING(src) START_MACHINE_PROCESSING(src)
sense_proximity(callback = .HasProximity)
update_coverage() update_coverage()
/obj/machinery/camera/proc/setPowerUsage() /obj/machinery/camera/proc/setPowerUsage()

View File

@@ -13,7 +13,6 @@
anchored = 1 anchored = 1
use_power = USE_POWER_IDLE use_power = USE_POWER_IDLE
idle_power_usage = 2 idle_power_usage = 2
flags = PROXMOVE
/obj/machinery/flasher/portable //Portable version of the flasher. Only flashes when anchored /obj/machinery/flasher/portable //Portable version of the flasher. Only flashes when anchored
name = "portable flasher" name = "portable flasher"
@@ -92,13 +91,13 @@
flash() flash()
..(severity) ..(severity)
/obj/machinery/flasher/portable/HasProximity(atom/movable/AM as mob|obj) /obj/machinery/flasher/portable/HasProximity(turf/T, atom/movable/AM, oldloc)
if((disable) || (last_flash && world.time < last_flash + 150)) if(disable || !anchored || (last_flash && world.time < last_flash + 150))
return return
if(istype(AM, /mob/living/carbon)) if(iscarbon(AM))
var/mob/living/carbon/M = AM var/mob/living/carbon/M = AM
if((M.m_intent != "walk") && (anchored)) if(M.m_intent != "walk")
flash() flash()
/obj/machinery/flasher/portable/attackby(obj/item/weapon/W as obj, mob/user as mob) /obj/machinery/flasher/portable/attackby(obj/item/weapon/W as obj, mob/user as mob)
@@ -108,11 +107,13 @@
if(!anchored) if(!anchored)
user.show_message(text("<span class='warning'>[src] can now be moved.</span>")) user.show_message(text("<span class='warning'>[src] can now be moved.</span>"))
overlays.Cut() cut_overlays()
unsense_proximity(callback = .HasProximity)
else if(anchored) else if(anchored)
user.show_message(text("<span class='warning'>[src] is now secured.</span>")) user.show_message(text("<span class='warning'>[src] is now secured.</span>"))
overlays += "[base_state]-s" add_overlay("[base_state]-s")
sense_proximity(callback = .HasProximity)
/obj/machinery/button/flasher /obj/machinery/button/flasher
name = "flasher button" name = "flasher button"

View File

@@ -441,7 +441,6 @@
var/health = 100 var/health = 100
var/status = BURST //can be GROWING, GROWN or BURST; all mutually exclusive var/status = BURST //can be GROWING, GROWN or BURST; all mutually exclusive
flags = PROXMOVE
/obj/effect/alien/egg/New() /obj/effect/alien/egg/New()
/* /*
@@ -545,16 +544,4 @@
/obj/effect/alien/egg/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) /obj/effect/alien/egg/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
if(exposed_temperature > 500 + T0C) if(exposed_temperature > 500 + T0C)
health -= 5 health -= 5
healthcheck() healthcheck()
/*
/obj/effect/alien/egg/HasProximity(atom/movable/AM as mob|obj)
if(status == GROWN)
if(!CanHug(AM))
return
var/mob/living/carbon/C = AM
if(C.stat == CONSCIOUS && C.status_flags & XENO_HOST)
return
Burst(0)
*/

View File

@@ -9,7 +9,6 @@
var/mob/attacher = null var/mob/attacher = null
var/valve_open = 0 var/valve_open = 0
var/toggle = 1 var/toggle = 1
flags = PROXMOVE
/obj/item/device/transfer_valve/attackby(obj/item/item, mob/user) /obj/item/device/transfer_valve/attackby(obj/item/item, mob/user)
var/turf/location = get_turf(src) // For admin logs var/turf/location = get_turf(src) // For admin logs
@@ -57,11 +56,15 @@
return return
/obj/item/device/transfer_valve/HasProximity(atom/movable/AM as mob|obj) /obj/item/device/transfer_valve/HasProximity(turf/T, atom/movable/AM, old_loc)
if(!attached_device) return attached_device?.HasProximity(T, AM, old_loc)
attached_device.HasProximity(AM)
return
/obj/item/device/transfer_valve/Moved(old_loc, direction, forced)
. = ..()
if(isturf(old_loc))
unsense_proximity(callback = .HasProximity, center = old_loc)
if(isturf(loc))
sense_proximity(callback = .HasProximity)
/obj/item/device/transfer_valve/attack_self(mob/user as mob) /obj/item/device/transfer_valve/attack_self(mob/user as mob)
ui_interact(user) ui_interact(user)

View File

@@ -678,6 +678,11 @@ var/list/global/tank_gauge_cache = list()
tank.update_icon() tank.update_icon()
tank.overlays -= "bomb_assembly" tank.overlays -= "bomb_assembly"
/obj/item/device/tankassemblyproxy/HasProximity(atom/movable/AM as mob|obj) /obj/item/device/tankassemblyproxy/HasProximity(turf/T, atom/movable/AM, old_loc)
if(src.assembly) assembly?.HasProximity(T, AM, old_loc)
src.assembly.HasProximity(AM)
/obj/item/device/tankassemblyproxy/Moved(old_loc, direction, forced)
if(isturf(old_loc))
unsense_proximity(callback = .HasProximity, center = old_loc)
if(isturf(loc))
sense_proximity(callback = .HasProximity)

View File

@@ -142,18 +142,8 @@ turf/attackby(obj/item/weapon/W as obj, mob/user as mob)
sleep(2) sleep(2)
O.update_transform() O.update_transform()
var/const/enterloopsanity = 100 /turf/Entered(var/atom/movable/A, var/old_loc)
/turf/Entered(atom/atom as mob|obj) . = ..()
if(movement_disabled)
to_chat(usr, "<span class='warning'>Movement is admin-disabled.</span>") //This is to identify lag problems
return
..()
if(!istype(atom, /atom/movable))
return
var/atom/movable/A = atom
if(ismob(A)) if(ismob(A))
var/mob/M = A var/mob/M = A
@@ -166,16 +156,6 @@ var/const/enterloopsanity = 100
M.inertia_dir = 0 M.inertia_dir = 0
M.make_floating(0) M.make_floating(0)
var/objects = 0
if(A && (A.flags & PROXMOVE))
for(var/atom/movable/thing in range(1))
if(objects++ > enterloopsanity) break
spawn(0)
if(A) //Runtime prevention
A.HasProximity(thing, 1)
if ((thing && A) && (thing.flags & PROXMOVE))
thing.HasProximity(A, 1)
/turf/CanPass(atom/movable/mover, turf/target) /turf/CanPass(atom/movable/mover, turf/target)
if(!target) if(!target)
return FALSE return FALSE

View File

@@ -3,7 +3,6 @@
icon = 'icons/obj/assemblies/new_assemblies.dmi' icon = 'icons/obj/assemblies/new_assemblies.dmi'
icon_state = "holder" icon_state = "holder"
item_state = "assembly" item_state = "assembly"
flags = PROXMOVE
throwforce = 5 throwforce = 5
w_class = ITEMSIZE_SMALL w_class = ITEMSIZE_SMALL
throw_speed = 3 throw_speed = 3
@@ -64,11 +63,18 @@
else else
. += "\The [src] can be attached!" . += "\The [src] can be attached!"
/obj/item/device/assembly_holder/HasProximity(atom/movable/AM as mob|obj) /obj/item/device/assembly_holder/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
if(isturf(old_loc))
unsense_proximity(callback = .HasProximity, center = old_loc)
if(isturf(loc))
sense_proximity(callback = .HasProximity)
/obj/item/device/assembly_holder/HasProximity(turf/T, atom/movable/AM, old_loc)
if(a_left) if(a_left)
a_left.HasProximity(AM) a_left.HasProximity(T, AM, old_loc)
if(a_right) if(a_right)
a_right.HasProximity(AM) a_right.HasProximity(T, AM, old_loc)
/obj/item/device/assembly_holder/Crossed(atom/movable/AM as mob|obj) /obj/item/device/assembly_holder/Crossed(atom/movable/AM as mob|obj)
if(AM.is_incorporeal()) if(AM.is_incorporeal())

View File

@@ -4,7 +4,6 @@
icon_state = "prox" icon_state = "prox"
origin_tech = list(TECH_MAGNET = 1) origin_tech = list(TECH_MAGNET = 1)
matter = list(DEFAULT_WALL_MATERIAL = 800, "glass" = 200, "waste" = 50) matter = list(DEFAULT_WALL_MATERIAL = 800, "glass" = 200, "waste" = 50)
flags = PROXMOVE
wires = WIRE_PULSE wires = WIRE_PULSE
secured = 0 secured = 0
@@ -33,7 +32,7 @@
update_icon() update_icon()
return secured return secured
/obj/item/device/assembly/prox_sensor/HasProximity(atom/movable/AM as mob|obj) /obj/item/device/assembly/prox_sensor/HasProximity(turf/T, atom/movable/AM, old_loc)
if(!istype(AM)) if(!istype(AM))
log_debug("DEBUG: HasProximity called with [AM] on [src] ([usr]).") log_debug("DEBUG: HasProximity called with [AM] on [src] ([usr]).")
return return
@@ -90,6 +89,10 @@
/obj/item/device/assembly/prox_sensor/Moved(atom/old_loc, direction, forced = FALSE) /obj/item/device/assembly/prox_sensor/Moved(atom/old_loc, direction, forced = FALSE)
. = ..() . = ..()
if(isturf(old_loc))
unsense_proximity(range = range, callback = .HasProximity, center = old_loc)
if(isturf(loc))
sense_proximity(range = range, callback = .HasProximity)
sense() sense()
/obj/item/device/assembly/prox_sensor/interact(mob/user as mob)//TODO: Change this to the wires thingy /obj/item/device/assembly/prox_sensor/interact(mob/user as mob)//TODO: Change this to the wires thingy

View File

@@ -72,8 +72,9 @@
var/obj/machinery/portable_atmospherics/hydroponics/soil/invisible/plant var/obj/machinery/portable_atmospherics/hydroponics/soil/invisible/plant
/obj/effect/plant/Destroy() /obj/effect/plant/Destroy()
if(plant_controller) if(seed.get_trait(TRAIT_SPREAD)==2)
plant_controller.remove_plant(src) unsense_proximity(callback = .HasProximity, center = get_turf(src))
plant_controller.remove_plant(src)
for(var/obj/effect/plant/neighbor in range(1,src)) for(var/obj/effect/plant/neighbor in range(1,src))
plant_controller.add_plant(neighbor) plant_controller.add_plant(neighbor)
return ..() return ..()
@@ -106,6 +107,7 @@
name = seed.display_name name = seed.display_name
max_health = round(seed.get_trait(TRAIT_ENDURANCE)/2) max_health = round(seed.get_trait(TRAIT_ENDURANCE)/2)
if(seed.get_trait(TRAIT_SPREAD)==2) if(seed.get_trait(TRAIT_SPREAD)==2)
sense_proximity(callback = .HasProximity) // Grabby
max_growth = VINE_GROWTH_STAGES max_growth = VINE_GROWTH_STAGES
growth_threshold = max_health/VINE_GROWTH_STAGES growth_threshold = max_health/VINE_GROWTH_STAGES
icon = 'icons/obj/hydroponics_vines.dmi' icon = 'icons/obj/hydroponics_vines.dmi'

View File

@@ -1,4 +1,4 @@
/obj/effect/plant/HasProximity(var/atom/movable/AM) /obj/effect/plant/HasProximity(turf/T, atom/movable/AM, old_loc)
if(!is_mature() || seed.get_trait(TRAIT_SPREAD) != 2) if(!is_mature() || seed.get_trait(TRAIT_SPREAD) != 2)
return return
@@ -13,6 +13,14 @@
spawn(1) spawn(1)
entangle(M) entangle(M)
/obj/effect/plant/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
if(seed.get_trait(TRAIT_SPREAD)==2)
if(isturf(old_loc))
unsense_proximity(callback = .HasProximity, center = old_loc)
if(isturf(loc))
sense_proximity(callback = .HasProximity)
/obj/effect/plant/attack_hand(var/mob/user) /obj/effect/plant/attack_hand(var/mob/user)
manual_unbuckle(user) manual_unbuckle(user)

View File

@@ -15,7 +15,6 @@ var/const/MAX_ACTIVE_TIME = 400
icon_state = "facehugger" icon_state = "facehugger"
item_state = "facehugger" item_state = "facehugger"
w_class = 3 //note: can be picked up by aliens unlike most other items of w_class below 4 w_class = 3 //note: can be picked up by aliens unlike most other items of w_class below 4
flags = PROXMOVE
body_parts_covered = FACE|EYES body_parts_covered = FACE|EYES
throw_range = 5 throw_range = 5

View File

@@ -3,7 +3,6 @@
layer = MOB_LAYER layer = MOB_LAYER
plane = MOB_PLANE plane = MOB_PLANE
animate_movement = 2 animate_movement = 2
flags = PROXMOVE
var/datum/mind/mind var/datum/mind/mind
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak

View File

@@ -10,12 +10,15 @@
unacidable = 1 unacidable = 1
use_power = USE_POWER_OFF use_power = USE_POWER_OFF
light_range = 4 light_range = 4
flags = PROXMOVE
var/obj/machinery/field_generator/FG1 = null var/obj/machinery/field_generator/FG1 = null
var/obj/machinery/field_generator/FG2 = null var/obj/machinery/field_generator/FG2 = null
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second. var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
/obj/machinery/containment_field/Initialize()
sense_proximity(callback = .HasProximity)
/obj/machinery/containment_field/Destroy() /obj/machinery/containment_field/Destroy()
unsense_proximity(callback = .HasProximity)
if(FG1 && !FG1.clean_up) if(FG1 && !FG1.clean_up)
FG1.cleanup() FG1.cleanup()
if(FG2 && !FG2.clean_up) if(FG2 && !FG2.clean_up)
@@ -33,7 +36,7 @@
/obj/machinery/containment_field/ex_act(severity) /obj/machinery/containment_field/ex_act(severity)
return 0 return 0
/obj/machinery/containment_field/HasProximity(atom/movable/AM as mob|obj) /obj/machinery/containment_field/HasProximity(turf/T, atom/movable/AM, old_loc)
if(istype(AM,/mob/living/silicon) && prob(40)) if(istype(AM,/mob/living/silicon) && prob(40))
shock(AM) shock(AM)
return 1 return 1
@@ -42,8 +45,6 @@
return 1 return 1
return 0 return 0
/obj/machinery/containment_field/shock(mob/living/user as mob) /obj/machinery/containment_field/shock(mob/living/user as mob)
if(hasShocked) if(hasShocked)
return 0 return 0

View File

@@ -355,6 +355,7 @@
#include "code\datums\observation\shuttle_moved.dm" #include "code\datums\observation\shuttle_moved.dm"
#include "code\datums\observation\stat_set.dm" #include "code\datums\observation\stat_set.dm"
#include "code\datums\observation\turf_changed.dm" #include "code\datums\observation\turf_changed.dm"
#include "code\datums\observation\turf_enterexit.dm"
#include "code\datums\observation\unequipped.dm" #include "code\datums\observation\unequipped.dm"
#include "code\datums\observation\z_moved.dm" #include "code\datums\observation\z_moved.dm"
#include "code\datums\observation\~cleanup.dm" #include "code\datums\observation\~cleanup.dm"