Skip to content

refactor: AutoObserve #6787

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

Open
wants to merge 15 commits into
base: master220
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai

/// A trait gained by leaning against a wall
#define TRAIT_LEANING "leaning"

/// used for dead mobs that are observing, but should not be afforded all the same platitudes as full ghosts.
/// This is a mind trait because ghosts can be frequently deleted and we want to be sure this sticks.
#define TRAIT_OBSERVING_INVENTORY "observe_inventory"
29 changes: 8 additions & 21 deletions code/_onclick/hud/action_button.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var/datum/keybinding/mob/trigger_action_button/linked_keybind

/atom/movable/screen/movable/action_button/MouseDrop(atom/over_object, src_location, over_location, src_control, over_control, params)
if(!observer_check(usr))
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

if(locked && could_be_click_lag()) // in case something bad happend and game realised we dragged our ability instead of pressing it
Expand Down Expand Up @@ -37,7 +37,7 @@


/atom/movable/screen/movable/action_button/Click(location,control,params)
if(!observer_check(usr))
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

var/list/modifiers = params2list(params)
Expand Down Expand Up @@ -73,7 +73,7 @@
return TRUE

/atom/movable/screen/movable/action_button/proc/set_to_keybind(mob/user)
if(!observer_check(usr))
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

var/keybind_to_set_to = tgui_input_keycombo(user, "What keybind do you want to set this action button to?")
Expand All @@ -94,7 +94,7 @@


/atom/movable/screen/movable/action_button/click_alt(mob/user)
if(!observer_check(usr))
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

linked_action.AltTrigger()
Expand All @@ -103,7 +103,7 @@

/atom/movable/screen/movable/action_button/proc/clean_up_keybinds(mob/owner)
if(linked_keybind)
if(!observer_check(usr))
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

owner.client.active_keybindings[linked_keybind.binded_to] -= (linked_keybind)
Expand Down Expand Up @@ -133,10 +133,8 @@


/atom/movable/screen/movable/action_button/hide_toggle/Click(location,control,params)
if(isobserver(usr))
var/mob/dead/observer/dead_mob = usr
if(dead_mob.orbiting)
return FALSE
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

if(usr.next_click > world.time)
return FALSE
Expand All @@ -158,7 +156,7 @@


