Files
Bubberstation/code/modules/power/tracker.dm
LemonInTheDark e766444468 Changes our map_format to SIDE_MAP (#70162)
## About The Pull Request

This does nothing currently, but will allow me to test for layering
issues on LIVE, rather then in just wallening.
Oh also I'm packaging in a fix to one of my macros that I wrote wrong,
as a joke

[removes SEE_BLACKNESS usage, because we actually cannot use it
effectively](c9a19dd7cc)

[c9a19dd](c9a19dd7cc)

Sidemap removes the ability to control it on a plane, so it basically
just means there's an uncontrollable black slate even if you have other
toggles set.

This just like, removes that, since it's silly

[fixes weird layering on solars and ai portraits. Pixel y was casuing
things to render below who
shouldn't](3885b9d9ed)

[3885b9d](3885b9d9ed)

[Fixes flicker
issues](2defc0ad20)

[2defc0a](2defc0ad20)

Offsetting the vis_contents'd objects down physically, and then up
visually resolves the confliciting that was going on between the text
and its display.

This resolves the existing reported flickering issues

[fixes plated food not appearing in
world](28a34c64f8)

[28a34c6](28a34c64f8)

pixel_y'd vis_contents strikes again. It's a tad hacky but we'll just
use pixel_z for this

[Adds wall and upper wall plane
masters](89fe2b4eb4)

[89fe2b4](89fe2b4eb4)

We use these + the floor and space planes to build a mask of all the
visible turfs.
Then we take that, stick it in a plane master, and mask the emissive
plane with it.

This solves the lighting fulldark screen object getting cut by emissives
Shifts some planes around to match this new layering. Also ensures we
only shift fullscreen objects if they don't object to it.

[compresses plane master
controllers](bd64cc196a)

[bd64cc1](bd64cc196a)

we don't use them for much rn, but we might in future so I'm keeping it
as a convienince thing

🆑
refactor: The logic of how we well, render things has changed. Make an
issue report if anything looks funky, particularly layers. PLEASE USE
YOUR EYES
/🆑

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-12-10 17:30:54 -08:00

157 lines
4.8 KiB
Plaintext

#define TRACKER_Z_OFFSET 13
#define TRACKER_EDGE_Z_OFFSET (TRACKER_Z_OFFSET - 2)
//Solar tracker
//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
name = "solar tracker"
desc = "A solar directional tracker."
icon = 'icons/obj/solar.dmi'
icon_state = "tracker_base"
density = TRUE
use_power = NO_POWER_USE
max_integrity = 250
integrity_failure = 0.2
var/id = 0
var/obj/machinery/power/solar_control/control
var/obj/effect/overlay/tracker_dish
var/obj/effect/overlay/tracker_dish_edge
var/azimuth_current
/obj/machinery/power/tracker/Initialize(mapload, obj/item/solar_assembly/S)
. = ..()
tracker_dish_edge = add_panel_overlay("tracker_edge", TRACKER_EDGE_Z_OFFSET)
tracker_dish = add_panel_overlay("tracker", TRACKER_Z_OFFSET)
Make(S)
connect_to_network()
RegisterSignal(SSsun, COMSIG_SUN_MOVED, PROC_REF(sun_update))
/obj/machinery/power/tracker/Destroy()
unset_control() //remove from control computer
return ..()
/obj/machinery/power/tracker/on_changed_z_level(turf/old_turf, turf/new_turf, same_z_layer, notify_contents)
. = ..()
if(same_z_layer)
return
SET_PLANE(tracker_dish_edge, PLANE_TO_TRUE(tracker_dish_edge.plane), new_turf)
SET_PLANE(tracker_dish, PLANE_TO_TRUE(tracker_dish.plane), new_turf)
/obj/machinery/power/tracker/proc/add_panel_overlay(icon_state, z_offset)
var/obj/effect/overlay/overlay = new()
overlay.vis_flags = VIS_INHERIT_ID | VIS_INHERIT_ICON
overlay.appearance_flags = TILE_BOUND
overlay.icon_state = icon_state
overlay.layer = FLY_LAYER
SET_PLANE_EXPLICIT(overlay, ABOVE_GAME_PLANE, src)
overlay.pixel_y = z_offset
vis_contents += overlay
return overlay
/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
/**
* Get the 2.5D transform for the tracker, given an angle
* Arguments:
* * angle - the angle the panel is facing
*/
/obj/machinery/power/tracker/proc/get_tracker_transform(angle)
// 2.5D solar tracker works by using a magic combination of transforms
var/matrix/turner = matrix()
// Rotate towards sun
turner.Turn(angle)
// Make it skinny on the floor plane
turner.Scale(1, 0.5)
return turner
/obj/machinery/power/tracker/proc/visually_turn_part(part, angle)
var/mid_azimuth = (azimuth_current + angle) / 2
// actually flip to other direction?
if(abs(angle - azimuth_current) > 180)
mid_azimuth = (mid_azimuth + 180) % 360
// Split into 2 parts so it doesn't distort on large changes
animate(part,
transform = get_tracker_transform(mid_azimuth),
time = 2.5 SECONDS, easing = CUBIC_EASING|EASE_IN
)
animate(
transform = get_tracker_transform(angle),
time = 2.5 SECONDS, easing = CUBIC_EASING|EASE_OUT
)
///Tell the controller to turn the solar panels
/obj/machinery/power/tracker/proc/sun_update(datum/source, azimuth)
SIGNAL_HANDLER
visually_turn_part(tracker_dish, azimuth)
visually_turn_part(tracker_dish_edge, azimuth)
azimuth_current = 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)
S = new /obj/item/solar_assembly(src)
S.glass_type = /obj/item/stack/sheet/glass
S.tracker = 1
S.update_appearance()
S.set_anchored(TRUE)
S.forceMove(src)
/obj/machinery/power/tracker/crowbar_act(mob/user, obj/item/I)
playsound(src.loc, 'sound/machines/click.ogg', 50, TRUE)
user.visible_message(span_notice("[user] begins to take the glass off [src]."), span_notice("You begin to take the glass off [src]..."))
if(I.use_tool(src, user, 50))
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE)
user.visible_message(span_notice("[user] takes the glass off [src]."), span_notice("You take the glass off [src]."))
deconstruct(TRUE)
return TRUE
/obj/machinery/power/tracker/atom_break(damage_flag)
. = ..()
if(.)
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
unset_control()
/obj/machinery/power/tracker/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
if(disassembled)
var/obj/item/solar_assembly/S = locate() in src
if(S)
S.forceMove(loc)
S.give_glass(machine_stat & BROKEN)
else
playsound(src, SFX_SHATTER, 70, TRUE)
new /obj/item/shard(src.loc)
new /obj/item/shard(src.loc)
qdel(src)
// Tracker Electronic
/obj/item/electronics/tracker
name = "tracker electronics"
#undef TRACKER_Z_OFFSET
#undef TRACKER_EDGE_Z_OFFSET