Files
Bubberstation/code/modules/power/tracker.dm
carnie b84d12d949 *Small tidy-up of various helper procs*
-Turns out there was already a Gaussian PRNG proc already, used by mechs and turrets. I've replaced it with my one as mine has almost half the cost. (currently broken! still waiting for fixes to be pulled!)
-replaced between(min, val, max) with Clamp(val, min, max)
-get_turf(thing) now uses var/list/locs to locate its turf, rather than iterating up through loc of its loc of its loc...etc
-sign(num) moved to maths.dm
-InRange(val, min, max) replaced with IsInRange(val, min, max) (they were identical)
-Removed ismultitool() iswrench() iscoil() iswire() iswelder() iscrowbar() etc
-removed modulus(num) as abs() performs the same task! *roll-eyes*
-removed get_mob_with_client_list() as it is no longer needed (we have var/list/player_list now)
-removed get_turf_or_move() as it simply called get_turf
-removed get_turf_loc() as it was identical to get_turf()

*Additions:*
-The "Declare Ready" link in the lobby will automatically become "Join Game" if the round starts before you declare ready, so you don't have to click it twice
2013-05-27 12:21:43 +01:00

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>")
del(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