Files
kiwistation/code/modules/power/singularity/containment_field.dm
T
MrPerson 9eee3e5067 First pass at a qdel() garbage collection system for tgstation
Works pretty well. If it can't GC something, it'll just del() it and be done.
Speed is amazing, holy shit.

New procs you should be aware of:
qdel(atom/movable) - sets up an object for garbage collection. Call this rather than del(atom/movable).
atom/movable/Destroy() - called right before the object is GC'd, so it still has a loc. Also called if the object is del()'d.
new controller - garbage.dm has all the details on this. Basically it nulls all references on GC'd objects and force del() them if necessary.
Generally speaking, objects should use Destroy() for behavior prior to deletion rather than Del(). You should also always call the parent so the object gets the right gc_destroyed var set.

ISSUES:
Tries to GC mobs atm. This actually works for new players, not so much for humans/monkies/simple_animals/anything. I'm guessing it needs to clear out their mind and HUD and maybe other things.
Gibbing is really bugged. It works, but the overlays just sit there for awhile and ugh. I'm very tempted just to del() mob/living and mob/camera and call it a day.
qdel() equipment doesn't unequip the item.
Pipes don't generally GC correctly. Debugging suggests they get referenced in many pipenets and that isn't cleared properly. However some do work fine. Need assistance here.
Bots don't GC, probably in the radio controller.
Lots of other shit doesn't GC but it's hard to find them because of the pipe spam.
I think I'm calling Destroy() twice by accident.
2014-02-23 14:55:12 -08:00

105 lines
2.8 KiB
Plaintext

//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/machinery/field/containment
name = "Containment Field"
desc = "An energy field."
icon = 'icons/obj/singularity.dmi'
icon_state = "Contain_F"
anchored = 1
density = 0
unacidable = 1
use_power = 0
luminosity = 4
layer = OBJ_LAYER + 0.1
var/obj/machinery/field/generator/FG1 = null
var/obj/machinery/field/generator/FG2 = null
/obj/machinery/field/containment/Destroy()
if(FG1 && !FG1.clean_up)
FG1.cleanup()
if(FG2 && !FG2.clean_up)
FG2.cleanup()
..()
/obj/machinery/field/containment/attack_hand(mob/user as mob)
if(get_dist(src, user) > 1)
return 0
else
shock(user)
return 1
/obj/machinery/field/containment/blob_act()
return 0
/obj/machinery/field/containment/ex_act(severity)
return 0
/obj/machinery/field/containment/meteorhit()
return 0
/obj/machinery/field/containment/Crossed(atom/movable/mover)
if(isliving(mover))
shock(mover)
/obj/machinery/field/containment/proc/set_master(var/master1,var/master2)
if(!master1 || !master2)
return 0
FG1 = master1
FG2 = master2
return 1
/obj/machinery/field/containment/shock(mob/living/user as mob)
if(!FG1 || !FG2)
qdel(src)
return 0
..()
// Abstract Field Class
// Used for overriding certain procs
/obj/machinery/field
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/field/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(isliving(mover)) // Don't let mobs through
shock(mover)
return 0
return ..()
/obj/machinery/field/proc/shock(mob/living/user as mob)
if(hasShocked)
return 0
if(isliving(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
hasShocked = 1
var/shock_damage = min(rand(30,40),rand(30,40))
if(iscarbon(user))
var/stun = min(shock_damage, 15)
user.Stun(stun)
user.Weaken(10)
user.burn_skin(shock_damage)
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>You feel a powerful shock course through your body sending you flying!</B>", \
"\red You hear a heavy electrical crack")
else if(issilicon(user))
if(prob(20))
user.Stun(2)
user.take_overall_damage(0, shock_damage)
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>Energy pulse detected, system damaged!</B>", \
"\red You hear an electrical crack")
user.updatehealth()
var/atom/target = get_edge_target_turf(user, get_dir(src, get_step_away(user, src)))
user.throw_at(target, 200, 4)
spawn(5)
hasShocked = 0
return