safety i guess, people are afraid that someone is SOMEHOW gonna manage to open their menu without being admin

This commit is contained in:
SandPoot
2023-02-11 21:54:20 -03:00
parent c42edf2d4c
commit 243e7ea02f
3 changed files with 23 additions and 15 deletions
@@ -7,9 +7,9 @@
if(!src)
return
var/datum/component/interaction/interaction = GetComponent(/datum/component/interaction)
if(interaction)
interaction.open_menu(usr, src)
var/datum/component/interaction_menu_granter/menu = GetComponent(/datum/component/interaction_menu_granter)
if(menu)
menu.open_menu(usr, src)
else // you bad
remove_verb(src, /mob/proc/interact_with)
@@ -18,10 +18,10 @@
#define INTERACTION_EXTREME 2
/// The menu itself, only var is target which is the mob you are interacting with
/datum/component/interaction
/datum/component/interaction_menu_granter
var/mob/living/target
/datum/component/interaction/Initialize(...)
/datum/component/interaction_menu_granter/Initialize(...)
if(!ismob(parent))
return COMPONENT_INCOMPATIBLE
var/mob/parent_mob = parent
@@ -33,14 +33,17 @@
RegisterSignal(parent_mob, COMSIG_MOB_CLICKON, .proc/open_menu)
. = ..()
/datum/component/interaction/Destroy(force, ...)
/datum/component/interaction_menu_granter/Destroy(force, ...)
var/mob/parent_mob = parent
remove_verb(parent_mob, /mob/proc/interact_with)
target = null
UnregisterSignal(parent_mob, COMSIG_MOB_CLICKON)
. = ..()
/datum/component/interaction/proc/open_menu(mob/clicker, mob/clicked, mouse_params)
/datum/component/interaction_menu_granter/proc/open_menu(mob/clicker, mob/clicked, mouse_params)
// Don't cancel admin quick spawn
if(isobserver(clicked) && check_rights(R_SPAWN, FALSE))
return FALSE
// COMSIG_MOB_CLICKON is sent for EVERYTHING your mob character clicks, avoid non-mob
if(!istype(clicked))
return FALSE
@@ -54,10 +57,15 @@
ui_interact(clicker)
return COMSIG_MOB_CANCEL_CLICKON
/datum/component/interaction/ui_state(mob/user)
return GLOB.conscious_state
/datum/component/interaction_menu_granter/ui_state(mob/user)
// Funny admin, don't you dare be the extra funny now.
if(user.client.holder)
return GLOB.always_state
if(user == parent)
return GLOB.conscious_state
return GLOB.never_state
/datum/component/interaction/ui_interact(mob/user, datum/tgui/ui)
/datum/component/interaction_menu_granter/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "MobInteraction", "Interactions")
@@ -72,7 +80,7 @@
else
return 0
/datum/component/interaction/ui_data(mob/user)
/datum/component/interaction_menu_granter/ui_data(mob/user)
. = ..()
//Getting player
var/mob/living/self = parent
@@ -190,7 +198,7 @@
else
return "No"
/datum/component/interaction/ui_act(action, params)
/datum/component/interaction_menu_granter/ui_act(action, params)
if(..())
return
var/mob/living/parent_mob = parent
+2 -2
View File
@@ -1,10 +1,10 @@
// Only Clients should have a panel for them, okay?
/mob/Login()
. = ..()
AddComponent(/datum/component/interaction)
AddComponent(/datum/component/interaction_menu_granter)
/mob/Logout()
qdel(GetComponent(/datum/component/interaction))
qdel(GetComponent(/datum/component/interaction_menu_granter))
. = ..()
///Adjust the thirst of a mob
+1 -1
View File
@@ -3918,7 +3918,7 @@
#include "modular_sand\code\datums\action.dm"
#include "modular_sand\code\datums\ai_laws.dm"
#include "modular_sand\code\datums\shuttles.dm"
#include "modular_sand\code\datums\components\interaction.dm"
#include "modular_sand\code\datums\components\interaction_menu_granter.dm"
#include "modular_sand\code\datums\components\mood.dm"
#include "modular_sand\code\datums\components\riding.dm"
#include "modular_sand\code\datums\components\container_item\container_item.dm"