Merge pull request #11241 from Arturlang/Solar_updates
Ports TGs Solar updates.
This commit is contained in:
@@ -208,7 +208,7 @@
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
// Destroy the Solar Arrays
|
||||
/datum/objective/bloodsucker/solars
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
if (SC && SC.lastgen > 0 && SC.connected_panels.len > 0 && SC.connected_tracker)
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -379,20 +379,21 @@
|
||||
protege_objective.generate_objective()
|
||||
add_objective(protege_objective)
|
||||
|
||||
if (rand(0,1) == 0)
|
||||
//if (rand(0,1) == 0)
|
||||
// Heart Thief Objective
|
||||
var/datum/objective/bloodsucker/heartthief/heartthief_objective = new
|
||||
heartthief_objective.owner = owner
|
||||
heartthief_objective.generate_objective()
|
||||
add_objective(heartthief_objective)
|
||||
|
||||
var/datum/objective/bloodsucker/heartthief/heartthief_objective = new
|
||||
heartthief_objective.owner = owner
|
||||
heartthief_objective.generate_objective()
|
||||
add_objective(heartthief_objective)
|
||||
/*
|
||||
else
|
||||
// Solars Objective
|
||||
|
||||
// Solars Objective, doesnt work due to TG updates.
|
||||
var/datum/objective/bloodsucker/solars/solars_objective = new
|
||||
solars_objective.owner = owner
|
||||
solars_objective.generate_objective()
|
||||
add_objective(solars_objective)
|
||||
|
||||
*/
|
||||
// Survive Objective
|
||||
var/datum/objective/bloodsucker/survive/survive_objective = new
|
||||
survive_objective.owner = owner
|
||||
|
||||
+186
-197
@@ -1,5 +1,5 @@
|
||||
#define SOLAR_MAX_DIST 40
|
||||
#define SOLARGENRATE 1500
|
||||
#define SOLAR_GEN_RATE 1500
|
||||
#define OCCLUSION_DISTANCE 20
|
||||
|
||||
/obj/machinery/power/solar
|
||||
name = "solar panel"
|
||||
@@ -10,20 +10,53 @@
|
||||
use_power = NO_POWER_USE
|
||||
idle_power_usage = 0
|
||||
active_power_usage = 0
|
||||
var/id = 0
|
||||
max_integrity = 150
|
||||
integrity_failure = 0.33
|
||||
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
|
||||
|
||||
var/id
|
||||
var/obscured = FALSE
|
||||
var/sunfrac = 0 //[0-1] measure of obscuration -- multipllier against power generation
|
||||
var/azimuth_current = 0 //[0-360) degrees, which direction are we facing?
|
||||
var/azimuth_target = 0 //same but what way we're going to face next time we turn
|
||||
var/obj/machinery/power/solar_control/control
|
||||
var/needs_to_turn = TRUE //do we need to turn next tick?
|
||||
var/needs_to_update_solar_exposure = TRUE //do we need to call update_solar_exposure() next tick?
|
||||
var/obj/effect/overlay/panel
|
||||
var/obj/item/solar_assembly/assembly
|
||||
var/efficiency = 1
|
||||
|
||||
/obj/machinery/power/solar/Initialize(mapload, obj/item/solar_assembly/S)
|
||||
. = ..()
|
||||
panel = new()
|
||||
#if DM_VERSION >= 513
|
||||
panel.vis_flags = VIS_INHERIT_ID|VIS_INHERIT_ICON|VIS_INHERIT_PLANE
|
||||
vis_contents += panel
|
||||
#endif
|
||||
panel.icon = icon
|
||||
panel.icon_state = "solar_panel"
|
||||
panel.layer = FLY_LAYER
|
||||
Make(S)
|
||||
connect_to_network()
|
||||
RegisterSignal(SSsun, COMSIG_SUN_MOVED, .proc/queue_update_solar_exposure)
|
||||
|
||||
/obj/machinery/power/solar/Destroy()
|
||||
unset_control() //remove from control computer
|
||||
return ..()
|
||||
|
||||
//set the control of the panel to a given computer
|
||||
/obj/machinery/power/solar/proc/set_control(obj/machinery/power/solar_control/SC)
|
||||
unset_control()
|
||||
control = SC
|
||||
SC.connected_panels += src
|
||||
queue_turn(SC.azimuth_target)
|
||||
|
||||
//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 -= src
|
||||
control = null
|
||||
|
||||
/obj/machinery/power/solar/proc/Make(obj/item/solar_assembly/S)
|
||||
if(!S)
|
||||
assembly = new /obj/item/solar_assembly
|
||||
assembly.glass_type = new /obj/item/stack/sheet/glass(null, 2)
|
||||
@@ -34,32 +67,13 @@
|
||||
assembly.glass_type.on_solar_construction(src)
|
||||
obj_integrity = max_integrity
|
||||
update_icon()
|
||||
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(obj/machinery/power/solar_control/SC)
|
||||
if(!SC || (get_dist(src, SC) > SOLAR_MAX_DIST))
|
||||
return 0
|
||||
control = SC
|
||||
SC.connected_panels |= src
|
||||
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/crowbar_act(mob/user, obj/item/I)
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
||||
user.visible_message("[user] begins to take the glass off [src].", "<span class='notice'>You begin to take the glass off [src]...</span>")
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, TRUE)
|
||||
user.visible_message("<span class='notice'>[user] begins to take the glass off [src].</span>", "<span class='notice'>You begin to take the glass off [src]...</span>")
|
||||
if(I.use_tool(src, user, 50))
|
||||
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, 1)
|
||||
user.visible_message("[user] takes the glass off [src].", "<span class='notice'>You take the glass off [src].</span>")
|
||||
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE)
|
||||
user.visible_message("<span class='notice'>[user] takes the glass off [src].</span>", "<span class='notice'>You take the glass off [src].</span>")
|
||||
deconstruct(TRUE)
|
||||
return TRUE
|
||||
|
||||
@@ -67,16 +81,16 @@
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(stat & BROKEN)
|
||||
playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 60, 1)
|
||||
playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 60, TRUE)
|
||||
else
|
||||
playsound(loc, 'sound/effects/glasshit.ogg', 90, 1)
|
||||
playsound(loc, 'sound/effects/glasshit.ogg', 90, TRUE)
|
||||
if(BURN)
|
||||
playsound(loc, 'sound/items/welder.ogg', 100, 1)
|
||||
playsound(loc, 'sound/items/welder.ogg', 100, TRUE)
|
||||
|
||||
|
||||
/obj/machinery/power/solar/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags_1 & NODECONSTRUCT_1))
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, 1)
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
|
||||
stat |= BROKEN
|
||||
unset_control()
|
||||
update_icon()
|
||||
@@ -94,81 +108,95 @@
|
||||
new shard(loc)
|
||||
qdel(src)
|
||||
|
||||
|
||||
/obj/machinery/power/solar/update_icon()
|
||||
..()
|
||||
cut_overlays()
|
||||
/obj/machinery/power/solar/update_overlays()
|
||||
. = ..()
|
||||
var/matrix/turner = matrix()
|
||||
turner.Turn(azimuth_current)
|
||||
panel.transform = turner
|
||||
if(stat & BROKEN)
|
||||
add_overlay(mutable_appearance(icon, "solar_panel-b", FLY_LAYER))
|
||||
panel.icon_state = "solar_panel-b"
|
||||
else
|
||||
add_overlay(mutable_appearance(icon, "solar_panel", FLY_LAYER))
|
||||
src.setDir(angle2dir(adir))
|
||||
panel.icon_state = "solar_panel"
|
||||
#if DM_VERSION <= 512
|
||||
. += new /mutable_appearance(panel)
|
||||
#endif
|
||||
|
||||
//calculates the fraction of the sunlight that the panel receives
|
||||
/obj/machinery/power/solar/proc/queue_turn(azimuth)
|
||||
needs_to_turn = TRUE
|
||||
azimuth_target = azimuth
|
||||
|
||||
/obj/machinery/power/solar/proc/queue_update_solar_exposure()
|
||||
needs_to_update_solar_exposure = TRUE //updating right away would be wasteful if we're also turning later
|
||||
|
||||
/obj/machinery/power/solar/proc/update_turn()
|
||||
needs_to_turn = FALSE
|
||||
if(azimuth_current != azimuth_target)
|
||||
azimuth_current = azimuth_target
|
||||
occlusion_setup()
|
||||
update_icon()
|
||||
needs_to_update_solar_exposure = TRUE
|
||||
|
||||
///trace towards sun to see if we're in shadow
|
||||
/obj/machinery/power/solar/proc/occlusion_setup()
|
||||
obscured = TRUE
|
||||
|
||||
var/distance = OCCLUSION_DISTANCE
|
||||
var/target_x = round(sin(SSsun.azimuth), 0.01)
|
||||
var/target_y = round(cos(SSsun.azimuth), 0.01)
|
||||
var/x_hit = x
|
||||
var/y_hit = y
|
||||
var/turf/hit
|
||||
|
||||
for(var/run in 1 to distance)
|
||||
x_hit += target_x
|
||||
y_hit += target_y
|
||||
hit = locate(round(x_hit, 1), round(y_hit, 1), z)
|
||||
if(hit.opacity)
|
||||
return
|
||||
if(hit.x == 1 || hit.x == world.maxx || hit.y == 1 || hit.y == world.maxy) //edge of the map
|
||||
break
|
||||
obscured = FALSE
|
||||
|
||||
///calculates the fraction of the sunlight that the panel receives
|
||||
/obj/machinery/power/solar/proc/update_solar_exposure()
|
||||
needs_to_update_solar_exposure = FALSE
|
||||
sunfrac = 0
|
||||
if(obscured)
|
||||
sunfrac = 0
|
||||
return
|
||||
return 0
|
||||
|
||||
//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 - SSsun.angle), 360 - abs(adir - SSsun.angle))
|
||||
var/sun_azimuth = SSsun.azimuth
|
||||
if(azimuth_current == sun_azimuth) //just a quick optimization for the most frequent case
|
||||
. = 1
|
||||
else
|
||||
//dot product of sun and panel -- Lambert's Cosine Law
|
||||
. = cos(azimuth_current - sun_azimuth)
|
||||
. = CLAMP(round(., 0.01), 0, 1)
|
||||
sunfrac = .
|
||||
|
||||
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 received 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
|
||||
/obj/machinery/power/solar/process()
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
if(!control) //if there's no sun or the panel is not linked to a solar control computer, no need to proceed
|
||||
if(control && (!powernet || control.powernet != powernet))
|
||||
unset_control()
|
||||
if(needs_to_turn)
|
||||
update_turn()
|
||||
if(needs_to_update_solar_exposure)
|
||||
update_solar_exposure()
|
||||
if(sunfrac <= 0)
|
||||
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 * efficiency
|
||||
add_avail(sgen)
|
||||
control.gen += sgen
|
||||
else //if we're no longer on the same powernet, remove from control computer
|
||||
unset_control()
|
||||
var/sgen = SOLAR_GEN_RATE * sunfrac
|
||||
add_avail(sgen)
|
||||
if(control)
|
||||
control.gen += sgen
|
||||
|
||||
|
||||
/obj/machinery/power/solar/fake/New(var/turf/loc, var/obj/item/solar_assembly/S)
|
||||
..(loc, S, 0)
|
||||
//Bit of a hack but this whole type is a hack
|
||||
/obj/machinery/power/solar/fake/Initialize(turf/loc, obj/item/solar_assembly/S)
|
||||
. = ..()
|
||||
UnregisterSignal(SSsun, COMSIG_SUN_MOVED)
|
||||
|
||||
/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
|
||||
var/dx = SSsun.dx
|
||||
var/dy = SSsun.dy
|
||||
|
||||
for(var/i = 1 to 20) // 20 steps is enough
|
||||
ax += dx // do step
|
||||
ay += dy
|
||||
|
||||
T = locate( round(ax,0.5),round(ay,0.5),z)
|
||||
|
||||
if(T.x == 1 || T.x==world.maxx || T.y==1 || T.y==world.maxy) // not obscured if we reach the edge
|
||||
break
|
||||
|
||||
if(T.density) // 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()
|
||||
|
||||
return PROCESS_KILL
|
||||
|
||||
//
|
||||
// Solar Assembly - For construction of solar arrays.
|
||||
@@ -202,6 +230,7 @@
|
||||
glass_type.forceMove(Tsec)
|
||||
glass_type = null
|
||||
|
||||
|
||||
/obj/item/solar_assembly/attackby(obj/item/W, mob/user, params)
|
||||
if(istype(W, /obj/item/wrench) && isturf(loc))
|
||||
if(isinspace())
|
||||
@@ -224,8 +253,7 @@
|
||||
var/obj/item/stack/sheet/G = S.change_stack(null, 2)
|
||||
if(G)
|
||||
glass_type = G
|
||||
G.moveToNullspace()
|
||||
playsound(loc, 'sound/machines/click.ogg', 50, 1)
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
||||
user.visible_message("[user] places the glass on the solar assembly.", "<span class='notice'>You place the glass on the solar assembly.</span>")
|
||||
if(tracker)
|
||||
new /obj/machinery/power/tracker(get_turf(src), src)
|
||||
@@ -269,21 +297,23 @@
|
||||
var/icon_screen = "solar"
|
||||
var/icon_keyboard = "power_key"
|
||||
var/id = 0
|
||||
var/currentdir = 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 degree in manual tracking
|
||||
var/azimuth_target = 0
|
||||
var/azimuth_rate = 1 ///degree change per minute
|
||||
|
||||
var/track = SOLAR_TRACK_OFF ///SOLAR_TRACK_OFF, SOLAR_TRACK_TIMED, SOLAR_TRACK_AUTO
|
||||
|
||||
var/obj/machinery/power/tracker/connected_tracker = null
|
||||
var/list/connected_panels = list()
|
||||
|
||||
/obj/machinery/power/solar_control/Initialize()
|
||||
. = ..()
|
||||
if(powernet)
|
||||
set_panels(currentdir)
|
||||
azimuth_rate = SSsun.base_rotation
|
||||
RegisterSignal(SSsun, COMSIG_SUN_MOVED, .proc/timed_track)
|
||||
connect_to_network()
|
||||
if(powernet)
|
||||
set_panels(azimuth_target)
|
||||
|
||||
/obj/machinery/power/solar_control/Destroy()
|
||||
for(var/obj/machinery/power/solar/M in connected_panels)
|
||||
@@ -292,16 +322,6 @@
|
||||
connected_tracker.unset_control()
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/solar_control/disconnect_from_network()
|
||||
..()
|
||||
SSsun.solars.Remove(src)
|
||||
|
||||
/obj/machinery/power/solar_control/connect_to_network()
|
||||
var/to_return = ..()
|
||||
if(powernet) //if connected and not already in solar_list...
|
||||
SSsun.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)
|
||||
@@ -316,32 +336,16 @@
|
||||
if(!T.control) //i.e unconnected
|
||||
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...
|
||||
currentdir = targetdir //...the current direction is the targetted one (and rotates panels to it)
|
||||
if(2) // auto-tracking
|
||||
if(connected_tracker)
|
||||
connected_tracker.set_angle(SSsun.angle)
|
||||
|
||||
set_panels(currentdir)
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/power/solar_control/update_icon()
|
||||
cut_overlays()
|
||||
/obj/machinery/power/solar_control/update_overlays()
|
||||
. = ..()
|
||||
if(stat & NOPOWER)
|
||||
add_overlay("[icon_keyboard]_off")
|
||||
. += mutable_appearance(icon, "[icon_keyboard]_off")
|
||||
return
|
||||
add_overlay(icon_keyboard)
|
||||
. += mutable_appearance(icon, icon_keyboard)
|
||||
if(stat & BROKEN)
|
||||
add_overlay("[icon_state]_broken")
|
||||
. += mutable_appearance(icon, "[icon_state]_broken")
|
||||
else
|
||||
add_overlay(icon_screen)
|
||||
. += mutable_appearance(icon, icon_screen)
|
||||
|
||||
/obj/machinery/power/solar_control/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
@@ -352,73 +356,60 @@
|
||||
|
||||
/obj/machinery/power/solar_control/ui_data()
|
||||
var/data = list()
|
||||
|
||||
data["generated"] = round(lastgen)
|
||||
data["angle"] = currentdir
|
||||
data["direction"] = angle2text(currentdir)
|
||||
|
||||
data["generated_ratio"] = data["generated"] / round(max(connected_panels.len, 1) * SOLAR_GEN_RATE)
|
||||
data["azimuth_current"] = azimuth_target
|
||||
data["azimuth_rate"] = azimuth_rate
|
||||
data["max_rotation_rate"] = SSsun.base_rotation * 2
|
||||
data["tracking_state"] = track
|
||||
data["tracking_rate"] = trackrate
|
||||
data["rotating_way"] = (trackrate<0 ? "CCW" : "CW")
|
||||
|
||||
data["connected_panels"] = connected_panels.len
|
||||
data["connected_tracker"] = (connected_tracker ? 1 : 0)
|
||||
data["connected_tracker"] = (connected_tracker ? TRUE : FALSE)
|
||||
return data
|
||||
|
||||
/obj/machinery/power/solar_control/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
if(action == "angle")
|
||||
if(action == "azimuth")
|
||||
var/adjust = text2num(params["adjust"])
|
||||
var/value = text2num(params["value"])
|
||||
if(adjust)
|
||||
value = currentdir + adjust
|
||||
value = azimuth_target + adjust
|
||||
if(value != null)
|
||||
currentdir = CLAMP((360 + value) % 360, 0, 359)
|
||||
targetdir = currentdir
|
||||
set_panels(currentdir)
|
||||
set_panels(value)
|
||||
return TRUE
|
||||
return FALSE
|
||||
if(action == "rate")
|
||||
if(action == "azimuth_rate")
|
||||
var/adjust = text2num(params["adjust"])
|
||||
var/value = text2num(params["value"])
|
||||
if(adjust)
|
||||
value = trackrate + adjust
|
||||
value = azimuth_rate + adjust
|
||||
if(value != null)
|
||||
trackrate = CLAMP(value, -7200, 7200)
|
||||
if(trackrate)
|
||||
nexttime = world.time + 36000 / abs(trackrate)
|
||||
azimuth_rate = round(CLAMP(value, -2 * SSsun.base_rotation, 2 * SSsun.base_rotation), 0.01)
|
||||
return TRUE
|
||||
return FALSE
|
||||
if(action == "tracking")
|
||||
var/mode = text2num(params["mode"])
|
||||
track = mode
|
||||
if(mode == 2 && connected_tracker)
|
||||
connected_tracker.set_angle(SSsun.angle)
|
||||
set_panels(currentdir)
|
||||
else if(mode == 1)
|
||||
targetdir = currentdir
|
||||
if(trackrate)
|
||||
nexttime = world.time + 36000 / abs(trackrate)
|
||||
set_panels(targetdir)
|
||||
if(mode == SOLAR_TRACK_AUTO)
|
||||
if(connected_tracker)
|
||||
connected_tracker.sun_update(SSsun, SSsun.azimuth)
|
||||
else
|
||||
track = SOLAR_TRACK_OFF
|
||||
return TRUE
|
||||
if(action == "refresh")
|
||||
search_for_connected()
|
||||
if(connected_tracker && track == 2)
|
||||
connected_tracker.set_angle(SSsun.angle)
|
||||
set_panels(currentdir)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/machinery/power/solar_control/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/screwdriver))
|
||||
if(I.use_tool(src, user, 20, volume=50))
|
||||
if (src.stat & BROKEN)
|
||||
if(I.tool_behaviour == TOOL_SCREWDRIVER)
|
||||
if(I.use_tool(src, user, 20, volume = 50))
|
||||
if(src.stat & BROKEN)
|
||||
to_chat(user, "<span class='notice'>The broken glass falls out.</span>")
|
||||
var/obj/structure/frame/computer/A = new /obj/structure/frame/computer( src.loc )
|
||||
new /obj/item/shard( src.loc )
|
||||
var/obj/item/circuitboard/computer/solar_control/M = new /obj/item/circuitboard/computer/solar_control( A )
|
||||
for (var/obj/C in src)
|
||||
for(var/obj/C in src)
|
||||
C.forceMove(drop_location())
|
||||
A.circuit = M
|
||||
A.state = 3
|
||||
@@ -429,7 +420,7 @@
|
||||
to_chat(user, "<span class='notice'>You disconnect the monitor.</span>")
|
||||
var/obj/structure/frame/computer/A = new /obj/structure/frame/computer( src.loc )
|
||||
var/obj/item/circuitboard/computer/solar_control/M = new /obj/item/circuitboard/computer/solar_control( A )
|
||||
for (var/obj/C in src)
|
||||
for(var/obj/C in src)
|
||||
C.forceMove(drop_location())
|
||||
A.circuit = M
|
||||
A.state = 4
|
||||
@@ -445,15 +436,15 @@
|
||||
switch(damage_type)
|
||||
if(BRUTE)
|
||||
if(stat & BROKEN)
|
||||
playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1)
|
||||
playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, TRUE)
|
||||
else
|
||||
playsound(src.loc, 'sound/effects/glasshit.ogg', 75, 1)
|
||||
playsound(src.loc, 'sound/effects/glasshit.ogg', 75, TRUE)
|
||||
if(BURN)
|
||||
playsound(src.loc, 'sound/items/welder.ogg', 100, 1)
|
||||
playsound(src.loc, 'sound/items/welder.ogg', 100, TRUE)
|
||||
|
||||
/obj/machinery/power/solar_control/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags_1 & NODECONSTRUCT_1))
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, 1)
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
|
||||
stat |= BROKEN
|
||||
update_icon()
|
||||
|
||||
@@ -461,36 +452,31 @@
|
||||
lastgen = gen
|
||||
gen = 0
|
||||
|
||||
if(stat & (NOPOWER | BROKEN))
|
||||
return
|
||||
if(connected_tracker && (!powernet || connected_tracker.powernet != powernet))
|
||||
connected_tracker.unset_control()
|
||||
|
||||
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()
|
||||
///Ran every time the sun updates.
|
||||
/obj/machinery/power/solar_control/proc/timed_track()
|
||||
if(track == SOLAR_TRACK_TIMED)
|
||||
azimuth_target += azimuth_rate
|
||||
set_panels(azimuth_target)
|
||||
|
||||
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�
|
||||
|
||||
//rotates the panel to the passed angle
|
||||
/obj/machinery/power/solar_control/proc/set_panels(currentdir)
|
||||
///Rotates the panel to the passed angles
|
||||
/obj/machinery/power/solar_control/proc/set_panels(azimuth)
|
||||
azimuth = CLAMP(round(azimuth, 0.01), -360, 719.99)
|
||||
if(azimuth >= 360)
|
||||
azimuth -= 360
|
||||
if(azimuth < 0)
|
||||
azimuth += 360
|
||||
azimuth_target = azimuth
|
||||
|
||||
for(var/obj/machinery/power/solar/S in connected_panels)
|
||||
S.adir = currentdir //instantly rotates the panel
|
||||
S.occlusion()//and
|
||||
S.update_icon() //update it
|
||||
|
||||
update_icon()
|
||||
|
||||
S.queue_turn(azimuth)
|
||||
|
||||
/obj/machinery/power/solar_control/power_change()
|
||||
..()
|
||||
update_icon()
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// MISC
|
||||
//
|
||||
@@ -498,3 +484,6 @@
|
||||
/obj/item/paper/guides/jobs/engi/solars
|
||||
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 plasma! 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>"
|
||||
|
||||
#undef SOLAR_GEN_RATE
|
||||
#undef OCCLUSION_DISTANCE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//Solar tracker
|
||||
|
||||
//Machine that tracks the sun and reports it's direction to the solar controllers
|
||||
//Machine that tracks the sun and reports its direction to the solar controllers
|
||||
//As long as this is working, solar panels on same powernet will track automatically
|
||||
|
||||
/obj/machinery/power/tracker
|
||||
@@ -14,12 +14,39 @@
|
||||
integrity_failure = 0.2
|
||||
|
||||
var/id = 0
|
||||
var/sun_angle = 0 // sun angle as set by sun datum
|
||||
var/obj/machinery/power/solar_control/control = null
|
||||
var/obj/machinery/power/solar_control/control
|
||||
var/obj/item/solar_assembly/assembly
|
||||
|
||||
/obj/machinery/power/tracker/Initialize(mapload, obj/item/solar_assembly/S)
|
||||
. = ..()
|
||||
Make(S)
|
||||
connect_to_network()
|
||||
RegisterSignal(SSsun, COMSIG_SUN_MOVED, .proc/sun_update)
|
||||
|
||||
/obj/machinery/power/tracker/Destroy()
|
||||
unset_control() //remove from control computer
|
||||
return ..()
|
||||
|
||||
/obj/machinery/power/tracker/proc/set_control(obj/machinery/power/solar_control/SC)
|
||||
unset_control()
|
||||
control = SC
|
||||
SC.connected_tracker = src
|
||||
|
||||
//set the control of the tracker to null and removes it from the previous control computer if needed
|
||||
/obj/machinery/power/tracker/proc/unset_control()
|
||||
if(control)
|
||||
if(control.track == SOLAR_TRACK_AUTO)
|
||||
control.track = SOLAR_TRACK_OFF
|
||||
control.connected_tracker = null
|
||||
control = null
|
||||
|
||||
///Tell the controller to turn the solar panels
|
||||
/obj/machinery/power/tracker/proc/sun_update(datum/source, azimuth)
|
||||
setDir(angle2dir(azimuth))
|
||||
if(control && control.track == SOLAR_TRACK_AUTO)
|
||||
control.set_panels(azimuth)
|
||||
|
||||
/obj/machinery/power/tracker/proc/Make(obj/item/solar_assembly/S)
|
||||
if(!S)
|
||||
assembly = new /obj/item/solar_assembly
|
||||
assembly.glass_type = new /obj/item/stack/sheet/glass(null, 2)
|
||||
@@ -29,59 +56,29 @@
|
||||
S.moveToNullspace()
|
||||
assembly = S
|
||||
update_icon()
|
||||
connect_to_network()
|
||||
|
||||
/obj/machinery/power/tracker/Destroy()
|
||||
unset_control() //remove from control computer
|
||||
return ..()
|
||||
|
||||
//set the control of the tracker to a given computer if closer than SOLAR_MAX_DIST
|
||||
/obj/machinery/power/tracker/proc/set_control(obj/machinery/power/solar_control/SC)
|
||||
if(!SC || (get_dist(src, SC) > SOLAR_MAX_DIST))
|
||||
return 0
|
||||
control = SC
|
||||
SC.connected_tracker = src
|
||||
return 1
|
||||
|
||||
//set the control of the tracker to null and removes it from the previous control computer if needed
|
||||
/obj/machinery/power/tracker/proc/unset_control()
|
||||
if(control)
|
||||
control.connected_tracker = null
|
||||
control = null
|
||||
|
||||
//updates the tracker icon and the facing angle for the control computer
|
||||
/obj/machinery/power/tracker/proc/set_angle(angle)
|
||||
sun_angle = angle
|
||||
|
||||
//set icon dir to show sun illumination
|
||||
setDir(turn(NORTH, -angle - 22.5) )// 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
|
||||
|
||||
if(powernet && (powernet == control.powernet)) //update if we're still in the same powernet
|
||||
control.currentdir = angle
|
||||
|
||||
/obj/machinery/power/tracker/crowbar_act(mob/user, obj/item/I)
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
|
||||
user.visible_message("[user] begins to take the glass off [src].", "<span class='notice'>You begin to take the glass off [src]...</span>")
|
||||
playsound(src.loc, 'sound/machines/click.ogg', 50, TRUE)
|
||||
user.visible_message("<span class='notice'>[user] begins to take the glass off [src].</span>", "<span class='notice'>You begin to take the glass off [src]...</span>")
|
||||
if(I.use_tool(src, user, 50))
|
||||
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, 1)
|
||||
user.visible_message("[user] takes the glass off [src].", "<span class='notice'>You take the glass off [src].</span>")
|
||||
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE)
|
||||
user.visible_message("<span class='notice'>[user] takes the glass off [src].</span>", "<span class='notice'>You take the glass off [src].</span>")
|
||||
deconstruct(TRUE)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/tracker/obj_break(damage_flag)
|
||||
if(!(stat & BROKEN) && !(flags_1 & NODECONSTRUCT_1))
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, 1)
|
||||
stat |= BROKEN
|
||||
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
|
||||
unset_control()
|
||||
|
||||
/obj/machinery/power/solar/deconstruct(disassembled = TRUE)
|
||||
/obj/machinery/power/tracker/deconstruct(disassembled = TRUE)
|
||||
if(!(flags_1 & NODECONSTRUCT_1))
|
||||
if(disassembled)
|
||||
if(assembly)
|
||||
assembly.forceMove(loc)
|
||||
assembly.give_glass(stat & BROKEN)
|
||||
else
|
||||
playsound(src, "shatter", 70, 1)
|
||||
playsound(src, "shatter", 70, TRUE)
|
||||
var/shard = assembly?.glass_type ? assembly.glass_type.shard_type : /obj/item/shard
|
||||
new shard(loc)
|
||||
new shard(loc)
|
||||
|
||||
Reference in New Issue
Block a user