From 528a226daef09c0fa9c0e6a452e9f02a9a809fc2 Mon Sep 17 00:00:00 2001 From: Artur Date: Mon, 24 Feb 2020 13:36:55 +0200 Subject: [PATCH] Done. --- code/modules/power/solar.dm | 72 +++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index 021b575fef..ab33324fb8 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -27,16 +27,15 @@ /obj/machinery/power/solar/Initialize(mapload, obj/item/solar_assembly/S) . = ..() - if(!S) - assembly = new /obj/item/solar_assembly - assembly.glass_type = new /obj/item/stack/sheet/glass(null, 2) - assembly.anchored = TRUE - else - S.moveToNullspace() - assembly = S - assembly.glass_type.on_solar_construction(src) - obj_integrity = max_integrity - update_icon() + 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) @@ -57,6 +56,18 @@ 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) + assembly.anchored = TRUE + else + S.moveToNullspace() + assembly = S + assembly.glass_type.on_solar_construction(src) + 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) user.visible_message("[user] begins to take the glass off [src].", "You begin to take the glass off [src]...") @@ -221,20 +232,20 @@ /obj/item/solar_assembly/attackby(obj/item/W, mob/user, params) - if(W.tool_behaviour == TOOL_WRENCH && isturf(loc)) + if(istype(W, /obj/item/wrench) && isturf(loc)) if(isinspace()) to_chat(user, "You can't secure [src] here.") return anchored = !anchored if(anchored) - user.visible_message("[user] wrenches the solar assembly into place.", "You wrench the solar assembly into place.") + user.visible_message("[user] wrenches the solar assembly into place.", "You wrench the solar assembly into place.") W.play_tool_sound(src, 75) else - user.visible_message("[user] unwrenches the solar assembly from its place.", "You unwrench the solar assembly from its place.") + user.visible_message("[user] unwrenches the solar assembly from its place.", "You unwrench the solar assembly from its place.") W.play_tool_sound(src, 75) return 1 - if(istype(W, /obj/item/stack/sheet/glass) || istype(W, /obj/item/stack/sheet/rglass)) + if(is_type_in_typecache(W, allowed_sheets)) if(!anchored) to_chat(user, "You need to secure the assembly before you can add glass.") return @@ -242,8 +253,8 @@ var/obj/item/stack/sheet/G = S.change_stack(null, 2) if(G) glass_type = G - playsound(src.loc, 'sound/machines/click.ogg', 50, TRUE) - user.visible_message("[user] places the glass on the solar assembly.", "You place the glass on the solar assembly.") + playsound(src.loc, 'sound/machines/click.ogg', 50, 1) + user.visible_message("[user] places the glass on the solar assembly.", "You place the glass on the solar assembly.") if(tracker) new /obj/machinery/power/tracker(get_turf(src), src) else @@ -259,13 +270,13 @@ return tracker = 1 qdel(W) - user.visible_message("[user] inserts the electronics into the solar assembly.", "You insert the electronics into the solar assembly.") + user.visible_message("[user] inserts the electronics into the solar assembly.", "You insert the electronics into the solar assembly.") return 1 else - if(W.tool_behaviour == TOOL_CROWBAR) + if(istype(W, /obj/item/crowbar)) new /obj/item/electronics/tracker(src.loc) tracker = 0 - user.visible_message("[user] takes out the electronics from the solar assembly.", "You take out the electronics from the solar assembly.") + user.visible_message("[user] takes out the electronics from the solar assembly.", "You take out the electronics from the solar assembly.") return 1 return ..() @@ -325,13 +336,16 @@ if(!T.control) //i.e unconnected T.set_control(src) -/obj/machinery/power/solar/update_icon() - ..() - cut_overlays() +/obj/machinery/power/solar_control/update_overlays() + . = ..() + if(stat & NOPOWER) + . += mutable_appearance(icon, "[icon_keyboard]_off") + return + . += mutable_appearance(icon, icon_keyboard) if(stat & BROKEN) - add_overlay(mutable_appearance(icon, "solar_panel-b", FLY_LAYER)) + . += mutable_appearance(icon, "[icon_state]_broken") else - add_overlay(mutable_appearance(icon, "solar_panel", FLY_LAYER)) + . += 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) @@ -389,13 +403,13 @@ /obj/machinery/power/solar_control/attackby(obj/item/I, mob/user, params) if(I.tool_behaviour == TOOL_SCREWDRIVER) - if(I.use_tool(src, user, 20, volume=50)) + if(I.use_tool(src, user, 20, volume = 50)) if(src.stat & BROKEN) to_chat(user, "The broken glass falls out.") 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 @@ -406,7 +420,7 @@ to_chat(user, "You disconnect the monitor.") 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 @@ -459,6 +473,10 @@ for(var/obj/machinery/power/solar/S in connected_panels) S.queue_turn(azimuth) +/obj/machinery/power/solar_control/power_change() + ..() + update_icon() + // // MISC //