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
5 changes: 4 additions & 1 deletion code/__DEFINES/dcs/signals/signals_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@
#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 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"

///from base of atom/movable/setGrabState(): (newstate)
#define COMSIG_MOVABLE_SET_GRAB_STATE "living_set_grab_state"

// 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
9 changes: 7 additions & 2 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,20 @@ 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)))

/// 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 @@ -55,7 +55,7 @@
if(use_alpha)
source.alpha = ALPHA_UNDERTILE
if(use_anchor)
source.anchored = TRUE
source.set_anchored(TRUE)

else
if(invisibility_trait)
Expand All @@ -65,7 +65,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
21 changes: 18 additions & 3 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/atom/movable
layer = OBJ_LAYER
glide_size = 8
appearance_flags = TILE_BOUND|PIXEL_SCALE

var/move_stacks = 0 //how many times a this movable had movement procs called on it since Moved() was last called
var/last_move = null
var/last_move_time = 0
Expand All @@ -13,6 +16,7 @@
var/mob/pulledby = null
var/initial_language_holder = /datum/language_holder
var/datum/language_holder/language_holder // Mindless mobs and objects need language too, some times. Mind holder takes prescedence.

var/verb_say = "says"
var/verb_ask = "asks"
var/verb_exclaim = "exclaims"
Expand All @@ -33,8 +37,6 @@
///Holds information about any movement loops currently running/waiting to run on the movable. Lazy, will be null if nothing's going on
var/datum/movement_packet/move_packet
var/list/acted_explosions //for explosion dodging
glide_size = 8
appearance_flags = TILE_BOUND|PIXEL_SCALE
var/datum/forced_movement/force_moving = null //handled soley by forced_movement.dm
var/movement_type = GROUND //Incase you have multiple types, you automatically use the most useful one. IE: Skating on ice, flippers on water, flying over chasm/space, etc.
var/atom/movable/pulling
Expand Down Expand Up @@ -115,7 +117,11 @@
return FALSE //PLEASE no.
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 @@ -577,6 +583,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 Expand Up @@ -696,7 +711,7 @@

if (pulledby)
pulledby.stop_pulling()


//They are moving! Wouldn't it be cool if we calculated their momentum and added it to the throw?
if (thrower && thrower.last_move && thrower.client && thrower.client.move_delay >= world.time + world.tick_lag*2)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ Class Procs:

new_frame.icon_state = "box_1"
. = new_frame
new_frame.anchored = TRUE
new_frame.set_anchored(TRUE)
if(!disassembled)
new_frame.obj_integrity = new_frame.max_integrity * 0.5 //the frame is already half broken
transfer_fingerprints_to(new_frame)
Expand Down Expand Up @@ -639,7 +639,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 @@ -147,7 +147,7 @@
A.circuit = circuit
// Circuit removal code is handled in /obj/machinery/Exited()
circuit.forceMove(A)
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
6 changes: 3 additions & 3 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 Expand Up @@ -133,7 +133,7 @@

// Set anchor state and move the frame's parts over to the new machine.
// Then refresh parts and call on_construction().
new_computer.anchored = anchored
new_computer.set_anchored(anchored)
new_computer.component_parts = list()

circuit.forceMove(new_computer)
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 @@ -195,7 +195,7 @@
// Set anchor state and move the frame's parts over to the new machine.
// Then refresh parts and call on_construction().

new_machine.anchored = anchored
new_machine.set_anchored(anchored)
new_machine.component_parts = list()

circuit.forceMove(new_machine)
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 @@ -297,7 +297,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 @@ -184,13 +184,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 @@ -562,7 +562,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 @@ -307,15 +307,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
Loading
Loading