Region

by Forum_account
Lets you specify regions of the map that trigger Entered and Exited events.
ID:428798
 
I just posted another update which adds some features that can be used to make regions more dynamic and a demo which makes use of this. The new demo, wire-demo, creates a graphical effect to represent what turfs are in the region:

region
wire
added(turf/t)
new /obj/wire(t)

removed(turf/t)
del locate(/obj/wire) in t

The region's added() and removed() procs are called each time a turf is added to the region or removed from it. To manage the graphical effect we simply create or delete an instance of /obj/wire. That wire object manages the autojoining, so the region is only responsible for creating and deleting these objects.

We can make use of the region's get_list() proc to find which objects are connected to another object through the wire. When the mob places a wire on the map or removes existing wire, we simply add or remove turfs from the wire region - it handles the rest (ex: placing the /obj/wire object).

client
Center()
if(mob.loc in wire.turfs)
wire.remove(mob.loc)
else
wire.add(mob.loc)

When you step on a button, you just need to call wire.get_list(button, /turf/door) to find the doors it's connected to.