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

Adds setter for anchored. Cleans up a lot of anchored, density, and update_icon implementations #8941

Merged
merged 13 commits into from
Mar 3, 2024
Merged
7 changes: 5 additions & 2 deletions code/__DEFINES/dcs/signals/signals_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
#define HEARING_SPANS 6
#define HEARING_MESSAGE_MODE 7
*/
#define COMSIG_MOVABLE_DISPOSING "movable_disposing" //! called when the movable is added to a disposal holder object for disposal movement: (obj/structure/disposalholder/holder, obj/machinery/disposal/source)
// called when movable is expelled from a disposal pipe, bin or outlet on obj/pipe_eject: (direction)
///called when the movable is added to a disposal holder object for disposal movement: (obj/structure/disposalholder/holder, obj/machinery/disposal/source)
#define COMSIG_MOVABLE_DISPOSING "movable_disposing"
///called when movable is expelled from a disposal pipe, bin or outlet on obj/pipe_eject: (direction)
#define COMSIG_MOVABLE_PIPE_EJECTING "movable_pipe_ejecting"
///called when the movable sucessfully has it's anchored var changed, from base atom/movable/set_anchored(): (value)
#define COMSIG_MOVABLE_SET_ANCHORED "movable_set_anchored"

///from base of atom/movable/newtonian_move(): (inertia_direction)
#define COMSIG_MOVABLE_NEWTONIAN_MOVE "movable_newtonian_move"
Expand Down
1 change: 0 additions & 1 deletion code/__DEFINES/dcs/signals/signals_obj/signals_object.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// /obj signals
#define COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH "obj_default_unfasten_wrench"
#define COMSIG_OBJ_DECONSTRUCT "obj_deconstruct" //! from base of obj/deconstruct(): (disassembled)
#define COMSIG_OBJ_SETANCHORED "obj_setanchored" //! called in /obj/structure/setAnchored(): (value)
#define COMSIG_OBJ_HIDE "obj_hide" //from base of /turf/proc/levelupdate(). (intact) true to hide and false to unhide

