Skip to content

Commit

Permalink
Anchor Variable Setter
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottfrei committed Apr 10, 2024
1 parent c6a086a commit e184e46
Show file tree
Hide file tree
Showing 97 changed files with 229 additions and 217 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@
/* #define HEARING_RADIO_FREQ 5
#define HEARING_SPANS 6
#define HEARING_MESSAGE_MODE 7 */
///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"

///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"
Expand Down
1 change: 0 additions & 1 deletion code/__HELPERS/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
/atom/var/bottom_left_corner
/atom/var/bottom_right_corner
/atom/var/list/canSmoothWith = null // TYPE PATHS I CAN SMOOTH WITH~~~~~ If this is null and atom is smooth, it smooths only with itself
/atom/movable/var/can_be_unanchored = FALSE
/turf/var/list/fixed_underlay = null

/proc/calculate_adjacencies(atom/A)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ Returns 1 if the chain up to the area contains the given typepath
var/obj/corner = new()
corner.loc = X
corner.density = 1
corner.anchored = TRUE
corner.set_anchored(TRUE)
corner.icon = X.icon
corner.icon_state = replacetext(X.icon_state, "_s", "_f")
corner.tag = "delete me"
Expand Down
3 changes: 2 additions & 1 deletion code/datums/components/ducttape.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
y_offset = y
RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, PROC_REF(afterattack))
RegisterSignal(parent, COMSIG_ITEM_PICKUP, PROC_REF(pick_up))
I.set_anchored(TRUE)
I.update_icon() //Do this first so the action button properly shows the icon
if(!hide_tape) //the tape can no longer be removed if TRUE
var/datum/action/item_action/remove_tape/RT = new(I)
Expand All @@ -38,7 +39,7 @@
playsound(I, 'sound/items/poster_ripped.ogg', 50, 1)
new /obj/item/trash/tapetrash(user.loc)
I.update_icon()
I.anchored = initial(I.anchored)
I.set_anchored(initial(I.anchored))
for(var/datum/action/item_action/remove_tape/RT in I.actions)
RT.Remove(user)
qdel(RT)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell))
var/obj/effect/overlay/spell = new /obj/effect/overlay(location)
spell.icon = overlay_icon
spell.icon_state = overlay_icon_state
spell.anchored = TRUE
spell.set_anchored(TRUE)
spell.density = FALSE
spawn(overlay_lifespan)
qdel(spell)
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 @@ -72,7 +72,7 @@
if(!mend && B.anchored)
holder.visible_message("<span class='notice'>[bicon(B)] 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_BOMB_PROCEED)
if(!mend && B.active)
holder.visible_message("<span class='danger'>[bicon(B)] An alarm sounds! It's go-</span>")
Expand Down
15 changes: 15 additions & 0 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
var/inertia_next_move = 0
var/inertia_move_delay = 5

///Used for the calculate_adjacencies proc for icon smoothing.
var/can_be_unanchored = FALSE

/**
* In case you have multiple types, you automatically use the most useful one.
* IE: Skating on ice, flippers on water, flying over chasm/space, etc.
Expand Down Expand Up @@ -864,3 +867,15 @@
SHOULD_BE_PURE(TRUE)
return blocker_opinion


///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
if(anchored && pulledby)
pulledby.stop_pulling()
SEND_SIGNAL(src, COMSIG_MOVABLE_SET_ANCHORED, anchorvalue)

6 changes: 3 additions & 3 deletions code/game/gamemodes/clockwork/clockwork_structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
to_chat(usr, "<span class='warning'>There is a structure here!</span>")
return TRUE
add_fingerprint(user)
anchored = !anchored
set_anchored(!anchored)
to_chat(user, "<span class='notice'>You [anchored ? "":"un"]secure [src] [anchored ? "to":"from"] the floor.</span>")
update_icon(UPDATE_ICON_STATE)
return TRUE
Expand Down Expand Up @@ -354,7 +354,7 @@
if(locate(/obj/structure/falsewall) in loc)
to_chat(usr, "<span class='warning'>There is a structure here!</span>")
return TRUE
anchored = !anchored
set_anchored(!anchored)
update_icon(UPDATE_ICON_STATE)
to_chat(user, "<span class='notice'>You [anchored ? "":"un"]secure [src] [anchored ? "to":"from"] the floor.</span>")
if(!anchored)
Expand Down Expand Up @@ -543,7 +543,7 @@
to_chat(usr, "<span class='warning'>There is a structure here!</span>")
return TRUE
add_fingerprint(user)
anchored = !anchored
set_anchored(!anchored)
update_icon(UPDATE_ICON_STATE)
to_chat(user, "<span class='notice'>You [anchored ? "":"un"]secure [src] [anchored ? "to":"from"] the floor.</span>")
if(!anchored)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/cult/cult_structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
/obj/structure/cult/functional/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/melee/cultblade/dagger) && iscultist(user))
add_fingerprint(user)
anchored = !anchored
set_anchored(!anchored)
update_icon(UPDATE_ICON_STATE)
to_chat(user, "<span class='notice'>You [anchored ? "":"un"]secure [src] [anchored ? "to":"from"] the floor.</span>")
return
Expand Down
8 changes: 4 additions & 4 deletions code/game/gamemodes/nuclear/nuclearbomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ GLOBAL_VAR(bomb_set)
if(!I.use_tool(src, user, 80, volume = I.tool_volume) || removal_stage != NUKE_UNWRENCHED)
return
user.visible_message("[user] crowbars [src] off of the anchors. It can now be moved.", "You jam the crowbar under the nuclear device and lift it off its anchors. You can now move it!")
anchored = FALSE
set_anchored(FALSE)
removal_stage = NUKE_MOBILE

/obj/machinery/nuclearbomb/wrench_act(mob/user, obj/item/I)
Expand Down Expand Up @@ -384,7 +384,7 @@ GLOBAL_VAR(bomb_set)
switch(action)
if("deploy")
if(removal_stage != NUKE_MOBILE)
anchored = TRUE
set_anchored(TRUE)
visible_message("<span class='warning'>With a steely snap, bolts slide out of [src] and anchor it to the flooring!</span>")
else
visible_message("<span class='warning'>[src] makes a highly unpleasant crunching noise. It looks like the anchoring bolts have been cut.</span>")
Expand Down Expand Up @@ -432,13 +432,13 @@ GLOBAL_VAR(bomb_set)
switch(action)
if("toggle_anchor")
if(removal_stage == NUKE_MOBILE)
anchored = FALSE
set_anchored(FALSE)
visible_message("<span class='warning'>[src] makes a highly unpleasant crunching noise. It looks like the anchoring bolts have been cut.</span>")
else if(isinspace())
to_chat(usr, "<span class='warning'>There is nothing to anchor to!</span>")
return FALSE
else
anchored = !(anchored)
set_anchored(!anchored)
if(anchored)
visible_message("<span class='warning'>With a steely snap, bolts slide out of [src] and anchor it to the flooring.</span>")
else
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
wires = new(src)
assembly = new(src)
assembly.state = 4
assembly.anchored = TRUE
assembly.set_anchored(TRUE)
assembly.update_icon(UPDATE_ICON_STATE)

GLOB.cameranet.cameras += src
Expand Down Expand Up @@ -425,7 +425,7 @@
/obj/machinery/camera/portable/Initialize(mapload)
. = ..()
assembly.state = 0 //These cameras are portable, and so shall be in the portable state if removed.
assembly.anchored = FALSE
assembly.set_anchored(FALSE)
assembly.update_icon(UPDATE_ICON_STATE)

/obj/machinery/camera/portable/process() //Updates whenever the camera is moved.
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 @@ -117,13 +117,13 @@
return
if(state == ASSEMBLY_UNBUILT && isturf(loc))
WRENCH_ANCHOR_TO_WALL_MESSAGE
anchored = TRUE
set_anchored(TRUE)
state = ASSEMBLY_WRENCHED
update_icon(UPDATE_ICON_STATE)
auto_turn()
else if(state == ASSEMBLY_WRENCHED)
WRENCH_UNANCHOR_WALL_MESSAGE
anchored = FALSE
set_anchored(FALSE)
update_icon(UPDATE_ICON_STATE)
state = ASSEMBLY_UNBUILT
else
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/cell_charger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
set_anchored(!anchored)
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,14 @@ GLOBAL_LIST_INIT(cloner_biomass_items, list(\
if(occupant)
to_chat(user, span_warning("Can not do that while [src] is in use."))
return
set_anchored(!anchored)
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
WRENCH_UNANCHOR_MESSAGE
anchored = FALSE
connected.pods -= src
connected = null
else
WRENCH_ANCHOR_MESSAGE
anchored = TRUE


/obj/machinery/clonepod/emag_act(mob/user)
if(isnull(occupant))
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 @@ -595,10 +595,10 @@

if(anchored)
to_chat(user, span_notice("You unfasten the frame."))
anchored = FALSE
set_anchored(FALSE)
else
to_chat(user, span_notice("You wrench the frame into place."))
anchored = TRUE
set_anchored(TRUE)

/obj/structure/computerframe/crowbar_act(mob/living/user, obj/item/I)
. = TRUE
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 @@ -153,7 +153,7 @@
A.name += " ([M.board_name])"
A.setDir(dir)
A.circuit = M
A.anchored = TRUE
A.set_anchored(TRUE)
if(stat & BROKEN)
if(user)
to_chat(user, span_notice("The broken glass falls out."))
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/constructable_frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@
return .

if(anchored)
anchored = FALSE
set_anchored(FALSE)
WRENCH_UNANCHOR_MESSAGE
return .

if(isinspace())
to_chat(user, span_warning("You cannot tightens the bolts in space!"))
return .

anchored = TRUE
set_anchored(TRUE)
WRENCH_ANCHOR_MESSAGE


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 @@ -64,10 +64,10 @@
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(!anchored && !isinspace())
anchored = TRUE
set_anchored(TRUE)
WRENCH_ANCHOR_MESSAGE
else if(anchored)
anchored = FALSE
set_anchored(FALSE)
WRENCH_UNANCHOR_MESSAGE
playsound(src, 'sound/items/deconstruct.ogg', 50, 1)

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
/obj/structure/barricade/security/proc/deploy()
icon_state = "barrier1"
density = TRUE
anchored = TRUE
set_anchored(TRUE)
if(deploy_message)
visible_message(span_warning("[src] deploys!"))

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 @@ -1515,7 +1515,7 @@ About the new airlock wires panel:
DA = new /obj/structure/door_assembly(loc)
//If you come across a null assemblytype, it will produce the default assembly instead of disintegrating.
DA.heat_proof_finished = heat_proof //tracks whether there's rglass in
DA.anchored = TRUE
DA.set_anchored(TRUE)
DA.glass = src.glass
DA.state = AIRLOCK_ASSEMBLY_NEEDS_ELECTRONICS
DA.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 @@ -325,7 +325,7 @@
if("rightsecure")
WA.facing = "r"
WA.secure = TRUE
WA.anchored = TRUE
WA.set_anchored(TRUE)
WA.state= "02"
WA.setDir(dir)
WA.ini_dir = dir
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
set_anchored(!anchored)
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ GLOBAL_LIST_EMPTY(holopads)

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.anchored = 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
2 changes: 1 addition & 1 deletion code/game/machinery/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Class Procs:
/obj/machinery/proc/spawn_frame(disassembled)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(loc)
. = M
M.anchored = anchored
M.set_anchored(anchored)
if(!disassembled)
M.obj_integrity = M.max_integrity * 0.5 //the frame is already half broken
transfer_fingerprints_to(M)
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/mass_driver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if(do_after(user, 30 * I.toolspeed * gettoolspeedmod(user), target = src))
var/obj/machinery/mass_driver_frame/F = new(get_turf(src))
F.dir = dir
F.anchored = TRUE
F.set_anchored(TRUE)
F.build = 4
F.update_icon()
qdel(src)
Expand Down Expand Up @@ -101,7 +101,7 @@
if(do_after(user, 10 * W.toolspeed * gettoolspeedmod(user), target = src) && (build == 0))
add_fingerprint(user)
to_chat(user, span_notice("You anchor \the [src]!"))
anchored = TRUE
set_anchored(TRUE)
build++
return 1
return
Expand All @@ -112,7 +112,7 @@
if(do_after(user, 10 * W.toolspeed * gettoolspeedmod(user), target = src) && (build == 1))
add_fingerprint(user)
build--
anchored = FALSE
set_anchored(FALSE)
to_chat(user, span_notice("You de-anchored \the [src]!"))
return 1
if(2) // Welded to the floor
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/pipe/pipe_dispenser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"[user] unfastens \the [src].", \
span_notice("You have unfastened \the [src]. Now it can be pulled somewhere else."), \
"You hear ratchet.")
anchored = FALSE
set_anchored(FALSE)
stat |= MAINT
unwrenched = 1
if(usr.machine==src)
Expand All @@ -124,7 +124,7 @@
"[user] fastens \the [src].", \
span_notice("You have fastened \the [src]. Now it can dispense pipes."), \
"You hear ratchet.")
anchored = TRUE
set_anchored(TRUE)
stat &= ~MAINT
unwrenched = 0
power_change()
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
//This code handles moving the turret around. After all, it's a portable turret!
add_fingerprint(user)
playsound(loc, I.usesound, 100, TRUE)
anchored = !anchored
set_anchored(!anchored)
update_icon(UPDATE_ICON_STATE)
to_chat(user, "<span class='notice'>You [anchored ? "" : "un"]secure the exterior bolts on the turret.</span>")
wrenching = FALSE
Expand Down Expand Up @@ -804,7 +804,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
add_fingerprint(user)
playsound(loc, I.usesound, 100, 1)
to_chat(user, span_notice("You secure the external bolts."))
anchored = TRUE
set_anchored(TRUE)
build_step = 1
return

Expand All @@ -831,7 +831,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
add_fingerprint(user)
playsound(loc, I.usesound, 75, 1)
to_chat(user, span_notice("You unfasten the external bolts."))
anchored = FALSE
set_anchored(FALSE)
build_step = 0
return

Expand Down
Loading

0 comments on commit e184e46

Please sign in to comment.