mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-19 13:35:10 +00:00
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.
92 lines
2.4 KiB
Plaintext
92 lines
2.4 KiB
Plaintext
//Solar tracker
|
|
|
|
//Machine that tracks the sun and reports it's direction to the solar controllers
|
|
//As long as this is working, solar panels on same powernet will track automatically
|
|
|
|
/obj/machinery/power/tracker
|
|
name = "solar tracker"
|
|
desc = "A solar directional tracker."
|
|
icon = 'icons/obj/power.dmi'
|
|
icon_state = "tracker"
|
|
anchored = 1
|
|
density = 1
|
|
directwired = 1
|
|
use_power = 0
|
|
|
|
var/sun_angle = 0 // sun angle as set by sun datum
|
|
|
|
/obj/machinery/power/tracker/New(var/turf/loc, var/obj/item/solar_assembly/S)
|
|
..(loc)
|
|
if(!S)
|
|
S = new /obj/item/solar_assembly(src)
|
|
S.glass_type = /obj/item/stack/sheet/glass
|
|
S.tracker = 1
|
|
S.anchored = 1
|
|
S.loc = src
|
|
connect_to_network()
|
|
|
|
/obj/machinery/power/tracker/disconnect_from_network()
|
|
..()
|
|
solars_list.Remove(src)
|
|
|
|
/obj/machinery/power/tracker/connect_to_network()
|
|
..()
|
|
solars_list.Add(src)
|
|
|
|
// called by datum/sun/calc_position() as sun's angle changes
|
|
/obj/machinery/power/tracker/proc/set_angle(var/angle)
|
|
sun_angle = angle
|
|
|
|
//set icon dir to show sun illumination
|
|
dir = turn(NORTH, -angle - 22.5) // 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
|
|
|
|
// check we can draw power
|
|
if(stat & NOPOWER)
|
|
return
|
|
|
|
// find all solar controls and update them
|
|
// currently, just update all controllers in world
|
|
// ***TODO: better communication system using network
|
|
if(powernet)
|
|
for(var/obj/machinery/power/solar_control/C in get_solars_powernet())
|
|
if(powernet.nodes[C])
|
|
if(get_dist(C, src) < SOLAR_MAX_DIST)
|
|
C.tracker_update(angle)
|
|
|
|
|
|
/obj/machinery/power/tracker/attackby(var/obj/item/weapon/W, var/mob/user)
|
|
|
|
if(istype(W, /obj/item/weapon/crowbar))
|
|
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
|
if(do_after(user, 50))
|
|
var/obj/item/solar_assembly/S = locate() in src
|
|
if(S)
|
|
S.loc = src.loc
|
|
S.give_glass()
|
|
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
|
|
user.visible_message("<span class='notice'>[user] takes the glass off the tracker.</span>")
|
|
qdel(src)
|
|
return
|
|
..()
|
|
|
|
// timed process
|
|
// make sure we can draw power from the powernet
|
|
/obj/machinery/power/tracker/process()
|
|
|
|
var/avail = surplus()
|
|
|
|
if(avail > 500)
|
|
add_load(500)
|
|
stat &= ~NOPOWER
|
|
else
|
|
stat |= NOPOWER
|
|
|
|
|
|
// Tracker Electronic
|
|
|
|
/obj/item/weapon/tracker_electronics
|
|
|
|
name = "tracker electronics"
|
|
icon = 'icons/obj/doors/door_assembly.dmi'
|
|
icon_state = "door_electronics"
|
|
w_class = 2.0 |