mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
- Moved pipe construction defines into __defines/construction.dm
- Unified pipe *unwrenching* by creating a standard proc along with the `construction_type` var.
- Eliminated the pipe fitting name & icon_state lookup tables by adding `pipe_state` var on atmos machinery and referencing that.
- Each pipe which can be made from a fitting object should override `pipe_state` with the icon state to be used on the pipe fitting object.
- Eliminated the giant switch statement of doom in pipe construction by delegating that work to `on_construction` proc.
- To make this work, every pipe must implement `get_neighbor_nodes_for_init` which returns a list of nodes which should be re-initialized on that pipe's construction.
- Combined the SCRUBBERS, SUPPLY and REGULAR pipe fitting classes together by storing the `piping_layer` variable and using the `setPipingLayer` procs
- Standardized the code for searching for node neighbors into the `can_be_node` proc.
- This proc is also improved in that is a mutual check, `check_connectable` is called on BOTH objects, so they have to mutually agree to connect as nodes. Eliminates lots of special edge case logic.
- Updated all the `amos_init` procs to use `can_be_node`. In the most common cases, even that boilerplate code is consolidated into the `STANDARD_ATMOS_CHOOSE_NODE` macro.
- Implemented `pipe_flags` which lets pipes declare (or override) certain requirements.
- Adds a "pipe_recipe" datum to help out things that construct pipes. By taking it out of the dispenser, we open the road for multiple dispenser types. No, no RPD yet. Soon.
- Enhances the pipe dispenser to operate on pipe recipe datums instead of hard coded lists of pipes it can construct. These datums are also (partially) initialized from the pipe machine types themselves, reducing having to define stuff in multiple places.
- Switched pipe dispenser UI to use browse(). Not a NanoUI, but makes it a bit prettier with low effort.
- Changed pipe dispenser to use a button selector to switch between Regular/Scrubbers/Supply instead of having separate list items.
- Added icon states to HE pipes to support the "connected on neither side" state.
291 lines
8.9 KiB
Plaintext
291 lines
8.9 KiB
Plaintext
//--------------------------------------------
|
|
// Pipe colors
|
|
//
|
|
// Add them here and to the pipe_colors list
|
|
// to automatically add them to all relevant
|
|
// atmospherics devices.
|
|
//--------------------------------------------
|
|
|
|
#define PIPE_COLOR_GREY "#ffffff" //yes white is grey
|
|
#define PIPE_COLOR_RED "#ff0000"
|
|
#define PIPE_COLOR_BLUE "#0000ff"
|
|
#define PIPE_COLOR_CYAN "#00ffff"
|
|
#define PIPE_COLOR_GREEN "#00ff00"
|
|
#define PIPE_COLOR_YELLOW "#ffcc00"
|
|
#define PIPE_COLOR_BLACK "#444444"
|
|
#define PIPE_COLOR_PURPLE "#5c1ec0"
|
|
|
|
var/global/list/pipe_colors = list("grey" = PIPE_COLOR_GREY, "red" = PIPE_COLOR_RED, "blue" = PIPE_COLOR_BLUE, "cyan" = PIPE_COLOR_CYAN, "green" = PIPE_COLOR_GREEN, "yellow" = PIPE_COLOR_YELLOW, "black" = PIPE_COLOR_BLACK, "purple" = PIPE_COLOR_PURPLE)
|
|
|
|
/proc/pipe_color_lookup(var/color)
|
|
for(var/C in pipe_colors)
|
|
if(color == pipe_colors[C])
|
|
return "[C]"
|
|
|
|
/proc/pipe_color_check(var/color)
|
|
if(!color)
|
|
return 1
|
|
for(var/C in pipe_colors)
|
|
if(color == pipe_colors[C])
|
|
return 1
|
|
return 0
|
|
|
|
//--------------------------------------------
|
|
// Icon cache generation
|
|
//--------------------------------------------
|
|
|
|
/datum/pipe_icon_manager
|
|
var/list/pipe_icons[]
|
|
var/list/manifold_icons[]
|
|
var/list/device_icons[]
|
|
var/list/underlays[]
|
|
//var/list/underlays_down[]
|
|
//var/list/underlays_exposed[]
|
|
//var/list/underlays_intact[]
|
|
//var/list/pipe_underlays_exposed[]
|
|
//var/list/pipe_underlays_intact[]
|
|
var/list/omni_icons[]
|
|
|
|
/datum/pipe_icon_manager/New()
|
|
check_icons()
|
|
|
|
/datum/pipe_icon_manager/proc/get_atmos_icon(var/device, var/dir, var/color, var/state)
|
|
check_icons()
|
|
|
|
device = "[device]"
|
|
state = "[state]"
|
|
color = "[color]"
|
|
dir = "[dir]"
|
|
|
|
switch(device)
|
|
if("pipe")
|
|
return pipe_icons[state + color]
|
|
if("manifold")
|
|
return manifold_icons[state + color]
|
|
if("device")
|
|
return device_icons[state]
|
|
if("omni")
|
|
return omni_icons[state]
|
|
if("underlay")
|
|
return underlays[state + dir + color]
|
|
// if("underlay_intact")
|
|
// return underlays_intact[state + dir + color]
|
|
// if("underlay_exposed")
|
|
// return underlays_exposed[state + dir + color]
|
|
// if("underlay_down")
|
|
// return underlays_down[state + dir + color]
|
|
// if("pipe_underlay_exposed")
|
|
// return pipe_underlays_exposed[state + dir + color]
|
|
// if("pipe_underlay_intact")
|
|
// return pipe_underlays_intact[state + dir + color]
|
|
|
|
/datum/pipe_icon_manager/proc/check_icons()
|
|
if(!pipe_icons)
|
|
gen_pipe_icons()
|
|
if(!manifold_icons)
|
|
gen_manifold_icons()
|
|
if(!device_icons)
|
|
gen_device_icons()
|
|
if(!omni_icons)
|
|
gen_omni_icons()
|
|
//if(!underlays_intact || !underlays_down || !underlays_exposed || !pipe_underlays_exposed || !pipe_underlays_intact)
|
|
if(!underlays)
|
|
gen_underlay_icons()
|
|
|
|
/datum/pipe_icon_manager/proc/gen_pipe_icons()
|
|
if(!pipe_icons)
|
|
pipe_icons = new()
|
|
|
|
var/icon/pipe = new('icons/atmos/pipes.dmi')
|
|
|
|
for(var/state in pipe.IconStates())
|
|
if(!state || findtext(state, "map"))
|
|
continue
|
|
|
|
var/cache_name = state
|
|
var/image/I = image('icons/atmos/pipes.dmi', icon_state = state)
|
|
pipe_icons[cache_name] = I
|
|
|
|
for(var/pipe_color in pipe_colors)
|
|
I = image('icons/atmos/pipes.dmi', icon_state = state)
|
|
I.color = pipe_colors[pipe_color]
|
|
pipe_icons[state + "[pipe_colors[pipe_color]]"] = I
|
|
|
|
pipe = new ('icons/atmos/heat.dmi')
|
|
for(var/state in pipe.IconStates())
|
|
if(!state || findtext(state, "map"))
|
|
continue
|
|
pipe_icons["hepipe" + state] = image('icons/atmos/heat.dmi', icon_state = state)
|
|
|
|
pipe = new ('icons/atmos/junction.dmi')
|
|
for(var/state in pipe.IconStates())
|
|
if(!state || findtext(state, "map"))
|
|
continue
|
|
pipe_icons["hejunction" + state] = image('icons/atmos/junction.dmi', icon_state = state)
|
|
|
|
|
|
/datum/pipe_icon_manager/proc/gen_manifold_icons()
|
|
if(!manifold_icons)
|
|
manifold_icons = new()
|
|
|
|
var/icon/pipe = new('icons/atmos/manifold.dmi')
|
|
|
|
for(var/state in pipe.IconStates())
|
|
if(findtext(state, "clamps"))
|
|
var/image/I = image('icons/atmos/manifold.dmi', icon_state = state)
|
|
manifold_icons[state] = I
|
|
continue
|
|
|
|
if(findtext(state, "core") || findtext(state, "4way"))
|
|
var/image/I = image('icons/atmos/manifold.dmi', icon_state = state)
|
|
manifold_icons[state] = I
|
|
for(var/pipe_color in pipe_colors)
|
|
I = image('icons/atmos/manifold.dmi', icon_state = state)
|
|
I.color = pipe_colors[pipe_color]
|
|
manifold_icons[state + pipe_colors[pipe_color]] = I
|
|
|
|
/datum/pipe_icon_manager/proc/gen_device_icons()
|
|
if(!device_icons)
|
|
device_icons = new()
|
|
|
|
var/icon/device
|
|
|
|
device = new('icons/atmos/vent_pump.dmi')
|
|
for(var/state in device.IconStates())
|
|
if(!state || findtext(state, "map"))
|
|
continue
|
|
device_icons["vent" + state] = image('icons/atmos/vent_pump.dmi', icon_state = state)
|
|
|
|
device = new('icons/atmos/vent_scrubber.dmi')
|
|
for(var/state in device.IconStates())
|
|
if(!state || findtext(state, "map"))
|
|
continue
|
|
device_icons["scrubber" + state] = image('icons/atmos/vent_scrubber.dmi', icon_state = state)
|
|
|
|
/datum/pipe_icon_manager/proc/gen_omni_icons()
|
|
if(!omni_icons)
|
|
omni_icons = new()
|
|
|
|
var/icon/omni = new('icons/atmos/omni_devices_vr.dmi') //VOREStation Edit - New Icons
|
|
|
|
for(var/state in omni.IconStates())
|
|
if(!state || findtext(state, "map"))
|
|
continue
|
|
omni_icons[state] = image('icons/atmos/omni_devices_vr.dmi', icon_state = state) //VOREStation Edit - New Icons
|
|
|
|
|
|
/datum/pipe_icon_manager/proc/gen_underlay_icons()
|
|
|
|
if(!underlays)
|
|
underlays = new()
|
|
|
|
var/icon/pipe = new('icons/atmos/pipe_underlays.dmi')
|
|
|
|
for(var/state in pipe.IconStates())
|
|
if(state == "")
|
|
continue
|
|
|
|
var/cache_name = state
|
|
|
|
for(var/D in cardinal)
|
|
var/image/I = image('icons/atmos/pipe_underlays.dmi', icon_state = state, dir = D)
|
|
underlays[cache_name + "[D]"] = I
|
|
for(var/pipe_color in pipe_colors)
|
|
I = image('icons/atmos/pipe_underlays.dmi', icon_state = state, dir = D)
|
|
I.color = pipe_colors[pipe_color]
|
|
underlays[state + "[D]" + "[pipe_colors[pipe_color]]"] = I
|
|
|
|
/*
|
|
Leaving the old icon manager code commented out for now, as we may want to rewrite the new code to cleanly
|
|
separate the newpipe icon caching (speshul supply and scrubber lines) from the rest of the pipe code.
|
|
*/
|
|
|
|
/*
|
|
/datum/pipe_icon_manager/proc/gen_underlay_icons()
|
|
if(!underlays_intact)
|
|
underlays_intact = new()
|
|
if(!underlays_exposed)
|
|
underlays_exposed = new()
|
|
if(!underlays_down)
|
|
underlays_down = new()
|
|
if(!pipe_underlays_exposed)
|
|
pipe_underlays_exposed = new()
|
|
if(!pipe_underlays_intact)
|
|
pipe_underlays_intact = new()
|
|
|
|
var/icon/pipe = new('icons/atmos/pipe_underlays.dmi')
|
|
|
|
for(var/state in pipe.IconStates())
|
|
if(state == "")
|
|
continue
|
|
|
|
for(var/D in cardinal)
|
|
var/image/I = image('icons/atmos/pipe_underlays.dmi', icon_state = state, dir = D)
|
|
switch(state)
|
|
if("intact")
|
|
underlays_intact["[D]"] = I
|
|
if("exposed")
|
|
underlays_exposed["[D]"] = I
|
|
if("down")
|
|
underlays_down["[D]"] = I
|
|
if("pipe_exposed")
|
|
pipe_underlays_exposed["[D]"] = I
|
|
if("pipe_intact")
|
|
pipe_underlays_intact["[D]"] = I
|
|
if("intact-supply")
|
|
underlays_intact["[D]"] = I
|
|
if("exposed-supply")
|
|
underlays_exposed["[D]"] = I
|
|
if("down-supply")
|
|
underlays_down["[D]"] = I
|
|
if("pipe_exposed-supply")
|
|
pipe_underlays_exposed["[D]"] = I
|
|
if("pipe_intact-supply")
|
|
pipe_underlays_intact["[D]"] = I
|
|
if("intact-scrubbers")
|
|
underlays_intact["[D]"] = I
|
|
if("exposed-scrubbers")
|
|
underlays_exposed["[D]"] = I
|
|
if("down-scrubbers")
|
|
underlays_down["[D]"] = I
|
|
if("pipe_exposed-scrubbers")
|
|
pipe_underlays_exposed["[D]"] = I
|
|
if("pipe_intact-scrubbers")
|
|
pipe_underlays_intact["[D]"] = I
|
|
for(var/pipe_color in pipe_colors)
|
|
I = image('icons/atmos/pipe_underlays.dmi', icon_state = state, dir = D)
|
|
I.color = pipe_colors[pipe_color]
|
|
switch(state)
|
|
if("intact")
|
|
underlays_intact["[D]" + pipe_colors[pipe_color]] = I
|
|
if("exposed")
|
|
underlays_exposed["[D]" + pipe_colors[pipe_color]] = I
|
|
if("down")
|
|
underlays_down["[D]" + pipe_colors[pipe_color]] = I
|
|
if("pipe_exposed")
|
|
pipe_underlays_exposed["[D]" + pipe_colors[pipe_color]] = I
|
|
if("pipe_intact")
|
|
pipe_underlays_intact["[D]" + pipe_colors[pipe_color]] = I
|
|
if("intact-supply")
|
|
underlays_intact["[D]" + pipe_colors[pipe_color]] = I
|
|
if("exposed-supply")
|
|
underlays_exposed["[D]" + pipe_colors[pipe_color]] = I
|
|
if("down-supply")
|
|
underlays_down["[D]" + pipe_colors[pipe_color]] = I
|
|
if("pipe_exposed-supply")
|
|
pipe_underlays_exposed["[D]" + pipe_colors[pipe_color]] = I
|
|
if("pipe_intact-supply")
|
|
pipe_underlays_intact["[D]" + pipe_colors[pipe_color]] = I
|
|
if("intact-scrubbers")
|
|
underlays_intact["[D]" + pipe_colors[pipe_color]] = I
|
|
if("exposed-scrubbers")
|
|
underlays_exposed["[D]" + pipe_colors[pipe_color]] = I
|
|
if("down-scrubbers")
|
|
underlays_down["[D]" + pipe_colors[pipe_color]] = I
|
|
if("pipe_exposed-scrubbers")
|
|
pipe_underlays_exposed["[D]" + pipe_colors[pipe_color]] = I
|
|
if("pipe_intact-scrubbers")
|
|
pipe_underlays_intact["[D]" + pipe_colors[pipe_color]] = I
|
|
|
|
*/
|