Files
Paradise/code/modules/assembly/assembly_holder.dm
warriorstar-orion 79bad427c8 Movement cross/uncross implementation. (#26762)
* refactor: Movement cross/uncross implementation.

* wrong var name

* fix unit tests dropping PDAs into nowhere

* Add documentation.

* remove unused constants

* say which procs are off limits

* fix simpleanimal z change runtime

* helps not to leave merge conflicts

* kill me

* fix typecast

* fix projectile/table collision

* treadmills don't cause MC to crash anymore

* connect_loc is appropriate here

* fix windoors and teleporters

* fix bonfires and clarify docs

* fix proximity sensors

Tested with sensors in crates, sensors in modsuits
Tested new proximity component with firing projectiles at singularity
Tested new proximity component with portable flashes
Tested new proximity component with facehuggers

* lint

* fix: polarized access helper false positives

* Revert "fix: polarized access helper false positives"

This reverts commit 9814f98cf6.

* hopefully the right change for mindflayer steam

* Changes following cameras

* fix glass table collision

* appears to fix doorspam

* fix ore bags not picking up ore

* fix signatures of /Exited

* remove debug log

* remove duplicate signal registrar

* fix emptying bags into locations

* I don't trust these nested Move calls

* use connect_loc for upgraded resonator fields

* use moveToNullspace

* fix spiderweb crossing

* fix pass checking for windows from a tile off

* fix bluespace closet/transparency issues

* fix mechs not interacting with doors and probably other things

* fix debug

* fix telepete

* add some docs

* stop trying to shoehorn prox monitor into cards

* I should make sure things build

* kill override signal warning

* undef signal

* not many prox monitors survive going off like this

* small fixes to storage

* make moving wormholes respect signals

* use correct signals for pulse demon

* fix pulse heart too

* fix smoke signals

* may have fucked singulo projectile swerve

* fix singulo projectile arcing

* remove duplicate define

* just look at it

* hopefully last cleanups of incorrect signal usage

* fix squeaking

* may god have mercy on my soul

* Apply suggestions from code review

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* lewc review

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* burza review

* fix bad args for grenade assemblies

* Update code/__DEFINES/is_helpers.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

---------

Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: DGamerL <daan.lyklema@gmail.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
2024-12-21 08:07:44 +00:00

196 lines
4.9 KiB
Plaintext

/obj/item/assembly_holder
name = "Assembly"
icon = 'icons/obj/assemblies/new_assemblies.dmi'
icon_state = "holder"
item_state = "assembly"
flags = CONDUCT
throwforce = 5
w_class = WEIGHT_CLASS_SMALL
throw_speed = 3
throw_range = 10
var/secured = FALSE
var/obj/item/assembly/a_left = null
var/obj/item/assembly/a_right = null
/obj/item/assembly_holder/IsAssemblyHolder()
return TRUE
/obj/item/assembly_holder/Destroy()
if(a_left)
a_left.holder = null
if(a_right)
a_right.holder = null
return ..()
/obj/item/assembly_holder/proc/attach(obj/item/D, obj/item/D2, mob/user)
if(!D || !D2)
return FALSE
if(!isassembly(D) || !isassembly(D2))
return FALSE
var/obj/item/assembly/A1 = D
var/obj/item/assembly/A2 = D2
if(A1.secured || A2.secured)
return FALSE
if(!A1.remove_item_from_storage(src))
if(user)
user.remove_from_mob(A1)
A1.forceMove(src)
if(!A2.remove_item_from_storage(src))
if(user)
user.remove_from_mob(A2)
A2.forceMove(src)
A1.holder = src
A2.holder = src
a_left = A1
a_right = A2
name = "[A1.name]-[A2.name] assembly"
update_icon(UPDATE_OVERLAYS)
A1.on_attach()
A2.on_attach()
return TRUE
/obj/item/assembly_holder/update_overlays()
. = ..()
if(a_left)
. += "[a_left.icon_state]_left"
for(var/O in a_left.attached_overlays)
. += "[O]_l"
if(a_right)
. += "[a_right.icon_state]_right"
for(var/O in a_right.attached_overlays)
. += "[O]_r"
if(master)
master.update_icon()
/obj/item/assembly_holder/examine(mob/user)
. = ..()
if(in_range(src, user) || loc == user)
if(secured)
. += "[src] is ready!"
else
. += "[src] can be attached!"
/obj/item/assembly_holder/HasProximity(atom/movable/AM)
if(a_left)
a_left.HasProximity(AM)
if(a_right)
a_right.HasProximity(AM)
// TODO: All these assemblies passing the crossed args around needs to be cleaned up with signals
/obj/item/assembly_holder/proc/on_atom_entered(datum/source, atom/movable/entered)
if(a_left)
a_left.on_atom_entered(source, entered)
if(a_right)
a_right.on_atom_entered(source, entered)
/obj/item/assembly_holder/on_found(mob/finder)
if(a_left)
a_left.on_found(finder)
if(a_right)
a_right.on_found(finder)
/obj/item/assembly_holder/hear_talk(mob/living/M, list/message_pieces)
if(a_left)
a_left.hear_talk(M, message_pieces)
if(a_right)
a_right.hear_talk(M, message_pieces)
/obj/item/assembly_holder/hear_message(mob/living/M, msg)
if(a_left)
a_left.hear_message(M, msg)
if(a_right)
a_right.hear_message(M, msg)
/obj/item/assembly_holder/proc/process_movement() // infrared beams and prox sensors
if(a_left && a_right)
a_left.holder_movement()
a_right.holder_movement()
/obj/item/assembly_holder/Move()
. = ..()
process_movement()
return
/obj/item/assembly_holder/pickup()
. = ..()
process_movement()
/obj/item/assembly_holder/Bump()
..()
process_movement()
/obj/item/assembly_holder/throw_impact() // called when a throw stops
..()
process_movement()
/obj/item/assembly_holder/attack_hand()//Perhapse this should be a holder_pickup proc instead, can add if needbe I guess
if(a_left && a_right)
a_left.holder_movement()
a_right.holder_movement()
..()
return
/obj/item/assembly_holder/screwdriver_act(mob/user, obj/item/I)
if(!a_left || !a_right)
to_chat(user, "<span class='warning'>BUG:Assembly part missing, please report this!</span>")
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
a_left.toggle_secure()
a_right.toggle_secure()
secured = !secured
if(secured)
to_chat(user, "<span class='notice'>[src] is ready!</span>")
else
to_chat(user, "<span class='notice'>[src] can now be taken apart!</span>")
update_icon()
/obj/item/assembly_holder/attack_self__legacy__attackchain(mob/user)
add_fingerprint(user)
if(secured)
if(!a_left || !a_right)
to_chat(user, "<span class='warning'>Assembly part missing!</span>")
return
if(istype(a_left, a_right.type)) // If they are the same type it causes issues due to window code
switch(tgui_alert(user, "Which side would you like to use?", "Choose", list("Left", "Right")))
if("Left")
a_left.attack_self__legacy__attackchain(user)
if("Right")
a_right.attack_self__legacy__attackchain(user)
return
else
a_left.attack_self__legacy__attackchain(user)
a_right.attack_self__legacy__attackchain(user)
else
var/turf/T = get_turf(src)
if(!T)
return FALSE
user.unEquip(src, TRUE, TRUE)
if(a_left)
a_left.holder = null
a_left.forceMove(T)
user.put_in_active_hand(a_left)
if(a_right) // Right object is the secondary item, hence put in inactive hand
a_right.holder = null
a_right.forceMove(T)
user.put_in_inactive_hand(a_right)
qdel(src)
/obj/item/assembly_holder/proc/process_activation(obj/D, normal = TRUE, special = TRUE)
if(!D)
return FALSE
if(normal && a_right && a_left)
if(a_right != D)
a_right.pulsed(0)
if(a_left && a_left != D) // the right pools might have sent us boom, so `a_left` can be null here
a_left.pulsed(0)
return TRUE