Browse Source

Solar improvements (#48110)

Improves the code for the solar panels a lot. It's still pretty bad but to make it better I'd have to dive into powernets.

Solar panels visually rotate a full 360 degrees instead of being locked to ordinal directions only. In 513 this uses vis_contents, in 512 it uses a regular overlay that needs to be reset constantly.
Adds a signal from the sun SS when the sun moves.
Timed tracking is now measured in degrees per minute instead of degrees per hour.
pride
MrPerson 8 months ago
committed by Emmett Gaines
parent
commit
e8ba7a1f68
8 changed files with 226 additions and 257 deletions
  1. +4
    -0
      code/__DEFINES/components.dm
  2. +4
    -0
      code/__DEFINES/power.dm
  3. +30
    -47
      code/controllers/subsystem/sun.dm
  4. +152
    -169
      code/modules/power/solar.dm
  5. +14
    -20
      code/modules/power/tracker.dm
  6. BIN
      goon/icons/obj/power.dmi
  7. +21
    -20
      tgui-next/packages/tgui/interfaces/SolarControl.js
  8. +1
    -1
      tgui-next/packages/tgui/public/tgui.bundle.js

+ 4
- 0
code/__DEFINES/components.dm View File

@@ -55,6 +55,10 @@
/// global living say plug - use sparingly: (mob/speaker , message)
#define COMSIG_GLOB_LIVING_SAY_SPECIAL "!say_special"
// signals from globally accessible objects
/// from SSsun when the sun changes position : (azimuth)
#define COMSIG_SUN_MOVED "sun_moved"
//////////////////////////////////////////////////////////////////
// /datum signals


+ 4
- 0
code/__DEFINES/power.dm View File

@@ -1,3 +1,7 @@
#define CABLE_LAYER_1 "l1"
#define CABLE_LAYER_2 "l2"
#define CABLE_LAYER_3 "l3"

#define SOLAR_TRACK_OFF 0
#define SOLAR_TRACK_TIMED 1
#define SOLAR_TRACK_AUTO 2

+ 30
- 47
code/controllers/subsystem/sun.dm View File

@@ -1,49 +1,32 @@
SUBSYSTEM_DEF(sun)
name = "Sun"
wait = 600
flags = SS_NO_TICK_CHECK|SS_NO_INIT
var/angle
var/dx
var/dy
var/rate
var/list/solars = list()

/datum/controller/subsystem/sun/PreInit()
angle = rand (0,360) // the station position to the sun is randomised at round start
rate = rand(50,200)/100 // 50% - 200% of standard rotation
if(prob(50)) // same chance to rotate clockwise than counter-clockwise
rate = -rate

/datum/controller/subsystem/sun/stat_entry(msg)
..("P:[solars.len]")

/datum/controller/subsystem/sun/fire()
angle = (360 + angle + rate * 6) % 360 // increase/decrease the angle to the sun, adjusted by the rate

// now calculate and cache the (dx,dy) increments for line drawing
var/s = sin(angle)
var/c = cos(angle)

// Either "abs(s) < abs(c)" or "abs(s) >= abs(c)"
// In both cases, the greater is greater than 0, so, no "if 0" check is needed for the divisions

if(abs(s) < abs(c))
dx = s / abs(c)
dy = c / abs(c)
else
dx = s / abs(s)
dy = c / abs(s)

//now tell the solar control computers to update their status and linked devices
for(var/obj/machinery/power/solar_control/SC in solars)
if(!SC.powernet)
solars.Remove(SC)
continue
SC.update()







wait = 1 MINUTES
flags = SS_NO_TICK_CHECK

var/azimuth = 0 ///clockwise, top-down rotation from 0 (north) to 359
var/azimuth_mod = 1 ///multiplier against base_rotation
var/base_rotation = 6 ///base rotation in degrees per fire

/datum/controller/subsystem/sun/Initialize(start_timeofday)
azimuth = rand(0, 359)
azimuth_mod = round(rand(50, 200)/100, 0.01) // 50% - 200% of standard rotation
if(prob(50))
azimuth_mod *= -1
return ..()

/datum/controller/subsystem/sun/fire(resumed = FALSE)
azimuth += azimuth_mod * base_rotation
azimuth = round(azimuth, 0.01)
if(azimuth >= 360)
azimuth -= 360
if(azimuth < 0)
azimuth += 360
complete_movement()

/datum/controller/subsystem/sun/proc/complete_movement()
SEND_SIGNAL(src, COMSIG_SUN_MOVED, azimuth)

/datum/controller/subsystem/sun/vv_edit_var(var_name, var_value)
. = ..()
if(var_name == NAMEOF(src, azimuth))
complete_movement()

+ 152
- 169
code/modules/power/solar.dm View File

@@ -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"
@@ -13,18 +13,29 @@
max_integrity = 150
integrity_failure = 0.33

var/id = 0
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

/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
@@ -33,19 +44,18 @@
/obj/machinery/power/solar/should_have_node()
return TRUE

//set the control of the panel to a given computer if closer than SOLAR_MAX_DIST
//set the control of the panel to a given computer
/obj/machinery/power/solar/proc/set_control(obj/machinery/power/solar_control/SC)
if(!SC || (get_dist(src, SC) > SOLAR_MAX_DIST))
return 0
unset_control()
control = SC
SC.connected_panels |= src
return 1
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.Remove(src)
control = null
control.connected_panels -= src
control = null

/obj/machinery/power/solar/proc/Make(obj/item/solar_assembly/S)
if(!S)
@@ -57,7 +67,6 @@
if(S.glass_type == /obj/item/stack/sheet/rglass) //if the panel is in reinforced glass
max_integrity *= 2 //this need to be placed here, because panels already on the map don't have an assembly linked to
obj_integrity = max_integrity
update_icon()

/obj/machinery/power/solar/crowbar_act(mob/user, obj/item/I)
playsound(src.loc, 'sound/machines/click.ogg', 50, TRUE)
@@ -98,81 +107,95 @@
new /obj/item/shard(src.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

/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
///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

//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))

if(p_angle > 90) // if facing more than 90deg from sun, zero output
sunfrac = 0
return
return 0

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 ?
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 = .

/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
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(turf/loc, 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.
@@ -267,21 +290,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)
@@ -290,16 +315,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)
@@ -314,32 +329,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)
@@ -350,61 +349,48 @@

