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

[PORT] [HELP] Smooth computers #21620

Closed
wants to merge 12 commits into from
12 changes: 11 additions & 1 deletion code/__DEFINES/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
/// it represents the sides of our directional border object that have a neighbor
/// Is incompatible with SMOOTH_CORNERS because border objects don't have corners
#define SMOOTH_BORDER_OBJECT (1<<6)
/// Smooths with atoms facing the same direction only
#define SMOOTH_DIRECTIONAL (1<<7)
/// Skips the corner step of bitmask smoothing (does nothing without SMOOTH_BITMASK)
#define SMOOTH_BITMASK_SKIP_CORNERS (1<<8)

DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_CORNERS" = SMOOTH_CORNERS,
Expand All @@ -25,6 +29,8 @@ DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_QUEUED" = SMOOTH_QUEUED,
"SMOOTH_OBJ" = SMOOTH_OBJ,
"SMOOTH_BORDER_OBJECT" = SMOOTH_BORDER_OBJECT,
"SMOOTH_DIRECTIONAL" = SMOOTH_DIRECTIONAL,
"SMOOTH_BITMASK_SKIP_CORNERS" = SMOOTH_BITMASK_SKIP_CORNERS,
))

/// Components of a smoothing junction
Expand Down Expand Up @@ -201,7 +207,11 @@ DEFINE_BITFIELD(smoothing_junction, list(

#define SMOOTH_GROUP_CLEANABLE_DIRT S_OBJ(68) ///obj/effect/decal/cleanable/dirt

#define SMOOTH_GROUP_GAS_TANK S_OBJ(72)
#define SMOOTH_GROUP_COMPUTERS S_OBJ(69) ///obj/machinery/computer, /obj/machinery/modular_console

#define SMOOTH_GROUP_GAS_TANK S_OBJ(70)




/// Performs the work to set smoothing_groups and canSmoothWith.
Expand Down
44 changes: 31 additions & 13 deletions code/__HELPERS/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -320,29 +320,36 @@
var/area/source_area = get_area(src)
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/atom/movable/thing as anything in target_turf)
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 @@ -359,6 +366,15 @@
var/smooth_border = (smoothing_flags & SMOOTH_BORDER)
var/smooth_obj = (smoothing_flags & SMOOTH_OBJ)
var/border_object_smoothing = (smoothing_flags & SMOOTH_BORDER_OBJECT)
var/smooth_directional = (smoothing_flags & SMOOTH_DIRECTIONAL)
var/skip_corners = (smoothing_flags & SMOOTH_BITMASK_SKIP_CORNERS)

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

// Did you know you can pass defines into other defines? very handy, lets take advantage of it here to allow 0 cost variation
#define SEARCH_ADJ_IN_DIR(direction, direction_flag, ADJ_FOUND, WORLD_BORDER, BORDER_CHECK) \
Expand Down Expand Up @@ -392,6 +408,7 @@
} while(FALSE) \

#define BITMASK_FOUND(target, direction, direction_flag) \
EXTRA_CHECKS(target); \
new_junction |= direction_flag; \
break set_adj_in_dir; \
/// Check that non border objects use to smooth against border objects
Expand Down Expand Up @@ -428,29 +445,29 @@
set_smoothed_icon_state(new_junction)
return

SET_ADJ_IN_DIR(NORTH, NORTH)

Check warning on line 448 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"
SET_ADJ_IN_DIR(SOUTH, SOUTH)

Check warning on line 449 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"
SET_ADJ_IN_DIR(EAST, EAST)

Check warning on line 450 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"
SET_ADJ_IN_DIR(WEST, WEST)

Check warning on line 451 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"

// If there's nothing going on already
if(!(new_junction & (NORTH|SOUTH)) || !(new_junction & (EAST|WEST)))
if(skip_corners || !(new_junction & (NORTH|SOUTH)) || !(new_junction & (EAST|WEST)))
set_smoothed_icon_state(new_junction)
return