/atom/movable/screen/movable/action_button/hide_toggle/click_alt(mob/user)
if(!observer_check(usr))
if(HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return

for(var/datum/action/action as anything in user.actions)
Expand Down Expand Up @@ -197,9 +195,6 @@


/atom/movable/screen/movable/action_button/MouseEntered(location, control, params)
if(!observer_check(usr))
return

if(!QDELETED(src))
if(!linked_keybind)
openToolTip(usr, src, params, title = name, content = desc, theme = actiontooltipstyle)
Expand All @@ -214,14 +209,6 @@
/atom/movable/screen/movable/action_button/MouseExited()
closeToolTip(usr)

// We don't want give permit to use buttons
/atom/movable/screen/movable/action_button/proc/observer_check(mob/user)
if(isobserver(user))
var/mob/dead/observer/dead_mob = user
if(linked_action?.owner != user || dead_mob.orbiting)
return FALSE
return TRUE

/mob/proc/update_action_buttons_icon()
for(var/datum/action/action as anything in actions)
action.UpdateButtonIcon()
Expand Down
44 changes: 37 additions & 7 deletions code/_onclick/hud/alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
if(client && hud_used)
hud_used.reorganize_alerts()
client.screen -= alert

for(var/mob/dead/observer/observe in inventory_observers)
if(!observe.client)
LAZYREMOVE(inventory_observers, observe)
continue
observe.client.screen -= alert
qdel(alert)

/atom/movable/screen/alert
Expand Down Expand Up @@ -329,6 +335,8 @@ or something covering your eyes."
icon_state = "embeddedobject"

/atom/movable/screen/alert/embeddedobject/Click()
if(!..())
return
if(isliving(usr))
var/mob/living/carbon/human/M = usr
return M.help_shake_act(M)
Expand Down Expand Up @@ -373,6 +381,9 @@ or shoot a gun to move around via Newton's 3rd Law of Motion."


/atom/movable/screen/alert/fire/Click()
if(!..())
return

if(!isliving(usr))
return FALSE

Expand All @@ -394,6 +405,9 @@ or shoot a gun to move around via Newton's 3rd Law of Motion."
icon_state = "direction_lock"

/atom/movable/screen/alert/direction_lock/Click()
if(!..())
return

if(isliving(usr))
var/mob/living/L = usr
return L.clear_forced_look()
Expand Down Expand Up @@ -452,7 +466,7 @@ Recharging stations are available in robotics, the dormitory bathrooms, and the
desc = "You have merged with a diona gestalt and are now part of it's biomass. You can still wiggle yourself free though."

/atom/movable/screen/alert/nymph/Click()
if(!usr || !usr.client)
if(!usr || !usr.client || !..())
return
if(isnymph(usr))
var/mob/living/simple_animal/diona/D = usr
Expand Down Expand Up @@ -491,7 +505,7 @@ so as to remain in compliance with the most up-to-date laws."
return ..()

/atom/movable/screen/alert/hackingapc/Click()
if(!usr || !usr.client)
if(!usr || !usr.client || !..())
return
if(!target)
return
Expand All @@ -517,7 +531,7 @@ so as to remain in compliance with the most up-to-date laws."
return ..()

/atom/movable/screen/alert/mech_port_available/Click()
if(!usr || !usr.client)
if(!usr || !usr.client || !..())
return
if(!ismecha(usr.loc) || !target)
return
Expand All @@ -533,7 +547,7 @@ so as to remain in compliance with the most up-to-date laws."
icon_state = "mech_port_x"

/atom/movable/screen/alert/mech_port_disconnect/Click()
if(!usr || !usr.client)
if(!usr || !usr.client || !..())
return
if(!ismecha(usr.loc))
return
Expand Down Expand Up @@ -823,11 +837,17 @@ so as to remain in compliance with the most up-to-date laws."
desc = "You're legcuffed, which slows you down considerably. Click the alert to free yourself."

/atom/movable/screen/alert/restrained/Click()
if(!..())
return

if(isliving(usr))
var/mob/living/L = usr
return L.resist()

/atom/movable/screen/alert/restrained/buckled/Click()
if(!..())
return

var/mob/living/L = usr
if(!istype(L) || !L.can_resist())
return
Expand All @@ -846,6 +866,11 @@ so as to remain in compliance with the most up-to-date laws."
if(!hud_shown)
for(var/i in 1 to alerts.len)
mymob.client.screen -= alerts[alerts[i]]
for(var/mob/dead/observer/observe in mymob.inventory_observers)
if(!observe.client)
LAZYREMOVE(mymob.inventory_observers, observe)
continue
observe.client.screen -= alerts[alerts[i]]
return TRUE
for(var/i in 1 to alerts.len)
var/atom/movable/screen/alert/alert = alerts[alerts[i]]
Expand All @@ -868,17 +893,22 @@ so as to remain in compliance with the most up-to-date laws."
. = ""
alert.screen_loc = .
mymob.client.screen |= alert
for(var/mob/dead/observer/observe in mymob.inventory_observers)
if(!observe.client)
LAZYREMOVE(mymob.inventory_observers, observe)
continue
observe.client.screen |= alert
return TRUE

/atom/movable/screen/alert/Click(location, control, params)
if(!usr || !usr.client)
if(!usr || !usr.client || HAS_TRAIT(usr, TRAIT_OBSERVING_INVENTORY))
return FALSE

var/paramslist = params2list(params)
if(paramslist["shift"]) // screen objects don't do the normal Click() stuff so we'll cheat
to_chat(usr, "<span class='boldnotice'>[name]</span> - <span class='info'>[desc]</span>")
return FALSE

if(master)
return usr.client.Click(master, location, control, params)

Expand All @@ -897,7 +927,7 @@ so as to remain in compliance with the most up-to-date laws."
icon_state = "succumb"

/atom/movable/screen/alert/succumb/Click()
if(!usr || !usr.client)
if(!usr || !usr.client || !..())
return
var/mob/living/living_owner = usr
if(!istype(usr))
Expand Down
31 changes: 18 additions & 13 deletions code/_onclick/hud/fullscreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
if(client && screen.should_show_to(src))
screen.update_for_view(client.view)
client.screen += screen
for(var/mob/dead/observer/observe in orbiters)
if(!istype(observe) || !observe.client || !observe.orbit_menu?.auto_observe)
LAZYREMOVE(orbiters, observe)
for(var/mob/dead/observer/observe in inventory_observers)
if(!observe.client)
LAZYREMOVE(inventory_observers, observe)
continue
observe.client.screen += screen

Expand All @@ -34,8 +34,9 @@
return

screens -= category
for(var/mob/dead/observer/observe in orbiters)
if(!istype(observe) || !observe.client)
for(var/mob/dead/observer/observe in inventory_observers)
if(!observe.client)
LAZYREMOVE(inventory_observers, observe)
continue
observe.screens -= category

Expand All @@ -46,8 +47,9 @@
if(client)
client.screen -= screen

for(var/mob/dead/observer/observe in orbiters)
if(!istype(observe) || !observe.client)
for(var/mob/dead/observer/observe in inventory_observers)
if(!observe.client)
LAZYREMOVE(inventory_observers, observe)
continue
observe.client.screen -= screen
qdel(screen)
Expand All @@ -56,8 +58,9 @@
/mob/proc/clear_fullscreen_after_animate(atom/movable/screen/fullscreen/screen)
if(client)
client.screen -= screen
for(var/mob/dead/observer/observe in orbiters)
if(!istype(observe) || !observe.client)
for(var/mob/dead/observer/observe in inventory_observers)
if(!observe.client)
LAZYREMOVE(inventory_observers, observe)
continue
observe.client.screen -= screen
qdel(screen)
Expand All @@ -78,15 +81,17 @@
screen.update_for_view(mymob.client.view)
mymob.client.screen |= screen

for(var/mob/dead/observer/observe in mymob.orbiters)
if(!istype(observe) || !observe.client)
for(var/mob/dead/observer/observe in mymob.inventory_observers)
if(!observe.client)
LAZYREMOVE(mymob.inventory_observers, observe)
continue
observe.client.screen |= screen
else
mymob.client.screen -= screen

for(var/mob/dead/observer/observe in mymob.orbiters)
if(!istype(observe) || !observe.client)
for(var/mob/dead/observer/observe in mymob.inventory_observers)
if(!observe.client)
LAZYREMOVE(mymob.inventory_observers, observe)
continue
observe.client.screen -= screen

Expand Down
12 changes: 6 additions & 6 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
if(owner.client)
owner.client.screen += button

for(var/mob/dead/observer/observe in user.orbiters)
if(!istype(observe) || !observe.client || !observe.orbit_menu?.auto_observe)
LAZYREMOVE(user.orbiters, observe)
for(var/mob/dead/observer/observe in user.inventory_observers)
if(!observe.client)
LAZYREMOVE(user.inventory_observers, observe)
continue
observe.client.screen += button

Expand Down Expand Up @@ -76,9 +76,9 @@
if(user.client)
user.client.screen -= button

for(var/mob/dead/observer/observe in user.orbiters)
if(!istype(observe) || !observe.client || !observe.orbit_menu?.auto_observe)
LAZYREMOVE(user.orbiters, observe)
for(var/mob/dead/observer/observe in user.inventory_observers)
if(!observe.client)
LAZYREMOVE(user.inventory_observers, observe)
continue
observe.client.screen -= button

Expand Down
2 changes: 2 additions & 0 deletions code/datums/diseases/viruses/babylon_fever.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
stored_languages ^= translator.given_languages // you can't forget it, because it's on the chip in translator

for(var/datum/language/lan as anything in stored_languages)
if(lan.flags & NOBABEL)
continue
affected_mob.remove_language(lan.name)


Expand Down
2 changes: 1 addition & 1 deletion code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,7 @@

if(!spell)
return FALSE

LAZYREMOVE(spell_list, spell)

spell.action.Remove(current)
Expand Down
5 changes: 3 additions & 2 deletions code/datums/progressbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
user_client = user.client
add_prog_bar_image_to_client()
// Ghosts wants to see a do_afters too!
for(var/mob/dead/observer/observe in user.orbiters)
if(!istype(observe) || !observe.client)
for(var/mob/dead/observer/observe in user.inventory_observers)
if(!observe.client)
LAZYREMOVE(user.inventory_observers, observe)
continue
user_client = observe.client
add_prog_bar_image_to_client()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/bloodcrawl.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
var/turf/tele_loc = isturf(enter_point) ? enter_point : enter_point.loc
var/holder = user.loc
user.forceMove(tele_loc)
user.client.eye = user
user.client.set_eye(user)

rise_animation(tele_loc, user, enter_point)

Expand Down
Loading