From d978472d272c2ea68862ac852427d10c1f717290 Mon Sep 17 00:00:00 2001 From: Citinited Date: Thu, 31 May 2018 22:44:10 +0100 Subject: [PATCH] RPD nanoUI improvement; misc. code tweaks --- code/__HELPERS/global_lists.dm | 5 +++-- code/datums/pipe_datums.dm | 8 ++++---- code/game/objects/items/weapons/rpd.dm | 24 ++++++++++++++++-------- nano/templates/rpd.tmpl | 10 +++++----- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 367028b3936..c11fd98f433 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -49,11 +49,12 @@ whitelisted_species += S.name init_subtypes(/datum/crafting_recipe, crafting_recipes) + + //RPD pipe list building var/list/temp_pipe_list = list() init_subtypes(/datum/pipes/atmospheric, temp_pipe_list) init_subtypes(/datum/pipes/disposal, temp_pipe_list) - for(var/I in temp_pipe_list) - var/datum/pipes/P = I + for(var/datum/pipes/P in temp_pipe_list) //Yes I know the list(list(...)) thing looks weird, but it allows us to group pipe metadata into ordered lists instead of being one big list GLOB.construction_pipe_list += list(list("pipename" = P.pipename, "pipeid" = P.pipeid, "atmosordisposals" = P.pipetype, "category" = P.category, "orientations" = P.orientations, "icon" = P.previewicon, "bendy" = P.bendy)) return 1 diff --git a/code/datums/pipe_datums.dm b/code/datums/pipe_datums.dm index 14d42510fb6..43cda53a4a9 100644 --- a/code/datums/pipe_datums.dm +++ b/code/datums/pipe_datums.dm @@ -29,11 +29,12 @@ GLOBAL_LIST_EMPTY(construction_pipe_list) //List of all pipe datums orientations = 2 previewicon = "simple" -/datum/pipes/atmospheric/simple/bent +/datum/pipes/atmospheric/bent //Why is this not atmospheric/simple/bent you ask? Because otherwise the ordering of the pipes in the UI menu gets weird pipename = "Bent pipe" pipeid = PIPE_SIMPLE_BENT orientations = 4 bendy = TRUE + previewicon = "simple" /datum/pipes/atmospheric/manifold pipename = "T-manifold" @@ -77,13 +78,12 @@ GLOBAL_LIST_EMPTY(construction_pipe_list) //List of all pipe datums //Supply pipes - /datum/pipes/atmospheric/simple/supply pipename = "Straight supply pipe" pipeid = PIPE_SUPPLY_STRAIGHT category = RPD_SUPPLY_PIPING -/datum/pipes/atmospheric/simple/bent/supply +/datum/pipes/atmospheric/bent/supply pipename = "Bent supply pipe" pipeid = PIPE_SUPPLY_BENT category = RPD_SUPPLY_PIPING @@ -110,7 +110,7 @@ GLOBAL_LIST_EMPTY(construction_pipe_list) //List of all pipe datums pipeid = PIPE_SCRUBBERS_STRAIGHT category = RPD_SCRUBBERS_PIPING -/datum/pipes/atmospheric/simple/bent/scrubbers +/datum/pipes/atmospheric/bent/scrubbers pipename = "Bent scrubbers pipe" pipeid = PIPE_SCRUBBERS_BENT category = RPD_SCRUBBERS_PIPING diff --git a/code/game/objects/items/weapons/rpd.dm b/code/game/objects/items/weapons/rpd.dm index 98639030b3a..5efa881b861 100644 --- a/code/game/objects/items/weapons/rpd.dm +++ b/code/game/objects/items/weapons/rpd.dm @@ -37,6 +37,10 @@ spark_system.set_up(1, 0, src) spark_system.attach(src) +/obj/item/rcd/Destroy() + QDEL_NULL(spark_system) + return ..() + //Procs /obj/item/rpd/proc/activate_rpd(delay) //Maybe makes sparks and activates cooldown if there is a delay @@ -53,17 +57,17 @@ else if(whatpipe == PIPE_METER) P = new /obj/item/pipe_meter(T) else - P = new(T, pipe_type = whatpipe, dir = user.dir) //Make the pipe, BUT WAIT! There's more! + P = new(T, whatpipe, iconrotation) //Make the pipe, BUT WAIT! There's more! if(!iconrotation && P.is_bent_pipe()) //Automatically rotates dispensed pipes if the user selected auto-rotation P.dir = turn(user.dir, 135) else if(!iconrotation && P.pipe_type in list(PIPE_CONNECTOR, PIPE_UVENT, PIPE_SCRUBBER, PIPE_HEAT_EXCHANGE, PIPE_CAP, PIPE_SUPPLY_CAP, PIPE_SCRUBBERS_CAP, PIPE_INJECTOR, PIPE_PASV_VENT)) //Some pipes dispense oppositely to what you'd expect, but we don't want to do anything if they selected a direction P.flip() else if(iconrotation && P.is_bent_pipe()) //If user selected a rotation and the pipe is bent P.dir = turn(iconrotation, -45) - else if(iconrotation) //If user selected a rotation - P.dir = iconrotation - to_chat(user, "[src] rapidly dispenses [P]!") - activate_rpd(1) + else if(!iconrotation) //If user selected a rotation + P.dir = user.dir + to_chat(user, "[src] rapidly dispenses [P]!") + activate_rpd(TRUE) /obj/item/rpd/proc/create_disposals_pipe(mob/user, turf/T) //Make a disposals pipe / construct var/obj/structure/disposalconstruct/P = new(T, whatdpipe, iconrotation) @@ -71,8 +75,8 @@ P.dir = user.dir if(!iconrotation && whatdpipe != PIPE_DISPOSALS_JUNCTION) //Disposals pipes are in the opposite direction to atmos pipes, so we need to flip them. Junctions don't have this quirk though P.flip() - to_chat(user, "[src] rapidly dispenses [P]!") - activate_rpd(1) + to_chat(user, "[src] rapidly dispenses [P]!") + activate_rpd(TRUE) /obj/item/rpd/proc/rotate_all_pipes(mob/user, turf/T) //Rotate all pipes on a turf for(var/obj/item/pipe/P in T) @@ -169,7 +173,11 @@ var/list/pipemenu = list( /obj/item/rpd/afterattack(atom/target, mob/user, proximity) ..() - if(loc != user || !proximity || world.time < lastused + spawndelay) + if(loc != user) + return + if(!proximity) + return + if(world.time < lastused + spawndelay) return target.rpd_act(user, src) //Handle RPD effects in separate procs diff --git a/nano/templates/rpd.tmpl b/nano/templates/rpd.tmpl index 6c380b3c046..f08a5ff02b4 100644 --- a/nano/templates/rpd.tmpl +++ b/nano/templates/rpd.tmpl @@ -4,21 +4,21 @@ Used In File(s): /code/game/objects/items/weapons/rpd.dm