if(new_junction & NORTH_JUNCTION)
if(new_junction & WEST_JUNCTION)
SET_ADJ_IN_DIR(NORTHWEST, NORTHWEST_JUNCTION)

Check warning on line 460 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"

if(new_junction & EAST_JUNCTION)
SET_ADJ_IN_DIR(NORTHEAST, NORTHEAST_JUNCTION)

Check warning on line 463 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"

if(new_junction & SOUTH_JUNCTION)
if(new_junction & WEST_JUNCTION)
SET_ADJ_IN_DIR(SOUTHWEST, SOUTHWEST_JUNCTION)

Check warning on line 467 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"

if(new_junction & EAST_JUNCTION)
SET_ADJ_IN_DIR(SOUTHEAST, SOUTHEAST_JUNCTION)

Check warning on line 470 in code/__HELPERS/icon_smoothing.dm

View workflow job for this annotation

GitHub Actions / Lints

field access requires static type: "dir"

set_smoothed_icon_state(new_junction)

Expand All @@ -462,6 +479,7 @@
#undef BITMASK_ON_BORDER_CHECK
#undef BITMASK_FOUND
#undef SEARCH_ADJ_IN_DIR
#undef EXTRA_CHECKS

///Changes the icon state based on the new junction bitmask
/atom/proc/set_smoothed_icon_state(new_junction)
Expand Down
7 changes: 7 additions & 0 deletions code/game/machinery/bank_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
name = "bank machine"
desc = "A machine used to deposit and withdraw station funds."
icon = 'goon/icons/obj/goon_terminals.dmi'

//these muthafuckas arent supposed to smooth until we get console icons for it :^
base_icon_state = null
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null

idle_power_usage = 100

var/siphoning = FALSE
Expand Down
24 changes: 22 additions & 2 deletions code/game/machinery/computer/_computer.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/obj/machinery/computer
name = "computer"
icon = 'icons/obj/computer.dmi'
icon_state = "computer"
icon_state = "computer-0"

density = TRUE
use_power = IDLE_POWER_USE
idle_power_usage = 300
Expand All @@ -10,6 +11,12 @@
integrity_failure = 100
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 40, ACID = 20)
clicksound = "keyboard"

base_icon_state = "computer"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL | SMOOTH_BITMASK_SKIP_CORNERS | SMOOTH_OBJ //SMOOTH_OBJ is needed because of narsie_act using initial() to restore
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)

/// How bright we are when turned on.
var/brightness_on = 1
/// Icon_state of the keyboard overlay.
Expand All @@ -27,6 +34,8 @@

/obj/machinery/computer/Initialize(mapload, obj/item/circuitboard/C)
. = ..()
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
if(mapload)
update_appearance()
power_change()
Expand All @@ -37,6 +46,7 @@

/obj/machinery/computer/Destroy()
QDEL_NULL(circuit)
QUEUE_SMOOTH_NEIGHBORS(src)
return ..()

/obj/machinery/computer/process()
Expand All @@ -50,14 +60,24 @@
icon_screen = "ratvar[rand(1, 4)]"
icon_keyboard = "ratvar_key[rand(1, 6)]"
icon_state = "ratvarcomputer[rand(1, 4)]"
smoothing_groups = null
QUEUE_SMOOTH_NEIGHBORS(src)
smoothing_flags = NONE
update_appearance()

/obj/machinery/computer/narsie_act()
if(clockwork && clockwork != initial(clockwork)) //if it's clockwork but isn't normally clockwork
clockwork = FALSE
icon_screen = initial(icon_screen)
icon_keyboard = initial(icon_keyboard)
icon_state = initial(icon_state)
smoothing_flags = initial(smoothing_flags)
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
SET_SMOOTHING_GROUPS(smoothing_groups)
SET_SMOOTHING_GROUPS(canSmoothWith)
QUEUE_SMOOTH(src)
if(smoothing_flags)
QUEUE_SMOOTH_NEIGHBORS(src)
update_appearance()

