Fixes mech equipment being unusable for AIs (#55248)

Adds a signal listener on mechs that listens for middle clicks, and calls a proc that will, in turn, call the normal click proc if the user is an AI.

Middle clicks now pass through params just like left clicks.
This commit is contained in:
zxaber
2020-12-27 19:03:10 -08:00
committed by GitHub
parent 011fa80eb7
commit 1b971c2d80
3 changed files with 15 additions and 7 deletions
+6 -1
View File
@@ -521,7 +521,7 @@
if(is_currently_ejecting)
return
var/list/mouse_control = params2list(params)
if(isAI(user) && !mouse_control["middle"])//AIs use MMB
if(isAI(user) == !mouse_control["middle"])//BASICALLY if a human uses MMB, or an AI doesn't, then do nothing.
return
if(phasing)
to_chat(occupants, "[icon2html(src, occupants)]<span class='warning'>Unable to interact with objects while phasing.</span>")
@@ -566,6 +566,9 @@
target.mech_melee_attack(src, user)
TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MELEE_ATTACK, melee_cooldown)
/obj/vehicle/sealed/mecha/proc/on_middlemouseclick(mob/user, atom/target, params)
if(isAI(user))
on_mouseclick(user, target, params)
//////////////////////////////////
//////// Movement procs ////////
@@ -1086,6 +1089,7 @@
/obj/vehicle/sealed/mecha/add_occupant(mob/M, control_flags)
RegisterSignal(M, COMSIG_LIVING_DEATH, .proc/mob_exit)
RegisterSignal(M, COMSIG_MOB_CLICKON, .proc/on_mouseclick)
RegisterSignal(M, COMSIG_MOB_MIDDLECLICKON, .proc/on_middlemouseclick) //For AIs
RegisterSignal(M, COMSIG_MOB_SAY, .proc/display_speech_bubble)
. = ..()
update_icon()
@@ -1093,6 +1097,7 @@
/obj/vehicle/sealed/mecha/remove_occupant(mob/M)
UnregisterSignal(M, COMSIG_LIVING_DEATH)
UnregisterSignal(M, COMSIG_MOB_CLICKON)
UnregisterSignal(M, COMSIG_MOB_MIDDLECLICKON)
UnregisterSignal(M, COMSIG_MOB_SAY)
M.clear_alert("charge")
M.clear_alert("mech damage")