mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-24 17:11:22 +00:00
* Replace SSingulo with SScalamity; processing cleanup
- SScalamity now handles blobs as well as singularity-types.
- Processing subtypes have been simplified to not require a stop_processing definition.
* this is probably important
* Remove cascade disabling SSgarbage
* Fixed a bug where dust() did not qdel the target mob
* Misc fixes
* Fix decals surviving break-to-plating
* Subsystem flag tweaks
* Apparently subsystems are new'd before config is.
* Fix paper icons
* Speculative fix for insane lag
* Better machinery stat
* Make organs not use SSoverlay
* Misc bugfixes & tweaks
* Nightmode fixes
* Changelog for SMC
* Port /tg/'s improved MC crash handling
* Add some more SS Recover() procs
* supply_controller -> SScargo
* More New() -> Initialize()
* pAI and robot construction overlays
* Fix cargo unit tests
* Merge the DMM Suite's atom/New() into atoms_init
* Lighting pre-baking
* Lighting initialization logging
* Fix some bad SS init orders
* Fix SSlighting logging; rename Processes to MC
* Speculative fix for insane GC lag
* Prebaked openturf/icon_smooth & fix lighting prebake
* SS init status; SSatoms LATEQDEL
* Fix bug with MC init stat panel
* Fix parallax
* Misc
* Ignore SS_NO_DISPLAY during init
* apparently this is important
* REEEEEE
* Image GC fixes; broadcaster radio-new sanity
* RCON Cleanup
* Move pAI recruiter into subsystem
* Move global solars list into sun subsystem
* Make chickens not use a global
* Demote SSdisposals to SS_BACKGROUND; garbage-debug cleanup
* Speed up space init a little
* Fix bad timer flags on floor drying
* Subsystem panic-restart verb for mins
* Explosion speedup
* Minor subsystem & MC logging tweaks
* SSopenturf improvements
* Make pipenet actually initialize (whoops)
* Minor tweaks
* Implement lighting rounding
* comments are hard okay
* Minor lattice tweaks
* Fix some timer issues & better closet init
* Timer sanity
* Request console tweaks + Storage init sanity
* Minor SSmachiner RCON improvements
* Further reduce world-start timer count
* Standardize subsystem logging
* Garbage hard delete profiling from /tg/
* Timer hang detection & recovery
* Log machines that sleep in process() and fuck up SSmachinery
* Fix an issue with external airlocks sleeping in process()
* Failsafe logging
* Minor tweaks
* Revert "Request console tweaks + Storage init sanity"
This reverts commit 98d3579e35.
* Re-implement RC changes
* Fix SQL FT saving
* Fix SSmachinery sleep in disposals
* Minor SS tweaks
* Paper fixes
* Blood drying fixes
* Merge gameticker and SSticker
* Minor global list init cleanup
* Lagcheck biogenerator & bags
* Tweak SScargo init order; RIG Initialize()
* Caching tweaks
* Remove rogue comma
* Initialize fixes
* Lighting destroy cleanup
* Fix emagging airlocks
* Initial SSicon implementation
* Tweaks & Fixes
* Fire + Air alarm queued icon updates
* Overlays + Queued icon cleanup
* Runtime & background fixes
* Kill some meaningless set statements
* Kill some image qdels
* Bump up lighting rounding val
* Fix adv. scanner destroy runtimes
* Remove unneeded icon update limiting
* Move icon smoothing into helpers
* Show a warning if DM 510 compiles without memory leak hack enabled
* Re-organize subsystems & MC defines a little
* Airlock SFX
* Log of Changes
* Make SSicon_update disable itself when not doing anything
* Fix respawn verb runtime when used early in server-init
* Add more information to MC's stat_entry()
* Replace direct refernces to gcDestroyed with QDEL* macros
* plant_controller -> SSplants
* More plant tweaks
* Add more humor to changelog
* Move parallax globals into SSparallax
* Lighting responsiveness tweaks
* Fix parallax init order & better MC init panel stat
* Make mobs GC
* More overlays + Remove intercom spawn()
* SSfast_process; make pinpointers not use spawn-recursion to process
Also made the SM Cascade beach process with SSprocessing instead of a spawn loop.
* Update changelog
* Mob GC tweaks
* Del() cleanup
* Fix insomniac ZAS connection edges
* Minor pAI cleanup
* Convert more things to SSoverlay; fix duplicated overlay in field gens
* SM Bluespace turf tweaks
* Update SSgarbage debug globals list
* Human-type qdel tweaks
* Subsystem suspension; stat_entry improvements
* SQL Statistics cleanup
* Fix runtimes with ambrosia
* More disable() -> suspend(); fix nightmode again
* Human qdel fix; minor tweaks
* Update turbolift to work with StonedMC
* Make lifts use timers instead of a subsystem
* Make SSassets start earlier
* Convert the radio controller into a subsystem
* Fix some missing CHECK_TICKs in asteroid generation
* MC stat tweaks; make shouldnt_see a typecache
* Kill some redundant debug-controller entries
* radio_controller -> SSradio
* Better SSgarbage hard-del logging from /tg/ upstream
* Logging tweaks + GELF
* Misc client caching improvements
* Slime SSoverlay
* Oven icon fixes
* Implant fixes
- Death implants will no longer spam Common on death of user.
- Death implants should handle a deleted user better.
* Holder tweaks + Welding tool Initialize()
* Fix some bad subsystem logging
* Fix suit cooling units spawning without cells
* Starlight tweaks
* Gibber infinite gib fix
* More SSoverlay stuff
* Make crates use CUT_OVERLAY_IN
* Make SSarrivals suspend instead of disable
* Make openturf use split/phased tick checks
* Speculative fix for unwet timer runtimes
* Blood overlay tweaks/fixes
* Update crusher to play nice with SMC + SSoverlay
* Openturf improvements and fixes
* Minor turbolift tweaks
* Lighting performance improvements + ChangeTurf tweaks
* this is probably important
* Fix wall weld noises on changeturf
* More ChangeTurf tweaks
* Explosion tweaks
* Pre-game lobby tweaks
* Openturf tweaks
* Prevent admins from starting the game before init finishes
* Fix Travis
* Kill an unused var
* Fix ChangeTurf runtimes on openturfs
* Fixes
* Browser datum fixes, asset caching
* Update changelog
* Changelog
* Lobby tweaks
* Ticker tweaks; kill ticker var
* Further lobby tweaks
* Cascade tweaks
* air_master -> SSair
* Reduce overhead from radio autosay
* alarm_manager -> SSalarm
* bomb_processor -> SSexplosives
* corp_regs -> SSlaw
* ZAS overlay fixes
* Small wall icon optimization
* Fix effects master
* Assembly tweaks
* Megavend fixes
* Shuttle fixes
* Camera alert performance improvements
* Fix some world.log spam from lighting overlays
* Fix some Initialize() procs
* Openspace responsiveness tweaks
* Make HE pipes animate through openturfs
* Kill a spawn
551 lines
18 KiB
Plaintext
551 lines
18 KiB
Plaintext
#define SOLAR_MAX_DIST 40
|
|
#define SOLARGENRATE 1500
|
|
|
|
/obj/machinery/power/solar
|
|
name = "solar panel"
|
|
desc = "A solar electrical generator."
|
|
icon = 'icons/obj/power.dmi'
|
|
icon_state = "sp_base"
|
|
anchored = 1
|
|
density = 1
|
|
use_power = 0
|
|
idle_power_usage = 0
|
|
active_power_usage = 0
|
|
var/id = 0
|
|
var/health = 10
|
|
var/obscured = 0
|
|
var/sunfrac = 0
|
|
var/adir = SOUTH // actual dir
|
|
var/ndir = SOUTH // target dir
|
|
var/turn_angle = 0
|
|
var/obj/machinery/power/solar_control/control = null
|
|
|
|
/obj/machinery/power/solar/drain_power()
|
|
return -1
|
|
|
|
/obj/machinery/power/solar/Initialize(mapload, var/obj/item/solar_assembly/S)
|
|
. = ..()
|
|
Make(S)
|
|
connect_to_network()
|
|
|
|
/obj/machinery/power/solar/Destroy()
|
|
unset_control() //remove from control computer
|
|
return ..()
|
|
|
|
//set the control of the panel to a given computer if closer than SOLAR_MAX_DIST
|
|
/obj/machinery/power/solar/proc/set_control(var/obj/machinery/power/solar_control/SC)
|
|
if(SC && (get_dist(src, SC) > SOLAR_MAX_DIST))
|
|
return 0
|
|
control = SC
|
|
return 1
|
|
|
|
//set the control of the panel to null and removes it from the control list of the previous control computer if needed
|
|
/obj/machinery/power/solar/proc/unset_control()
|
|
if(control)
|
|
control.connected_panels.Remove(src)
|
|
control = null
|
|
|
|
/obj/machinery/power/solar/proc/Make(var/obj/item/solar_assembly/S)
|
|
if(!S)
|
|
S = new /obj/item/solar_assembly(src)
|
|
S.glass_type = /obj/item/stack/material/glass
|
|
S.anchored = 1
|
|
S.loc = src
|
|
if(S.glass_type == /obj/item/stack/material/glass/reinforced) //if the panel is in reinforced glass
|
|
health *= 2 //this need to be placed here, because panels already on the map don't have an assembly linked to
|
|
update_icon()
|
|
|
|
|
|
|
|
/obj/machinery/power/solar/attackby(obj/item/weapon/W, mob/user)
|
|
|
|
if(istype(W, /obj/item/weapon/crowbar))
|
|
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
|
user.visible_message("<span class='notice'>[user] begins to take the glass off the solar panel.</span>")
|
|
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 solar panel.</span>")
|
|
qdel(src)
|
|
return
|
|
else if (W)
|
|
src.add_fingerprint(user)
|
|
src.health -= W.force
|
|
src.healthcheck()
|
|
..()
|
|
|
|
|
|
/obj/machinery/power/solar/proc/healthcheck()
|
|
if (src.health <= 0)
|
|
if(!(stat & BROKEN))
|
|
broken()
|
|
else
|
|
new /obj/item/weapon/material/shard(src.loc)
|
|
new /obj/item/weapon/material/shard(src.loc)
|
|
qdel(src)
|
|
return
|
|
return
|
|
|
|
|
|
/obj/machinery/power/solar/update_icon()
|
|
..()
|
|
cut_overlays()
|
|
if(stat & BROKEN)
|
|
add_overlay("solar_panel-b")
|
|
else
|
|
add_overlay("solar_panel")
|
|
src.set_dir(angle2dir(adir))
|
|
return
|
|
|
|
//calculates the fraction of the sunlight that the panel recieves
|
|
/obj/machinery/power/solar/proc/update_solar_exposure()
|
|
if(!sun)
|
|
return
|
|
if(obscured)
|
|
sunfrac = 0
|
|
return
|
|
|
|
//find the smaller angle between the direction the panel is facing and the direction of the sun (the sign is not important here)
|
|
var/p_angle = min(abs(adir - sun.angle), 360 - abs(adir - sun.angle))
|
|
|
|
if(p_angle > 90) // if facing more than 90deg from sun, zero output
|
|
sunfrac = 0
|
|
return
|
|
|
|
sunfrac = cos(p_angle) ** 2
|
|
//isn't the power recieved from the incoming light proportionnal to cos(p_angle) (Lambert's cosine law) rather than cos(p_angle)^2 ?
|
|
|
|
/obj/machinery/power/solar/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY
|
|
if(stat & BROKEN)
|
|
return
|
|
if(!sun || !control) //if there's no sun or the panel is not linked to a solar control computer, no need to proceed
|
|
return
|
|
|
|
if(powernet)
|
|
if(powernet == control.powernet)//check if the panel is still connected to the computer
|
|
if(obscured) //get no light from the sun, so don't generate power
|
|
return
|
|
var/sgen = SOLARGENRATE * sunfrac
|
|
add_avail(sgen)
|
|
control.gen += sgen
|
|
else //if we're no longer on the same powernet, remove from control computer
|
|
unset_control()
|
|
|
|
/obj/machinery/power/solar/proc/broken()
|
|
stat |= BROKEN
|
|
unset_control()
|
|
update_icon()
|
|
return
|
|
|
|
|
|
/obj/machinery/power/solar/ex_act(severity)
|
|
switch(severity)
|
|
if(1.0)
|
|
if(prob(15))
|
|
new /obj/item/weapon/material/shard( src.loc )
|
|
qdel(src)
|
|
return
|
|
|
|
if(2.0)
|
|
if (prob(25))
|
|
new /obj/item/weapon/material/shard( src.loc )
|
|
qdel(src)
|
|
return
|
|
|
|
if (prob(50))
|
|
broken()
|
|
|
|
if(3.0)
|
|
if (prob(25))
|
|
broken()
|
|
return
|
|
|
|
|
|
/obj/machinery/power/solar/fake/Initialize(mapload, var/obj/item/solar_assembly/S)
|
|
. = ..(mapload, S, 0)
|
|
|
|
/obj/machinery/power/solar/fake/process()
|
|
. = PROCESS_KILL
|
|
return
|
|
|
|
//trace towards sun to see if we're in shadow
|
|
/obj/machinery/power/solar/proc/occlusion()
|
|
|
|
var/ax = x // start at the solar panel
|
|
var/ay = y
|
|
var/turf/T = null
|
|
|
|
for(var/i = 1 to 20) // 20 steps is enough
|
|
ax += sun.dx // do step
|
|
ay += sun.dy
|
|
|
|
T = locate( round(ax,0.5),round(ay,0.5),z)
|
|
|
|
if(!T || T.x == 1 || T.x==world.maxx || T.y==1 || T.y==world.maxy) // not obscured if we reach the edge
|
|
break
|
|
|
|
if(T.opacity) // if we hit a solid turf, panel is obscured
|
|
obscured = 1
|
|
return
|
|
|
|
obscured = 0 // if hit the edge or stepped 20 times, not obscured
|
|
update_solar_exposure()
|
|
|
|
|
|
//
|
|
// Solar Assembly - For construction of solar arrays.
|
|
//
|
|
|
|
/obj/item/solar_assembly
|
|
name = "solar panel assembly"
|
|
desc = "A solar panel assembly kit, allows constructions of a solar panel, or with a tracking circuit board, a solar tracker"
|
|
icon = 'icons/obj/power.dmi'
|
|
icon_state = "sp_base"
|
|
item_state = "electropack"
|
|
w_class = 4 // Pretty big!
|
|
anchored = 0
|
|
var/tracker = 0
|
|
var/glass_type = null
|
|
|
|
/obj/item/solar_assembly/attack_hand(var/mob/user)
|
|
if(!anchored && isturf(loc)) // You can't pick it up
|
|
..()
|
|
|
|
// Give back the glass type we were supplied with
|
|
/obj/item/solar_assembly/proc/give_glass()
|
|
if(glass_type)
|
|
var/obj/item/stack/material/S = new glass_type(src.loc)
|
|
S.amount = 2
|
|
glass_type = null
|
|
|
|
|
|
/obj/item/solar_assembly/attackby(var/obj/item/weapon/W, var/mob/user)
|
|
|
|
if(!anchored && isturf(loc))
|
|
if(istype(W, /obj/item/weapon/wrench))
|
|
anchored = 1
|
|
user.visible_message("<span class='notice'>[user] wrenches the solar assembly into place.</span>")
|
|
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
|
|
return 1
|
|
else
|
|
if(istype(W, /obj/item/weapon/wrench))
|
|
anchored = 0
|
|
user.visible_message("<span class='notice'>[user] unwrenches the solar assembly from it's place.</span>")
|
|
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
|
|
return 1
|
|
|
|
if(istype(W, /obj/item/stack/material) && (W.get_material_name() == "glass" || W.get_material_name() == "rglass"))
|
|
var/obj/item/stack/material/S = W
|
|
if(S.use(2))
|
|
glass_type = W.type
|
|
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
|
user.visible_message("<span class='notice'>[user] places the glass on the solar assembly.</span>")
|
|
if(tracker)
|
|
new /obj/machinery/power/tracker(get_turf(src), src)
|
|
else
|
|
new /obj/machinery/power/solar(get_turf(src), src)
|
|
else
|
|
user << "<span class='warning'>You need two sheets of glass to put them into a solar panel.</span>"
|
|
return
|
|
return 1
|
|
|
|
if(!tracker)
|
|
if(istype(W, /obj/item/weapon/tracker_electronics))
|
|
tracker = 1
|
|
user.drop_item()
|
|
qdel(W)
|
|
user.visible_message("<span class='notice'>[user] inserts the electronics into the solar assembly.</span>")
|
|
return 1
|
|
else
|
|
if(istype(W, /obj/item/weapon/crowbar))
|
|
new /obj/item/weapon/tracker_electronics(src.loc)
|
|
tracker = 0
|
|
user.visible_message("<span class='notice'>[user] takes out the electronics from the solar assembly.</span>")
|
|
return 1
|
|
..()
|
|
|
|
//
|
|
// Solar Control Computer
|
|
//
|
|
|
|
/obj/machinery/power/solar_control
|
|
name = "solar panel control"
|
|
desc = "A controller for solar panel arrays."
|
|
icon = 'icons/obj/computer.dmi'
|
|
icon_state = "solar_control"
|
|
anchored = 1
|
|
density = 1
|
|
use_power = 1
|
|
idle_power_usage = 250
|
|
var/id = 0
|
|
var/cdir = 0
|
|
var/targetdir = 0 // target angle in manual tracking (since it updates every game minute)
|
|
var/gen = 0
|
|
var/lastgen = 0
|
|
var/track = 0 // 0= off 1=timed 2=auto (tracker)
|
|
var/trackrate = 600 // 300-900 seconds
|
|
var/nexttime = 0 // time for a panel to rotate of 1° in manual tracking
|
|
var/obj/machinery/power/tracker/connected_tracker = null
|
|
var/list/connected_panels = list()
|
|
|
|
/obj/machinery/power/solar_control/drain_power()
|
|
return -1
|
|
|
|
/obj/machinery/power/solar_control/Destroy()
|
|
for(var/obj/machinery/power/solar/M in connected_panels)
|
|
M.unset_control()
|
|
if(connected_tracker)
|
|
connected_tracker.unset_control()
|
|
return ..()
|
|
|
|
/obj/machinery/power/solar_control/disconnect_from_network()
|
|
..()
|
|
sun.solars -= src
|
|
|
|
/obj/machinery/power/solar_control/connect_to_network()
|
|
var/to_return = ..()
|
|
if(powernet) //if connected and not already in solar_list...
|
|
sun.solars |= src //... add it
|
|
return to_return
|
|
|
|
//search for unconnected panels and trackers in the computer powernet and connect them
|
|
/obj/machinery/power/solar_control/proc/search_for_connected()
|
|
if(powernet)
|
|
for(var/obj/machinery/power/M in powernet.nodes)
|
|
if(istype(M, /obj/machinery/power/solar))
|
|
var/obj/machinery/power/solar/S = M
|
|
if(!S.control) //i.e unconnected
|
|
S.set_control(src)
|
|
connected_panels |= S
|
|
else if(istype(M, /obj/machinery/power/tracker))
|
|
if(!connected_tracker) //if there's already a tracker connected to the computer don't add another
|
|
var/obj/machinery/power/tracker/T = M
|
|
if(!T.control) //i.e unconnected
|
|
connected_tracker = T
|
|
T.set_control(src)
|
|
|
|
//called by the sun controller, update the facing angle (either manually or via tracking) and rotates the panels accordingly
|
|
/obj/machinery/power/solar_control/proc/update()
|
|
if(stat & (NOPOWER | BROKEN))
|
|
return
|
|
|
|
switch(track)
|
|
if(1)
|
|
if(trackrate) //we're manual tracking. If we set a rotation speed...
|
|
cdir = targetdir //...the current direction is the targetted one (and rotates panels to it)
|
|
if(2) // auto-tracking
|
|
if(connected_tracker)
|
|
connected_tracker.set_angle(sun.angle)
|
|
|
|
set_panels(cdir)
|
|
updateDialog()
|
|
|
|
|
|
/obj/machinery/power/solar_control/Initialize()
|
|
. = ..()
|
|
if(!connect_to_network()) return
|
|
set_panels(cdir)
|
|
|
|
/obj/machinery/power/solar_control/update_icon()
|
|
if(stat & BROKEN)
|
|
icon_state = "broken"
|
|
cut_overlays()
|
|
return
|
|
if(stat & NOPOWER)
|
|
icon_state = "computer"
|
|
cut_overlays()
|
|
return
|
|
icon_state = "solar_control"
|
|
cut_overlays()
|
|
if(cdir > -1)
|
|
add_overlay(image('icons/obj/computer.dmi', "solcon-o", FLY_LAYER, angle2dir(cdir)))
|
|
return
|
|
|
|
/obj/machinery/power/solar_control/attack_hand(mob/user)
|
|
if(!..())
|
|
interact(user)
|
|
|
|
/obj/machinery/power/solar_control/interact(mob/user)
|
|
|
|
var/t = "<B><span class='highlight'>Generated power</span></B> : [round(lastgen)] W<BR>"
|
|
t += "<B><span class='highlight'>Star Orientation</span></B>: [sun.angle]° ([angle2text(sun.angle)])<BR>"
|
|
t += "<B><span class='highlight'>Array Orientation</span></B>: [rate_control(src,"cdir","[cdir]°",1,15)] ([angle2text(cdir)])<BR>"
|
|
t += "<B><span class='highlight'>Tracking:</span></B><div class='statusDisplay'>"
|
|
switch(track)
|
|
if(0)
|
|
t += "<span class='linkOn'>Off</span> <A href='?src=\ref[src];track=1'>Timed</A> <A href='?src=\ref[src];track=2'>Auto</A><BR>"
|
|
if(1)
|
|
t += "<A href='?src=\ref[src];track=0'>Off</A> <span class='linkOn'>Timed</span> <A href='?src=\ref[src];track=2'>Auto</A><BR>"
|
|
if(2)
|
|
t += "<A href='?src=\ref[src];track=0'>Off</A> <A href='?src=\ref[src];track=1'>Timed</A> <span class='linkOn'>Auto</span><BR>"
|
|
|
|
t += "Tracking Rate: [rate_control(src,"tdir","[trackrate] deg/h ([trackrate<0 ? "CCW" : "CW"])",1,30,180)]</div><BR>"
|
|
|
|
t += "<B><span class='highlight'>Connected devices:</span></B><div class='statusDisplay'>"
|
|
|
|
t += "<A href='?src=\ref[src];search_connected=1'>Search for devices</A><BR>"
|
|
t += "Solar panels : [connected_panels.len] connected<BR>"
|
|
t += "Solar tracker : [connected_tracker ? "<span class='good'>Found</span>" : "<span class='bad'>Not found</span>"]</div><BR>"
|
|
|
|
t += "<A href='?src=\ref[src];close=1'>Close</A>"
|
|
|
|
var/datum/browser/popup = new(user, "solar", name)
|
|
popup.set_content(t)
|
|
popup.open()
|
|
|
|
return
|
|
|
|
/obj/machinery/power/solar_control/attackby(I as obj, user as mob)
|
|
if(istype(I, /obj/item/weapon/screwdriver))
|
|
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
|
|
if(do_after(user, 20))
|
|
if (src.stat & BROKEN)
|
|
user << "\blue The broken glass falls out."
|
|
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
|
|
new /obj/item/weapon/material/shard( src.loc )
|
|
var/obj/item/weapon/circuitboard/solar_control/M = new /obj/item/weapon/circuitboard/solar_control( A )
|
|
for (var/obj/C in src)
|
|
C.loc = src.loc
|
|
A.circuit = M
|
|
A.state = 3
|
|
A.icon_state = "3"
|
|
A.anchored = 1
|
|
qdel(src)
|
|
else
|
|
user << "\blue You disconnect the monitor."
|
|
var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc )
|
|
var/obj/item/weapon/circuitboard/solar_control/M = new /obj/item/weapon/circuitboard/solar_control( A )
|
|
for (var/obj/C in src)
|
|
C.loc = src.loc
|
|
A.circuit = M
|
|
A.state = 4
|
|
A.icon_state = "4"
|
|
A.anchored = 1
|
|
qdel(src)
|
|
else
|
|
src.attack_hand(user)
|
|
return
|
|
|
|
/obj/machinery/power/solar_control/process()
|
|
lastgen = gen
|
|
gen = 0
|
|
|
|
if(stat & (NOPOWER | BROKEN))
|
|
return
|
|
|
|
if(connected_tracker) //NOTE : handled here so that we don't add trackers to the processing list
|
|
if(connected_tracker.powernet != powernet)
|
|
connected_tracker.unset_control()
|
|
|
|
if(track==1 && trackrate) //manual tracking and set a rotation speed
|
|
if(nexttime <= world.time) //every time we need to increase/decrease the angle by 1°...
|
|
targetdir = (targetdir + trackrate/abs(trackrate) + 360) % 360 //... do it
|
|
nexttime += 36000/abs(trackrate) //reset the counter for the next 1°
|
|
|
|
updateDialog()
|
|
|
|
/obj/machinery/power/solar_control/Topic(href, href_list)
|
|
if(..())
|
|
usr << browse(null, "window=solcon")
|
|
usr.unset_machine()
|
|
return 0
|
|
if(href_list["close"] )
|
|
usr << browse(null, "window=solcon")
|
|
usr.unset_machine()
|
|
return 0
|
|
|
|
if(href_list["rate control"])
|
|
if(href_list["cdir"])
|
|
src.cdir = dd_range(0,359,(360+src.cdir+text2num(href_list["cdir"]))%360)
|
|
src.targetdir = src.cdir
|
|
if(track == 2) //manual update, so losing auto-tracking
|
|
track = 0
|
|
spawn(1)
|
|
set_panels(cdir)
|
|
if(href_list["tdir"])
|
|
src.trackrate = dd_range(-7200,7200,src.trackrate+text2num(href_list["tdir"]))
|
|
if(src.trackrate) nexttime = world.time + 36000/abs(trackrate)
|
|
|
|
if(href_list["track"])
|
|
track = text2num(href_list["track"])
|
|
if(track == 2)
|
|
if(connected_tracker)
|
|
connected_tracker.set_angle(sun.angle)
|
|
set_panels(cdir)
|
|
else if (track == 1) //begin manual tracking
|
|
src.targetdir = src.cdir
|
|
if(src.trackrate) nexttime = world.time + 36000/abs(trackrate)
|
|
set_panels(targetdir)
|
|
|
|
if(href_list["search_connected"])
|
|
src.search_for_connected()
|
|
if(connected_tracker && track == 2)
|
|
connected_tracker.set_angle(sun.angle)
|
|
src.set_panels(cdir)
|
|
|
|
interact(usr)
|
|
return 1
|
|
|
|
//rotates the panel to the passed angle
|
|
/obj/machinery/power/solar_control/proc/set_panels(var/cdir)
|
|
|
|
for(var/obj/machinery/power/solar/S in connected_panels)
|
|
S.adir = cdir //instantly rotates the panel
|
|
S.occlusion()//and
|
|
S.update_icon() //update it
|
|
|
|
update_icon()
|
|
|
|
|
|
/obj/machinery/power/solar_control/power_change()
|
|
..()
|
|
update_icon()
|
|
|
|
|
|
/obj/machinery/power/solar_control/proc/broken()
|
|
stat |= BROKEN
|
|
update_icon()
|
|
|
|
|
|
/obj/machinery/power/solar_control/ex_act(severity)
|
|
switch(severity)
|
|
if(1.0)
|
|
//SN src = null
|
|
qdel(src)
|
|
return
|
|
if(2.0)
|
|
if (prob(50))
|
|
broken()
|
|
if(3.0)
|
|
if (prob(25))
|
|
broken()
|
|
return
|
|
|
|
// Used for mapping in solar array which automatically starts itself (telecomms, for example)
|
|
/obj/machinery/power/solar_control/autostart
|
|
track = 2 // Auto tracking mode
|
|
|
|
/obj/machinery/power/solar_control/autostart/Initialize()
|
|
. = ..()
|
|
src.search_for_connected()
|
|
if(connected_tracker && track == 2)
|
|
connected_tracker.set_angle(sun.angle)
|
|
src.set_panels(cdir)
|
|
|
|
//
|
|
// MISC
|
|
//
|
|
|
|
/obj/item/weapon/paper/solar
|
|
name = "paper- 'Going green! Setup your own solar array instructions.'"
|
|
info = "<h1>Welcome</h1><p>At greencorps we love the environment, and space. With this package you are able to help mother nature and produce energy without any usage of fossil fuel or phoron! Singularity energy is dangerous while solar energy is safe, which is why it's better. Now here is how you setup your own solar array.</p><p>You can make a solar panel by wrenching the solar assembly onto a cable node. Adding a glass panel, reinforced or regular glass will do, will finish the construction of your solar panel. It is that easy!</p><p>Now after setting up 19 more of these solar panels you will want to create a solar tracker to keep track of our mother nature's gift, the sun. These are the same steps as before except you insert the tracker equipment circuit into the assembly before performing the final step of adding the glass. You now have a tracker! Now the last step is to add a computer to calculate the sun's movements and to send commands to the solar panels to change direction with the sun. Setting up the solar computer is the same as setting up any computer, so you should have no trouble in doing that. You do need to put a wire node under the computer, and the wire needs to be connected to the tracker.</p><p>Congratulations, you should have a working solar array. If you are having trouble, here are some tips. Make sure all solar equipment are on a cable node, even the computer. You can always deconstruct your creations if you make a mistake.</p><p>That's all to it, be safe, be green!</p>"
|
|
|
|
/proc/rate_control(var/S, var/V, var/C, var/Min=1, var/Max=5, var/Limit=null) //How not to name vars
|
|
var/href = "<A href='?src=\ref[S];rate control=1;[V]"
|
|
var/rate = "[href]=-[Max]'>-</A>[href]=-[Min]'>-</A> [(C?C : 0)] [href]=[Min]'>+</A>[href]=[Max]'>+</A>"
|
|
if(Limit) return "[href]=-[Limit]'>-</A>"+rate+"[href]=[Limit]'>+</A>"
|
|
return rate
|