/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

@@ -458,32 +444,26 @@
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°
if(connected_tracker && (!powernet || connected_tracker.powernet != powernet))
connected_tracker.unset_control()

//rotates the panel to the passed angle
/obj/machinery/power/solar_control/proc/set_panels(currentdir)
///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)

///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)

//
// MISC
@@ -492,3 +472,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

+ 14
- 20
code/modules/power/tracker.dm View File

@@ -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,31 +14,36 @@
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
/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 ..()
//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
unset_control()
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)
if(control.track == SOLAR_TRACK_AUTO)
control.track = SOLAR_TRACK_OFF
control.connected_tracker = null
control = 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)
@@ -47,17 +52,6 @@
S.tracker = 1
S.anchored = TRUE
S.forceMove(src)
update_icon()
//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, TRUE)
@@ -74,7 +68,7 @@
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)
var/obj/item/solar_assembly/S = locate() in src


BIN
goon/icons/obj/power.dmi View File

Before After
Width: 160  |  Height: 128  |  Size: 4.1 KiB Width: 128  |  Height: 96  |  Size: 2.9 KiB

+ 21
- 20
tgui-next/packages/tgui/interfaces/SolarControl.js View File

@@ -7,9 +7,11 @@ export const SolarControl = props => {
const { act, data } = useBackend(props);
const {
generated,
angle,
generated_ratio,
azimuth_current,
azimuth_rate,
max_rotation_rate,
tracking_state,
tracking_rate,
connected_panels,
connected_tracker,
} = data;
@@ -43,13 +45,13 @@ export const SolarControl = props => {
<LabeledList.Item label="Power output">
<ProgressBar
ranges={{
good: [60000, Infinity],
average: [30000, 60000],
bad: [-Infinity, 30000],
good: [0.66, Infinity],
average: [0.33, 0.66],
bad: [-Infinity, 0.33],
}}
minValue={0}
maxValue={90000}
value={generated}
maxValue={1}
value={generated_ratio}
content={generated + ' W'} />
</LabeledList.Item>
</LabeledList>
@@ -76,7 +78,7 @@ export const SolarControl = props => {
disabled={!connected_tracker}
onClick={() => act('tracking', { mode: 2 })} />
</LabeledList.Item>
<LabeledList.Item label="Angle">
<LabeledList.Item label="Azimuth">
{(tracking_state === 0 || tracking_state === 1) && (
<NumberInput
width="52px"
@@ -85,28 +87,27 @@ export const SolarControl = props => {
stepPixelSize={2}
minValue={-360}
maxValue={+720}
value={angle}
format={angle => Math.round(360 + angle) % 360}
onDrag={(e, value) => act('angle', { value })} />
value={azimuth_current}
onDrag={(e, value) => act('azimuth', { value })} />
)}
{tracking_state === 1 && (
<NumberInput
width="80px"
unit="°/h"
step={5}
stepPixelSize={2}
minValue={-7200}
maxValue={7200}
value={tracking_rate}
unit="°/m"
step={0.01}
stepPixelSize={1}
minValue={-max_rotation_rate-0.01}
maxValue={max_rotation_rate+0.01}
value={azimuth_rate}
format={rate => {
const sign = Math.sign(rate) > 0 ? '+' : '-';
return sign + toFixed(Math.abs(rate));
return sign + Math.abs(rate);
}}
onDrag={(e, value) => act('rate', { value })} />
onDrag={(e, value) => act('azimuth_rate', { value })} />
)}
{tracking_state === 2 && (
<Box inline color="label" mt="3px">
{angle + ' °'} (auto)
{azimuth_current + ' °'} (auto)
</Box>
)}
</LabeledList.Item>


+ 1
- 1
tgui-next/packages/tgui/public/tgui.bundle.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save