Skip to content

Commit

Permalink
on_*_interaction() procs reordering
Browse files Browse the repository at this point in the history
Nothing should have been removed or added (other than combining the `UnregisterSignal()`s). This is just to make them a bit neater.
  • Loading branch information
SabreML committed Dec 29, 2023
1 parent 4a31b8a commit fc49338
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions code/modules/cm_marines/smartgun_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -858,45 +858,53 @@
user.set_interaction(src)

/obj/structure/machinery/m56d_hmg/on_set_interaction(mob/user)
RegisterSignal(user, list(COMSIG_MOB_MG_EXIT, COMSIG_MOB_RESISTED, COMSIG_MOB_DEATH, COMSIG_LIVING_SET_BODY_POSITION), PROC_REF(exit_interaction))
flags_atom |= RELAY_CLICK
user.status_flags |= IMMOBILE_ACTION
user.visible_message(SPAN_NOTICE("[user] mans \the [src]."),SPAN_NOTICE("You man \the [src], locked and loaded!"))
RegisterSignal(user, COMSIG_MOB_MOUSEDOWN, PROC_REF(start_fire))
RegisterSignal(user, COMSIG_MOB_MOUSEDRAG, PROC_REF(change_target))
RegisterSignal(user, COMSIG_MOB_MOUSEUP, PROC_REF(stop_fire))
ADD_TRAIT(user, TRAIT_IMMOBILIZED, INTERACTION_TRAIT)
give_action(user, /datum/action/human_action/mg_exit)
user.forceMove(src.loc)
user.setDir(dir)
user.reset_view(src)
user.status_flags |= IMMOBILE_ACTION
user.visible_message(SPAN_NOTICE("[user] mans [src]."), SPAN_NOTICE("You man [src], locked and loaded!"))
user_old_x = user.pixel_x
user_old_y = user.pixel_y
user.reset_view(src)
update_pixels(user)

RegisterSignal(user, list(COMSIG_MOB_MG_EXIT, COMSIG_MOB_RESISTED, COMSIG_MOB_DEATH, COMSIG_LIVING_SET_BODY_POSITION), PROC_REF(exit_interaction))
RegisterSignal(user, COMSIG_MOB_MOUSEDOWN, PROC_REF(start_fire))
RegisterSignal(user, COMSIG_MOB_MOUSEDRAG, PROC_REF(change_target))
RegisterSignal(user, COMSIG_MOB_MOUSEUP, PROC_REF(stop_fire))

operator = user
flags_atom |= RELAY_CLICK

/obj/structure/machinery/m56d_hmg/on_unset_interaction(mob/living/user)
flags_atom &= ~RELAY_CLICK
SEND_SIGNAL(src, COMSIG_GUN_INTERRUPT_FIRE)
user.status_flags &= ~IMMOBILE_ACTION
user.visible_message(SPAN_NOTICE("[user] lets go of \the [src]."),SPAN_NOTICE("You let go of \the [src], letting the gun rest."))
/obj/structure/machinery/m56d_hmg/on_unset_interaction(mob/user)
REMOVE_TRAIT(user, TRAIT_IMMOBILIZED, INTERACTION_TRAIT)
UnregisterSignal(user, list(COMSIG_MOB_MOUSEUP, COMSIG_MOB_MOUSEDOWN, COMSIG_MOB_MOUSEDRAG))
user.reset_view(null)
user.remove_temp_pass_flags(PASS_MOB_THRU) // this is necessary because being knocked over while using the gun makes you incorporeal
remove_action(user, /datum/action/human_action/mg_exit)
user.Move(get_step(src, reverse_direction(src.dir)))
user.setDir(dir) //set the direction of the player to the direction the gun is facing
user.reset_view(null)
user.status_flags &= ~IMMOBILE_ACTION
user.visible_message(SPAN_NOTICE("[user] lets go of [src]."), SPAN_NOTICE("You let go of [src], letting the gun rest."))
user_old_x = 0 //reset our x
user_old_y = 0 //reset our y
update_pixels(user, FALSE)
if(operator == user) //We have no operator now
operator = null
remove_action(user, /datum/action/human_action/mg_exit)
user.remove_temp_pass_flags(PASS_MOB_THRU) // this is necessary because being knocked over while using the gun makes you incorporeal

SEND_SIGNAL(src, COMSIG_GUN_INTERRUPT_FIRE)
UnregisterSignal(user, list(
COMSIG_MOB_MG_EXIT,
COMSIG_MOB_RESISTED,
COMSIG_MOB_DEATH,
COMSIG_LIVING_SET_BODY_POSITION,
COMSIG_MOB_MOUSEUP,
COMSIG_MOB_MOUSEDOWN,
COMSIG_MOB_MOUSEDRAG,
))

if(operator == user) //We have no operator now
operator = null
flags_atom &= ~RELAY_CLICK


/obj/structure/machinery/m56d_hmg/proc/update_pixels(mob/user, mounting = TRUE)
if(mounting)
Expand Down

0 comments on commit fc49338

Please sign in to comment.