mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 19:44:09 +01:00
RPD refactor: part 2
This commit is contained in:
@@ -2,23 +2,6 @@
|
||||
Rapid Pipe Dispenser
|
||||
*/
|
||||
|
||||
#define SIMPLE_CAP 20
|
||||
#define SUPPLY_CAP 32
|
||||
#define SCRUBBERS_CAP 33
|
||||
#define HE_EXCHANGER 17
|
||||
#define CONNECTOR 4
|
||||
#define UNARY_VENT 7
|
||||
#define PASSIVE_VENT 37
|
||||
#define GAS_SCRUBBER 10
|
||||
#define INJECTOR 34
|
||||
#define GAS_SENSOR 98
|
||||
#define METER 99
|
||||
#define DISPOSALS_JUNCTION 2
|
||||
#define ATMOS_PIPING 1
|
||||
#define SUPPLY_PIPING 2
|
||||
#define SCRUBBERS_PIPING 3
|
||||
#define DEVICES 4
|
||||
#define HEAT_PIPING 5
|
||||
#define RPD_COOLDOWN_TIME 4 //How long should we have to wait between dispensing pipes?
|
||||
#define RPD_WALLBUILD_TIME 40 //How long should drilling into a wall take?
|
||||
|
||||
@@ -40,11 +23,11 @@
|
||||
origin_tech = "engineering=4;materials=2"
|
||||
var/datum/effect_system/spark_spread/spark_system
|
||||
var/lastused
|
||||
var/iconrotation = 0 //used to orient icons and pipes
|
||||
var/iconrotation = 0 //Used to orient icons and pipes
|
||||
var/mode = RPD_ATMOS_MODE //Disposals, atmospherics, etc.
|
||||
var/pipetype = 1//For nanoUI menus
|
||||
var/whatpipe = 0 //What kind of pipe is it? See code/game/machinery/pipe/construction.dm for a list of defines
|
||||
var/whatdpipe = 0 //What kind of disposals pipe is it?
|
||||
var/pipetype = RPD_ATMOS_PIPING//For nanoUI menus, this is a subtype of pipes e.g. scrubbers pipes, devices
|
||||
var/whatpipe = PIPE_SIMPLE_STRAIGHT //What kind of atmos pipe is it?
|
||||
var/whatdpipe = PIPE_DISPOSALS_STRAIGHT //What kind of disposals pipe is it?
|
||||
var/spawndelay = RPD_COOLDOWN_TIME
|
||||
var/walldelay = RPD_WALLBUILD_TIME
|
||||
|
||||
@@ -56,7 +39,7 @@
|
||||
|
||||
//Procs
|
||||
|
||||
/obj/item/rpd/proc/Activaterpd(delay) //Maybe makes sparks and activates cooldown if there is a delay.
|
||||
/obj/item/rpd/proc/activate_rpd(delay) //Maybe makes sparks and activates cooldown if there is a delay
|
||||
playsound(loc, "sound/machines/click.ogg", 50, 1)
|
||||
if(prob(15))
|
||||
spark_system.start()
|
||||
@@ -65,34 +48,31 @@
|
||||
|
||||
/obj/item/rpd/proc/create_atmos_pipe(mob/user, turf/T) //Make an atmos pipe, meter, or gas sensor
|
||||
var/obj/item/pipe/P
|
||||
if(whatpipe == GAS_SENSOR)
|
||||
if(whatpipe == PIPE_GAS_SENSOR)
|
||||
P = new /obj/item/pipe_gsensor(T)
|
||||
else if(whatpipe == METER)
|
||||
else if(whatpipe == PIPE_METER)
|
||||
P = new /obj/item/pipe_meter(T)
|
||||
else
|
||||
P = new(T, pipe_type = whatpipe, dir = user.dir)
|
||||
if(iconrotation == 0 && P.is_bent_pipe()) //Automatic rotation of dispensed pipes
|
||||
P = new(T, pipe_type = whatpipe, dir = user.dir) //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 == 0 && P.pipe_type in list(CONNECTOR, UNARY_VENT, GAS_SCRUBBER, HE_EXCHANGER, SIMPLE_CAP, SUPPLY_CAP, SCRUBBERS_CAP, INJECTOR, PASSIVE_VENT)) //Some pipes dispense oppositely to what you'd expect, but we don't want to do anything if they selected a direction
|
||||
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 != 0 && P.is_bent_pipe()) //If they selected a rotation and the pipe is bent
|
||||
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 != 0)
|
||||
else if(iconrotation) //If user selected a rotation
|
||||
P.dir = iconrotation
|
||||
to_chat(user, "<span class = 'notice'>[src] rapidly dispenses [P]!</span>")
|
||||
Activaterpd(1)
|
||||
activate_rpd(1)
|
||||
|
||||
/obj/item/rpd/proc/create_disposals_pipe(mob/user, turf/T) //Make a disposals pipe / construct
|
||||
var/obj/structure/disposalconstruct/P = new(T) //Now we make the pipe
|
||||
P.dir = iconrotation
|
||||
P.ptype = whatdpipe
|
||||
if(iconrotation == 0) //Automatic rotation
|
||||
var/obj/structure/disposalconstruct/P = new(T, whatdpipe, iconrotation)
|
||||
if(!iconrotation) //Automatic rotation
|
||||
P.dir = user.dir
|
||||
if(iconrotation == 0 && whatdpipe != 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
|
||||
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()
|
||||
P.update()
|
||||
to_chat(user, "<span class = 'notice'>[src] rapidly dispenses [P]!</span>")
|
||||
Activaterpd(1)
|
||||
activate_rpd(1)
|
||||
|
||||
/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)
|
||||
@@ -123,76 +103,29 @@
|
||||
eaten = TRUE
|
||||
if(eaten)
|
||||
to_chat(user, "<span class='notice'>[src] sucks up the loose pipes on [T].")
|
||||
Activaterpd()
|
||||
activate_rpd()
|
||||
else
|
||||
to_chat(user, "<span class='notice'>There were no loose pipes on [T].</span>")
|
||||
|
||||
/obj/item/rpd/proc/delete_single_pipe(mob/user, obj/P) //Delete a single pipe
|
||||
to_chat(user, "<span class='notice'>[src] sucks up [P].</span>")
|
||||
QDEL_NULL(P)
|
||||
Activaterpd()
|
||||
activate_rpd()
|
||||
|
||||
//Lists of things
|
||||
|
||||
var/list/pipelist = list( //id refers to the pipe_type found in construction.dm, icon refers to the name of the icon state in icons/obj/pipe-item.dmi. Icons are made with the asset-cache
|
||||
list("pipename" = "Straight pipe", "id" = 0, "category" = ATMOS_PIPING, "orientations" = 2, "icon" = "simple"),
|
||||
list("pipename" = "Bent pipe", "id" = 1, "category" = ATMOS_PIPING, "orientations" = 4, "icon" = "simple", "bendy" = 1),
|
||||
list("pipename" = "T-manifold", "id" = 5, "category" = ATMOS_PIPING, "orientations" = 4, "icon" = "manifold"),
|
||||
list("pipename" = "4-way manifold", "id" = 19, "category" = ATMOS_PIPING, "orientations" = 1, "icon" = "manifold4w"),
|
||||
list("pipename" = "Pipe cap", "id" = 20, "category" = ATMOS_PIPING, "orientations" = 4, "icon" = "cap"),
|
||||
list("pipename" = "Manual valve", "id" = 8, "category" = ATMOS_PIPING, "orientations" = 2, "icon" = "mvalve"),
|
||||
list("pipename" = "Digital valve", "id" = 35, "category" = ATMOS_PIPING, "orientations" = 2, "icon" = "dvalve"),
|
||||
list("pipename" = "Manual T-valve", "id" = 18, "category" = ATMOS_PIPING, "orientations" = 4, "icon" = "tvalve"),
|
||||
list("pipename" = "Digital T-valve", "id" = 38, "category" = ATMOS_PIPING, "orientations" = 4, "icon" = "dtvalve"),
|
||||
list("pipename" = "Straight supply pipe", "id" = 24, "category" = SUPPLY_PIPING, "orientations" = 2, "icon" = "simple"),
|
||||
list("pipename" = "Bent supply pipe", "id" = 25, "category" = SUPPLY_PIPING, "orientations" = 4, "icon" = "simple", "bendy" = 1),
|
||||
list("pipename" = "Supply T-manifold", "id" = 28, "category" = SUPPLY_PIPING, "orientations" = 4, "icon" = "manifold"),
|
||||
list("pipename" = "4-way supply manifold", "id" = 30, "category" = SUPPLY_PIPING, "orientations" = 1, "icon" = "manifold4w"),
|
||||
list("pipename" = "Supply pipe cap", "id" = 32, "category" = SUPPLY_PIPING, "orientations" = 4, "icon" = "cap"),
|
||||
list("pipename" = "Straight scrubbers pipe", "id" = 26, "category" = SCRUBBERS_PIPING, "orientations" = 2, "icon" = "simple"),
|
||||
list("pipename" = "Bent scrubbers pipe", "id" = 27, "category" = SCRUBBERS_PIPING, "orientations" = 4, "icon" = "simple", "bendy" = 1),
|
||||
list("pipename" = "Scrubbers T-manifold", "id" = 29, "category" = SCRUBBERS_PIPING, "orientations" = 4, "icon" = "manifold"),
|
||||
list("pipename" = "4-way scrubbers manifold", "id" = 31, "category" = SCRUBBERS_PIPING, "orientations" = 1, "icon" = "manifold4w"),
|
||||
list("pipename" = "Scrubbers pipe cap", "id" = 33, "category" = SCRUBBERS_PIPING, "orientations" = 4, "icon" = "cap"),
|
||||
list("pipename" = "Universal pipe adapter", "id" = 23, "category" = DEVICES, "orientations" = 2, "icon" = "universal"),
|
||||
list("pipename" = "Connector", "id" = 4, "category" = DEVICES, "orientations" = 4, "icon" = "connector"),
|
||||
list("pipename" = "Unary vent", "id" = 7, "category" = DEVICES, "orientations" = 4, "icon" = "uvent"),
|
||||
list("pipename" = "Scrubber", "id" = 10, "category" = DEVICES, "orientations" = 4, "icon" = "scrubber"),
|
||||
list("pipename" = "Gas pump", "id" = 9, "category" = DEVICES, "orientations" = 4, "icon" = "pump"),
|
||||
list("pipename" = "Volume pump", "id" = 16, "category" = DEVICES, "orientations" = 4, "icon" = "volumepump"),
|
||||
list("pipename" = "Passive gate", "id" = 15, "category" = DEVICES, "orientations" = 4, "icon" = "passivegate"),
|
||||
list("pipename" = "Gas filter", "id" = 13, "category" = DEVICES, "orientations" = 4, "icon" = "filter"),
|
||||
list("pipename" = "Gas mixer", "id" = 14, "category" = DEVICES, "orientations" = 4, "icon" = "mixer"),
|
||||
list("pipename" = "Gas sensor", "id" = 98, "category" = DEVICES, "orientations" = 1, "icon" = "sensor"),
|
||||
list("pipename" = "Meter", "id" = 99, "category" = DEVICES, "orientations" = 1, "icon" = "meter"),
|
||||
list("pipename" = "Passive vent", "id" = 37, "category" = DEVICES, "orientations" = 4, "icon" = "passive vent"),
|
||||
list("pipename" = "Dual-port vent pump", "id" = 36, "category" = DEVICES, "orientations" = 2, "icon" = "dual-port vent"),
|
||||
list("pipename" = "Air injector", "id" = 34, "category" = DEVICES, "orientations" = 4, "icon" = "injector"),
|
||||
list("pipename" = "Straight HE pipe", "id" = 2, "category" = HEAT_PIPING, "orientations" = 2, "icon" = "he"),
|
||||
list("pipename" = "Bent HE pipe", "id" = 3, "category" = HEAT_PIPING, "orientations" = 4, "icon" = "he", "bendy" = 1),
|
||||
list("pipename" = "Junction", "id" = 6, "category" = HEAT_PIPING, "orientations" = 4, "icon" = "junction"),
|
||||
list("pipename" = "Heat exchanger", "id" = 17, "category" = HEAT_PIPING, "orientations" = 4, "icon" = "heunary"))
|
||||
var/list/dpipelist = list(
|
||||
list("pipename" = "Straight pipe", "id" = 0, "orientations" = 2, "icon" = "conpipe-s"),
|
||||
list("pipename" = "Bent pipe", "id" = 1, "orientations" = 4, "icon" = "conpipe-c"),
|
||||
list("pipename" = "Junction", "id" = 2, "orientations" = 4, "icon" = "conpipe-j1"),
|
||||
list("pipename" = "Y-junction", "id" = 4, "orientations" = 4, "icon" = "conpipe-y"),
|
||||
list("pipename" = "Trunk", "id" = 5, "orientations" = 4, "icon" = "conpipe-t"),
|
||||
list("pipename" = "Bin", "id" = 6, "orientations" = 1, "icon" = "condisposal"),
|
||||
list("pipename" = "Outlet", "id" = 7, "orientations" = 4, "icon" = "outlet"),
|
||||
list("pipename" = "Chute", "id" = 8, "orientations" = 4, "icon" = "intake"))
|
||||
var/list/mainmenu = list(
|
||||
list("category" = "Atmospherics", "mode" = 1, "icon" = "wrench"),
|
||||
list("category" = "Disposals", "mode" = 2, "icon" = "recycle"),
|
||||
list("category" = "Rotate", "mode" = 3, "icon" = "rotate-right"),
|
||||
list("category" = "Flip", "mode" = 4, "icon" = "exchange"),
|
||||
list("category" = "Recycle", "mode" = 5, "icon" = "trash"))
|
||||
list("category" = "Atmospherics", "mode" = RPD_ATMOS_MODE, "icon" = "wrench"),
|
||||
list("category" = "Disposals", "mode" = RPD_DISPOSALS_MODE, "icon" = "recycle"),
|
||||
list("category" = "Rotate", "mode" = RPD_ROTATE_MODE, "icon" = "rotate-right"),
|
||||
list("category" = "Flip", "mode" = RPD_FLIP_MODE, "icon" = "exchange"),
|
||||
list("category" = "Recycle", "mode" = RPD_DELETE_MODE, "icon" = "trash"))
|
||||
var/list/pipemenu = list(
|
||||
list("pipecategory" = "Normal", "pipemode" = 1),
|
||||
list("pipecategory" = "Supply", "pipemode" = 2),
|
||||
list("pipecategory" = "Scrubber", "pipemode" = 3),
|
||||
list("pipecategory" = "Devices", "pipemode" = 4),
|
||||
list("pipecategory" = "Heat exchange", "pipemode" = 5))
|
||||
list("pipecategory" = "Normal", "pipemode" = RPD_ATMOS_PIPING),
|
||||
list("pipecategory" = "Supply", "pipemode" = RPD_SUPPLY_PIPING),
|
||||
list("pipecategory" = "Scrubber", "pipemode" = RPD_SCRUBBERS_PIPING),
|
||||
list("pipecategory" = "Devices", "pipemode" = RPD_DEVICES),
|
||||
list("pipecategory" = "Heat exchange", "pipemode" = RPD_HEAT_PIPING))
|
||||
|
||||
//NanoUI stuff
|
||||
|
||||
@@ -208,11 +141,10 @@ var/list/pipemenu = list(
|
||||
|
||||
/obj/item/rpd/ui_data(mob/user, ui_key = "main", datum/topic_state/state = inventory_state)
|
||||
var/data[0]
|
||||
data["dpipelist"] = dpipelist
|
||||
data["iconrotation"] = iconrotation
|
||||
data["mainmenu"] = mainmenu
|
||||
data["mode"] = mode
|
||||
data["pipelist"] = pipelist
|
||||
data["pipelist"] = construction_pipe_list
|
||||
data["pipemenu"] = pipemenu
|
||||
data["pipetype"] = pipetype
|
||||
data["whatdpipe"] = whatdpipe
|
||||
@@ -239,24 +171,7 @@ var/list/pipemenu = list(
|
||||
..()
|
||||
if(loc != user || !proximity || world.time < lastused + spawndelay)
|
||||
return
|
||||
target.rpd_act(user, src)
|
||||
target.rpd_act(user, src) //Handle RPD effects in separate procs
|
||||
|
||||
#undef SIMPLE_CAP
|
||||
#undef SUPPLY_CAP
|
||||
#undef SCRUBBERS_CAP
|
||||
#undef HE_EXCHANGER
|
||||
#undef CONNECTOR
|
||||
#undef UNARY_VENT
|
||||
#undef PASSIVE_VENT
|
||||
#undef GAS_SCRUBBER
|
||||
#undef INJECTOR
|
||||
#undef GAS_SENSOR
|
||||
#undef METER
|
||||
#undef DISPOSALS_JUNCTION
|
||||
#undef ATMOS_PIPING
|
||||
#undef SUPPLY_PIPING
|
||||
#undef SCRUBBERS_PIPING
|
||||
#undef DEVICES
|
||||
#undef HEAT_PIPING
|
||||
#undef RPD_COOLDOWN_TIME
|
||||
#undef RPD_WALLBUILD_TIME
|
||||
|
||||
Reference in New Issue
Block a user