Mode:

{{for data.mainmenu}} - {{:helper.link(String(value.category), String(value.icon), {"mode": Number(value.mode)}, data.mode == Number(value.mode) ? "linkOn" : null)}} + {{:helper.link(value.category, value.icon, {mode: value.mode}, data.mode == value.mode ? "linkOn" : null)}} {{/for}}
{{if data.mode == 1}}

Pipe type:

{{for data.pipemenu}} - {{:helper.link(String(value.pipecategory), null, {pipetype: Number(value.pipemode)}, data.pipetype == Number(value.pipemode) ? "linkOn" : null)}} + {{:helper.link(value.pipecategory, null, {pipetype: value.pipemode}, data.pipetype == value.pipemode ? "linkOn" : null)}} {{/for}}

Available pipes:

{{for data.pipelist}} {{if value.atmosordisposals == 1 && value.category == data.pipetype}} -
{{:helper.link(String(value.pipename), "arrow-right", {"whatpipe": Number(value.pipeid)}, data.whatpipe == Number(value.pipeid) ? "linkOn" : null)}}
+
{{:helper.link(value.pipename, "arrow-right", {whatpipe: value.pipeid}, data.whatpipe == value.pipeid ? "linkOn" : null)}}
{{/if}} {{/for}}
@@ -74,12 +74,12 @@ Used In File(s): /code/game/objects/items/weapons/rpd.dm
{{for data.pipelist}} {{if value.atmosordisposals == 2}} -
{{:helper.link(String(value.pipename), "arrow-right", {"whatdpipe": Number(value.pipeid)}, data.whatdpipe == Number(value.pipeid) ? "linkOn" : null)}}
+
{{:helper.link(value.pipename, "arrow-right", {whatdpipe: value.pipeid}, data.whatdpipe == value.pipeid ? "linkOn" : null)}}
{{/if}} {{/for}}
{{for data.pipelist}} - {{if value.atmosordisposals != 2 || value.pipeid != data.whatdpipe || value.orientations == 1}} + {{if value.atmosordisposals != 2 || value.pipeid != data.whatdpipe || value.orientations == 1}} {{continue;}} {{/if}}