/obj/machinery/computer/update_appearance(updates)
Expand Down
7 changes: 7 additions & 0 deletions code/game/machinery/computer/arcade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ GLOBAL_LIST_INIT(arcade_prize_pool, list(
icon_state = "arcade"
icon_keyboard = null
icon_screen = "invaders"

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

clockwork = TRUE //it'd look weird
var/list/prize_override
light_color = LIGHT_COLOR_GREEN
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 @@ -188,6 +188,13 @@
icon_state = "television"
icon_keyboard = null
icon_screen = "detective_tv"

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

clockwork = TRUE //it'd look weird
pass_flags = PASSTABLE

Expand Down Expand Up @@ -231,6 +238,13 @@
icon_state = "telescreen"
icon_keyboard = null
icon_screen = null

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

layer = SIGN_LAYER
network = list("thunder")
density = FALSE
Expand Down
7 changes: 7 additions & 0 deletions code/game/machinery/computer/camera_advanced.dm
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,13 @@
/obj/machinery/computer/camera_advanced/ratvar
name = "ratvarian camera observer"
desc = "A console used to snoop on the station's goings-on. A jet of steam occasionally whooshes out from slats on its sides."

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

use_power = FALSE
networks = list("ss13", "minisat") //:eye:
var/datum/action/innate/servant_warp/warp_action = /datum/action/innate/servant_warp
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 @@ -13,7 +13,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/obj/item/card/id/modify = null
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 @@ -574,6 +574,13 @@
icon_state = "laptop"
icon_screen = "medlaptop"
icon_keyboard = "laptop_key"

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

clockwork = TRUE //it'd look weird
pass_flags = PASSTABLE

Expand Down
6 changes: 6 additions & 0 deletions code/game/machinery/computer/pod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
icon_screen = "library"
icon_keyboard = null

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

/obj/machinery/computer/pod/old/syndicate
name = "\improper ProComp Executive IIc"
desc = "The Syndicate operate on a tight budget. Operates external airlocks."
Expand Down
7 changes: 7 additions & 0 deletions code/game/machinery/computer/security.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
icon_state = "laptop"
icon_screen = "seclaptop"
icon_keyboard = "laptop_key"

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

clockwork = TRUE //it'd look weird
pass_flags = PASSTABLE

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/mindmachine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
desc = "The main hub of a complete mind machine setup. Placed between two mind pods and used to control and manage the transfer. \
Houses an experimental bluespace conduit which uses bluespace crystals for charge."
icon = 'icons/obj/computer.dmi'
icon_state = "computer" // This may appear to be a computer, but it is a machine (that looks like a computer).
icon_state = "computer-0" // This may appear to be a computer, but it is a machine (that looks like a computer).
density = TRUE
circuit = /obj/item/circuitboard/machine/mindmachine_hub
/// The current icon of the screen.
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
6 changes: 6 additions & 0 deletions code/modules/antagonists/abductor/machinery/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
icon_screen = null
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF

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

/obj/machinery/computer/camera_advanced/abductor/CreateEye()
..()
eyeobj.visible_icon = TRUE
Expand Down
16 changes: 12 additions & 4 deletions code/modules/goals/station_goals/bsa.dm
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,21 @@

/obj/machinery/computer/bsa_control
name = "bluespace artillery control"
icon = 'icons/obj/machines/particle_accelerator.dmi'
icon_state = "control_boxp"

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

use_power = NO_POWER_USE
circuit = /obj/item/circuitboard/computer/bsa_control

var/obj/machinery/bsa/full/cannon
var/notice
var/target
use_power = NO_POWER_USE
circuit = /obj/item/circuitboard/computer/bsa_control
icon = 'icons/obj/machines/particle_accelerator.dmi'
icon_state = "control_boxp"
var/area_aim = FALSE //should also show areas for targeting

/obj/machinery/computer/bsa_control/ui_state(mob/user)
Expand Down
Loading
Loading