Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computer smoothing from Bay #9834

Merged
merged 18 commits into from
Oct 7, 2023
6 changes: 3 additions & 3 deletions _maps/RandomRuins/LavaRuins/lavaland_surface_golem_ship.dmm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions _maps/RandomRuins/LavaRuins/lavaland_surface_seed_vault.dmm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion code/__DEFINES/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#define SMOOTH_QUEUED (1<<4)
/// Smooths with objects, and will thus need to scan turfs for contents.
#define SMOOTH_OBJ (1<<5)

/// Smooths with atoms facing the same direction only
#define SMOOTH_DIRECTIONAL (1<<6)

DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_CORNERS" = SMOOTH_CORNERS,
Expand All @@ -20,6 +21,7 @@ DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_BORDER" = SMOOTH_BORDER,
"SMOOTH_QUEUED" = SMOOTH_QUEUED,
"SMOOTH_OBJ" = SMOOTH_OBJ,
"SMOOTH_DIRECTIONAL" = SMOOTH_DIRECTIONAL,
))


Expand Down Expand Up @@ -114,6 +116,8 @@ DEFINE_BITFIELD(smoothing_flags, list(
#define SMOOTH_GROUP_HEDGE_FLUFF S_OBJ(65) ///obj/structure/fluff/hedge
#define SMOOTH_GROUP_SHUTTLE_PARTS S_OBJ(66) ///obj/structure/window/shuttle, /obj/structure/window/plasma/reinforced/plastitanium, /turf/closed/indestructible/opsglass, /obj/structure/shuttle
#define SMOOTH_GROUP_CLEANABLE_DIRT S_OBJ(67) ///obj/effect/decal/cleanable/dirt
///obj/machinery/computer/_computer
#define SMOOTH_GROUP_COMPUTERS S_OBJ (68)

//LIQUIDS

Expand Down
43 changes: 30 additions & 13 deletions code/__HELPERS/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -241,29 +241,36 @@ DEFINE_BITFIELD(smoothing_junction, list(
if((source_area.area_limited_icon_smoothing && !istype(target_area, source_area.area_limited_icon_smoothing)) || (target_area.area_limited_icon_smoothing && !istype(source_area, target_area.area_limited_icon_smoothing)))
return NO_ADJ_FOUND

var/atom/match //Used later in a special check

if(isnull(canSmoothWith)) //special case in which it will only smooth with itself
if(isturf(src))
return (type == target_turf.type) ? ADJ_FOUND : NO_ADJ_FOUND
var/atom/matching_obj = locate(type) in target_turf
return (matching_obj && matching_obj.type == type) ? ADJ_FOUND : NO_ADJ_FOUND
match = (type == target_turf.type) ? target_turf : null
else
var/atom/matching_obj = locate(type) in target_turf
match = (matching_obj && matching_obj.type == type) ? matching_obj : null

if(!isnull(target_turf.smoothing_groups))
if(isnull(match) && !isnull(target_turf.smoothing_groups))
for(var/target in canSmoothWith)
if(!(canSmoothWith[target] & target_turf.smoothing_groups[target]))
continue
return ADJ_FOUND
if(canSmoothWith[target] & target_turf.smoothing_groups[target])
match = target_turf

if(smoothing_flags & SMOOTH_OBJ)
if(isnull(match) && smoothing_flags & SMOOTH_OBJ)
for(var/am in target_turf)
var/atom/movable/thing = am
if(!thing.anchored || isnull(thing.smoothing_groups))
continue
for(var/target in canSmoothWith)
if(!(canSmoothWith[target] & thing.smoothing_groups[target]))
continue
return ADJ_FOUND
if(canSmoothWith[target] & thing.smoothing_groups[target])
match = thing

return NO_ADJ_FOUND
if(isnull(match))
return NO_ADJ_FOUND
. = ADJ_FOUND

if(smoothing_flags & SMOOTH_DIRECTIONAL)
if(match.dir != dir)
return NO_ADJ_FOUND

/**
* Basic smoothing proc. The atom checks for adjacent directions to smooth with and changes the icon_state based on that.
Expand All @@ -279,6 +286,14 @@ DEFINE_BITFIELD(smoothing_junction, list(

var/smooth_border = (smoothing_flags & SMOOTH_BORDER)
var/smooth_obj = (smoothing_flags & SMOOTH_OBJ)
var/smooth_directional = (smoothing_flags & SMOOTH_DIRECTIONAL)

#define EXTRA_CHECKS(atom) \
if(smooth_directional) { \
if(atom.dir != dir) { \
break set_adj_in_dir; \
}; \
}; \

#define SET_ADJ_IN_DIR(direction, direction_flag) \
set_adj_in_dir: { \
Expand All @@ -289,6 +304,7 @@ DEFINE_BITFIELD(smoothing_junction, list(
if(neighbor_smoothing_groups) { \
for(var/target in canSmoothWith) { \
if(canSmoothWith[target] & neighbor_smoothing_groups[target]) { \
EXTRA_CHECKS(neighbor); \
new_junction |= direction_flag; \
break set_adj_in_dir; \
}; \
Expand All @@ -302,6 +318,7 @@ DEFINE_BITFIELD(smoothing_junction, list(
}; \
for(var/target in canSmoothWith) { \
if(canSmoothWith[target] & thing_smoothing_groups[target]) { \
EXTRA_CHECKS(thing); \
new_junction |= direction_flag; \
break set_adj_in_dir; \
}; \
Expand Down Expand Up @@ -338,7 +355,7 @@ DEFINE_BITFIELD(smoothing_junction, list(
set_smoothed_icon_state(new_junction)

#undef SET_ADJ_IN_DIR

#undef EXTRA_CHECKS

///Changes the icon state based on the new junction bitmask. Returns the old junction value.
/atom/proc/set_smoothed_icon_state(new_junction)
Expand Down
9 changes: 8 additions & 1 deletion code/game/machinery/computer/_computer.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/obj/machinery/computer
name = "computer"
icon = 'icons/obj/computer.dmi'
icon_state = "computer"
icon_state = "computer-0"
base_icon_state = "computer"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 300
Expand All @@ -26,6 +30,9 @@

/obj/machinery/computer/Initialize(mapload, obj/item/circuitboard/C)
. = ..()
if(smoothing_flags & SMOOTH_BITMASK)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
power_change()
if(!QDELETED(C))
qdel(circuit)
Expand Down
9 changes: 8 additions & 1 deletion code/game/machinery/computer/arcade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@ GLOBAL_LIST_INIT(arcade_prize_pool, list(
icon_state = "arcade"
icon_keyboard = "no_keyboard"
icon_screen = "invaders"

//these muthafuckas arent supposed to smooth
base_icon_state = null
smoothing_flags = null
smoothing_groups = null
canSmoothWith = null

clockwork = TRUE //it'd look weird
broken_overlay_emissive = TRUE
light_color = LIGHT_COLOR_GREEN
var/list/prize_override
var/prizeselect = /obj/item/coin/arcade_token
light_color = LIGHT_COLOR_GREEN

/obj/machinery/computer/arcade/proc/Reset()
return
Expand Down
2 changes: 0 additions & 2 deletions code/game/machinery/computer/atmos_alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
name = "atmospheric alert console"
desc = "Used to monitor the station's air alarms."
circuit = /obj/item/circuitboard/computer/atmos_alert


icon_screen = "alert:0"
icon_keyboard = "atmos_key"
var/list/priority_alarms = list()
Expand Down
14 changes: 14 additions & 0 deletions code/game/machinery/computer/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@
icon_state = "television"
icon_keyboard = "no_keyboard"
icon_screen = "detective_tv"

//these muthafuckas arent supposed to smooth
base_icon_state = null
smoothing_flags = null
smoothing_groups = null
canSmoothWith = null

clockwork = TRUE //it'd look weird
broken_overlay_emissive = TRUE
pass_flags = PASSTABLE
Expand Down Expand Up @@ -270,6 +277,13 @@
desc = "Used for watching an empty arena."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "telescreen"

//these muthafuckas arent supposed to smooth
base_icon_state = null
smoothing_flags = null
smoothing_groups = null
canSmoothWith = null

layer = SIGN_LAYER
network = list("thunder")
density = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/card.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
name = "identification console"
desc = "You can use this to manage jobs and ID access."
icon_screen = "id"
icon_keyboard = "id_key"
icon_keyboard = "generic_key"
req_one_access = list(ACCESS_HEADS, ACCESS_CHANGE_IDS)
circuit = /obj/item/circuitboard/computer/card
var/mode = 0
Expand Down
7 changes: 7 additions & 0 deletions code/game/machinery/computer/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@
icon_state = "laptop"
icon_screen = "medlaptop"
icon_keyboard = "laptop_key"

//these muthafuckas arent supposed to smooth
base_icon_state = null
smoothing_flags = null
smoothing_groups = null
canSmoothWith = null

clockwork = TRUE //it'd look weird
broken_overlay_emissive = TRUE
pass_flags = PASSTABLE
7 changes: 7 additions & 0 deletions code/game/machinery/computer/security.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@
icon_state = "laptop"
icon_screen = "seclaptop"
icon_keyboard = "laptop_key"

//these muthafuckas arent supposed to smooth
base_icon_state = null
smoothing_flags = null
smoothing_groups = null
canSmoothWith = null

clockwork = TRUE //it'd look weird
broken_overlay_emissive = TRUE
pass_flags = PASSTABLE
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/structures/showcase.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
name = "\improper CentCom identification console"
desc = "You can use this to change ID's."
icon = 'icons/obj/computer.dmi'
icon_state = "computer"
icon_state = "computer-0"

/obj/structure/showcase/fakeid/Initialize(mapload)
. = ..()
add_overlay("id")
add_overlay("id_key")
add_overlay("generic_key")

/obj/structure/showcase/fakesec
name = "\improper CentCom security records"
desc = "Used to view and edit personnel's security records."
icon = 'icons/obj/computer.dmi'
icon_state = "computer"
icon_state = "computer-0"

/obj/structure/showcase/fakesec/Initialize(mapload)
. = ..()
Expand Down
11 changes: 9 additions & 2 deletions code/modules/library/lib_machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@
icon_state = "oldcomp"
icon_screen = "library"
icon_keyboard = null

//these muthafuckas arent supposed to smooth
base_icon_state = null
smoothing_flags = null
smoothing_groups = null
canSmoothWith = null

circuit = /obj/item/circuitboard/computer/libraryconsole
desc = "Checked out books MUST be returned on time."
clockwork = TRUE //it'd look weird
broken_overlay_emissive = TRUE
var/screenstate = 0
var/title
var/category = "Any"
var/author
var/search_page = 0
clockwork = TRUE //it'd look weird
broken_overlay_emissive = TRUE

/obj/machinery/computer/libraryconsole/ui_interact(mob/user)
. = ..()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/obj/machinery/modular_computer/console
name = "console"
desc = "A stationary computer."

icon = 'icons/obj/modular_console.dmi'
icon_state = "console"
icon_state_powered = "console"
icon_state_unpowered = "console-off"
icon_state = "console-0"
screen_icon_state_menu = "menu"
base_icon_state = "console"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
hardware_flag = PROGRAM_CONSOLE
density = TRUE
base_idle_power_usage = 100
Expand All @@ -30,6 +31,10 @@

/obj/machinery/modular_computer/console/Initialize(mapload)
. = ..()
if(smoothing_flags & SMOOTH_BITMASK)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)

var/obj/item/computer_hardware/battery/battery_module = cpu.all_components[MC_CELL]
if(battery_module)
qdel(battery_module)
Expand All @@ -53,3 +58,21 @@
if(cpu)
cpu.screen_on = 1
update_icon()

// Same as parent code, but without the smoothing handling
/obj/machinery/modular_computer/update_icon()
cut_overlays()

if(!cpu || !cpu.enabled)
if (!(machine_stat & NOPOWER) && (cpu && cpu.use_power()))
add_overlay(screen_icon_screensaver)
else
if(cpu.active_program)
add_overlay(cpu.active_program.program_icon_state ? cpu.active_program.program_icon_state : screen_icon_state_menu)
else
add_overlay(screen_icon_state_menu)

if(cpu && cpu.obj_integrity <= cpu.integrity_failure)
add_overlay("bsod")
add_overlay("broken")

9 changes: 8 additions & 1 deletion code/modules/power/solar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@
name = "solar panel control"
desc = "A controller for solar panel arrays."
icon = 'icons/obj/computer.dmi'
icon_state = "computer"
icon_state = "computer-0"
base_icon_state = "computer"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 250
Expand All @@ -278,6 +282,9 @@

/obj/machinery/power/solar_control/Initialize(mapload)
. = ..()
if(smoothing_flags & SMOOTH_BITMASK)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
if(powernet)
set_panels(currentdir)
connect_to_network()
Expand Down
Loading