/// from /obj/proc/make_unfrozen()
Expand Down
11 changes: 9 additions & 2 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,22 @@ GLOBAL_LIST_INIT(glass_sheet_types, typecacheof(list(

#define isshuttleturf(T) (length(T.baseturfs) && (/turf/baseturf_skipover/shuttle in T.baseturfs))

#define isbook(O) (is_type_in_typecache(O, GLOB.book_types))

GLOBAL_LIST_INIT(book_types, typecacheof(list(
/obj/item/book,
/obj/item/spellbook,
/obj/item/storage/book)))

#define IS_EDIBLE(O) (O.GetComponent(/datum/component/edible))
Tsar-Salat marked this conversation as resolved.
Show resolved Hide resolved

/// isnum() returns TRUE for NaN. Also, NaN != NaN. Checkmate, BYOND.
#define isnan(x) ( (x) != (x) )

#define isinf(x) (isnum((x)) && (((x) == SYSTEM_TYPE_INFINITY) || ((x) == -SYSTEM_TYPE_INFINITY)))

#define isProbablyWallMounted(O) (O.pixel_x > 20 || O.pixel_x < -20 || O.pixel_y > 20 || O.pixel_y < -20)

#define isbook(O) (is_type_in_typecache(O, GLOB.book_types))

/// NaN isn't a number, damn it. Infinity is a problem too.
#define isnum_safe(x) ( isnum((x)) && !isnan((x)) && !isinf((x)) )

Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/cult_ritual_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
*/
/datum/component/cult_ritual_item/proc/do_unanchor_structure(obj/structure/cult_structure, mob/living/cultist)
playsound(cult_structure, 'sound/items/deconstruct.ogg', 30, TRUE, ignore_walls = FALSE)
cult_structure.anchored = !cult_structure.anchored
cult_structure.set_anchored(!cult_structure.anchored)
to_chat(cultist, "<span class='notice'>You [cult_structure.anchored ? "":"un"]secure \the [cult_structure] [cult_structure.anchored ? "to":"from"] the floor.</span>")

/*
Expand Down
4 changes: 2 additions & 2 deletions code/datums/elements/undertile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if(use_alpha)
source.alpha = ALPHA_UNDERTILE
if(use_anchor)
source.anchored = TRUE
source.set_anchored(TRUE)

else
if(invisibility_trait)
Expand All @@ -57,7 +57,7 @@
if(use_alpha)
source.alpha = 255
if(use_anchor)
source.anchored = FALSE
source.set_anchored(FALSE)

/datum/element/undertile/Detach(atom/movable/AM, visibility_trait, invisibility_level = INVISIBILITY_MAXIMUM)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/wires/syndicatebomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
if(!mend && B.anchored)
holder.visible_message("<span class='notice'>[icon2html(B, viewers(holder))] The bolts lift out of the ground!</span>")
playsound(B, 'sound/effects/stealthoff.ogg', 30, 1)
B.anchored = FALSE
B.set_anchored(FALSE)
if(WIRE_PROCEED)
if(!mend && B.active)
holder.visible_message("<span class='danger'>[icon2html(B, viewers(holder))] An alarm sounds! It's go-</span>")
Expand Down
12 changes: 12 additions & 0 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
if((var_name in careful_edits) && (var_value % world.icon_size) != 0)
return FALSE
switch(var_name)
if(NAMEOF(src, anchored))
set_anchored(var_value)
return TRUE
if(NAMEOF(src, x))
var/turf/T = locate(var_value, y, z)
if(T)
Expand Down Expand Up @@ -545,6 +548,15 @@
return
A.Bumped(src)

///Sets the anchored var and returns if it was sucessfully changed or not.
/atom/movable/proc/set_anchored(anchorvalue)
SHOULD_CALL_PARENT(TRUE)
if(anchored == anchorvalue)
return
. = anchored
anchored = anchorvalue
SEND_SIGNAL(src, COMSIG_MOVABLE_SET_ANCHORED, anchorvalue)

/atom/movable/proc/forceMove(atom/destination)
. = FALSE
if(destination == null) //destination destroyed due to explosion
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ Class Procs:
to_chat(user, "<span class='notice'>You fail to secure [src].</span>")
return CANT_UNFASTEN
to_chat(user, "<span class='notice'>You [anchored ? "un" : ""]secure [src].</span>")
setAnchored(!anchored)
set_anchored(!anchored)
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
SEND_SIGNAL(src, COMSIG_OBJ_DEFAULT_UNFASTEN_WRENCH, anchored)
return SUCCESSFUL_UNFASTEN
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/camera_assembly.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
if(W.tool_behaviour == TOOL_WELDER)
if(weld(W, user))
to_chat(user, "<span class='notice'>You weld [src] securely into place.</span>")
setAnchored(TRUE)
set_anchored(TRUE)
state = STATE_WELDED
return

Expand All @@ -122,7 +122,7 @@
if(weld(W, user))
to_chat(user, "<span class='notice'>You unweld [src] from its place.</span>")
state = STATE_WRENCHED
setAnchored(TRUE)
set_anchored(TRUE)
return

if(STATE_WIRED) // Upgrades!
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
var/obj/structure/frame/computer/A = new /obj/structure/frame/computer(src.loc)
A.setDir(dir)
A.circuit = circuit
A.setAnchored(TRUE)
A.set_anchored(TRUE)
if(machine_stat & BROKEN)
if(user)
to_chat(user, "<span class='notice'>The broken glass falls out.</span>")
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/buildandrepair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
to_chat(user, "<span class='notice'>You start wrenching the frame into place...</span>")
if(P.use_tool(src, user, 20, volume=50))
to_chat(user, "<span class='notice'>You wrench the frame into place.</span>")
setAnchored(TRUE)
set_anchored(TRUE)
state = 1
return
if(P.tool_behaviour == TOOL_WELDER)
Expand All @@ -29,7 +29,7 @@
to_chat(user, "<span class='notice'>You start to unfasten the frame...</span>")
if(P.use_tool(src, user, 20, volume=50))
to_chat(user, "<span class='notice'>You unfasten the frame.</span>")
setAnchored(FALSE)
set_anchored(FALSE)
state = 0
return
if(istype(P, /obj/item/circuitboard/computer) && !circuit)
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/constructable_frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@
if(P.use_tool(src, user, 40, volume=75))
if(state == 1)
to_chat(user, "<span class='notice'>You [anchored ? "un" : ""]secure [src].</span>")
setAnchored(!anchored)
set_anchored(!anchored)
return

if(2)
if(P.tool_behaviour == TOOL_WRENCH)
to_chat(user, "<span class='notice'>You start [anchored ? "un" : ""]securing [src]...</span>")
if(P.use_tool(src, user, 40, volume=75))
to_chat(user, "<span class='notice'>You [anchored ? "un" : ""]secure [src].</span>")
setAnchored(!anchored)
set_anchored(!anchored)
return

if(istype(P, /obj/item/circuitboard/machine))
Expand Down Expand Up @@ -168,7 +168,7 @@
to_chat(user, "<span class='notice'>You start [anchored ? "un" : ""]securing [src]...</span>")
if(P.use_tool(src, user, 40, volume=75))
to_chat(user, "<span class='notice'>You [anchored ? "un" : ""]secure [src].</span>")
setAnchored(!anchored)
set_anchored(!anchored)
return

if(P.tool_behaviour == TOOL_SCREWDRIVER)
Expand All @@ -183,7 +183,7 @@
if(new_machine.circuit)
QDEL_NULL(new_machine.circuit)
new_machine.circuit = circuit
new_machine.setAnchored(anchored)
new_machine.set_anchored(anchored)
new_machine.on_construction()
for(var/obj/O in new_machine.component_parts)
qdel(O)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/dance_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
if(O.tool_behaviour == TOOL_WRENCH)
if(!anchored && !isinspace())
to_chat(user,"<span class='notice'>You secure [src] to the floor.</span>")
setAnchored(TRUE)
set_anchored(TRUE)
else if(anchored)
to_chat(user,"<span class='notice'>You unsecure and disconnect [src].</span>")
setAnchored(FALSE)
set_anchored(FALSE)
playsound(src, 'sound/items/deconstruct.ogg', 50, 1)
return
return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@
A = new /obj/structure/door_assembly(loc)
//If you come across a null assemblytype, it will produce the default assembly instead of disintegrating.
A.heat_proof_finished = heat_proof //tracks whether there's rglass in
A.setAnchored(TRUE)
A.set_anchored(TRUE)
A.glass = glass
A.state = AIRLOCK_ASSEMBLY_NEEDS_ELECTRONICS
A.created_name = name
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
if("rightsecure")
WA.facing = "r"
WA.secure = TRUE
WA.setAnchored(TRUE)
WA.set_anchored(TRUE)
WA.state= "02"
WA.setDir(dir)
WA.update_icon()
Expand Down
7 changes: 3 additions & 4 deletions code/game/machinery/doppler_array.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/obj/machinery/doppler_array/Initialize(mapload)
. = ..()
RegisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION, PROC_REF(sense_explosion))
RegisterSignal(src, COMSIG_MOVABLE_SET_ANCHORED, PROC_REF(power_change))
printer_ready = world.time + PRINTER_TIMEOUT

/obj/machinery/doppler_array/ComponentInitialize()
Expand Down Expand Up @@ -119,12 +120,10 @@
/obj/machinery/doppler_array/attackby(obj/item/I, mob/user, params)
if(I.tool_behaviour == TOOL_WRENCH)
if(!anchored && !isinspace())
anchored = TRUE
power_change()
set_anchored(TRUE)
to_chat(user, "<span class='notice'>You fasten [src].</span>")
else if(anchored)
anchored = FALSE
power_change()
set_anchored(FALSE)
to_chat(user, "<span class='notice'>You unfasten [src].</span>")
I.play_tool_sound(src)
return
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@
if (!anchored && !isinspace())
to_chat(user, "<span class='notice'>[src] is now secured.</span>")
add_overlay("[base_state]-s")
setAnchored(TRUE)
set_anchored(TRUE)
power_change()
proximity_monitor.SetRange(range)
else
to_chat(user, "<span class='notice'>[src] can now be moved.</span>")
cut_overlays()
setAnchored(FALSE)
set_anchored(FALSE)
power_change()
proximity_monitor.SetRange(0)

Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ Possible to do for anyone motivated enough:

Hologram.mouse_opacity = MOUSE_OPACITY_TRANSPARENT//So you can't click on it.
Hologram.layer = FLY_LAYER//Above all the other objects/mobs. Or the vast majority of them.
Hologram.setAnchored(TRUE)//So space wind cannot drag it.
Hologram.set_anchored(TRUE)//So space wind cannot drag it.
Hologram.name = "[user.name] (Hologram)"//If someone decides to right click.
Hologram.set_light(2) //hologram lighting
move_hologram()
Expand Down Expand Up @@ -559,7 +559,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
holder.selected_language = record.language
Hologram.mouse_opacity = MOUSE_OPACITY_TRANSPARENT//So you can't click on it.
Hologram.layer = FLY_LAYER//Above all the other objects/mobs. Or the vast majority of them.
Hologram.setAnchored(TRUE)//So space wind cannot drag it.
Hologram.set_anchored(TRUE)//So space wind cannot drag it.
Hologram.name = "[record.caller_name] (Hologram)"//If someone decides to right click.
Hologram.set_light(2) //hologram lighting
visible_message("<span class='notice'>A holographic image of [record.caller_name] flickers to life before your eyes!</span>")
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/porta_turret/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@

//This code handles moving the turret around. After all, it's a portable turret!
if(!anchored && !isinspace())
setAnchored(TRUE)
set_anchored(TRUE)
invisibility = INVISIBILITY_MAXIMUM
update_icon()
to_chat(user, "<span class='notice'>You secure the exterior bolts on the turret.</span>")
if(has_cover)
cover = new /obj/machinery/porta_turret_cover(loc) //create a new turret. While this is handled in process(), this is to workaround a bug where the turret becomes invisible for a split second
cover.parent_turret = src //make the cover's parent src
else if(anchored)
setAnchored(FALSE)
set_anchored(FALSE)
to_chat(user, "<span class='notice'>You unsecure the exterior bolts on the turret.</span>")
power_change()
invisibility = 0
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/porta_turret/portable_turret_construct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
desc = "An unfinished covered turret frame."
anchored = FALSE
density = TRUE
use_power = NO_POWER_USE //why would it use power if its not even connected yet
var/build_step = PTURRET_UNSECURED //the current step in the building process
var/finish_name = "turret" //the name applied to the product turret
var/obj/item/gun/installed_gun = null
Expand All @@ -26,7 +27,7 @@
if(I.tool_behaviour == TOOL_WRENCH && !anchored)
I.play_tool_sound(src, 100)
to_chat(user, "<span class='notice'>You secure the external bolts.</span>")
setAnchored(TRUE)
set_anchored(TRUE)
build_step = PTURRET_BOLTED
return

Expand All @@ -51,7 +52,7 @@
else if(I.tool_behaviour == TOOL_WRENCH)
I.play_tool_sound(src, 75)
to_chat(user, "<span class='notice'>You unfasten the external bolts.</span>")
setAnchored(FALSE)
set_anchored(FALSE)
build_step = PTURRET_UNSECURED
return

Expand Down Expand Up @@ -85,7 +86,6 @@
to_chat(user, "<span class='notice'>You add [I] to the turret.</span>")
build_step = PTURRET_GUN_EQUIPPED
return

else if(I.tool_behaviour == TOOL_WRENCH)
I.play_tool_sound(src, 100)
to_chat(user, "<span class='notice'>You remove the turret's metal armor bolts.</span>")
Expand Down
20 changes: 11 additions & 9 deletions code/game/machinery/porta_turret/portable_turret_cover.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,36 @@
if(I.tool_behaviour == TOOL_WRENCH && !parent_turret.on)
if(parent_turret.raised)
return

if(!parent_turret.anchored)
parent_turret.setAnchored(TRUE)
parent_turret.set_anchored(TRUE)
to_chat(user, "<span class='notice'>You secure the exterior bolts on the turret.</span>")
parent_turret.invisibility = 0
parent_turret.update_icon()
parent_turret.update_appearance()
else
parent_turret.setAnchored(FALSE)
parent_turret.set_anchored(FALSE)
to_chat(user, "<span class='notice'>You unsecure the exterior bolts on the turret.</span>")
parent_turret.invisibility = INVISIBILITY_MAXIMUM
parent_turret.update_icon()
parent_turret.update_appearance()
qdel(src)
return

else if(I.GetID())
if(I.GetID())
if(parent_turret.allowed(user))
parent_turret.locked = !parent_turret.locked
to_chat(user, "<span class='notice'>Controls are now [parent_turret.locked ? "locked" : "unlocked"].</span>")
updateUsrDialog()
else
to_chat(user, "<span class='notice'>Access denied.</span>")
else if(I.tool_behaviour == TOOL_MULTITOOL && !parent_turret.locked)
return

if(I.tool_behaviour == TOOL_MULTITOOL && !parent_turret.locked)
if(!multitool_check_buffer(user, I))
return
var/obj/item/multitool/M = I
M.buffer = parent_turret
to_chat(user, "<span class='notice'>You add [parent_turret] to multitool buffer.</span>")
else
return ..()
return
return ..()

/obj/machinery/porta_turret_cover/attacked_by(obj/item/I, mob/user)
parent_turret.attacked_by(I, user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/recharger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
if(charging)
to_chat(user, "<span class='notice'>Remove the charging item first!</span>")
return
setAnchored(!anchored)
set_anchored(!anchored)
power_change()
to_chat(user, "<span class='notice'>You [anchored ? "attached" : "detached"] [src].</span>")
G.play_tool_sound(src)
Expand Down
Loading