Files
Bubberstation/code/modules/tgui/states.dm
coiax 4483d5275c Shuttle manipulator (#17436)
* Starting out on our tgui journey

* God tgui, why do you need to be updated

You're dynamically generated anyway

* Commit of stuff

* Further progress is being made

* Everyone loves buildscripts

* Further modifications to my incredible running script

* Starting to modify the minimap code to be better

* It's going well thusfar, I guess

* What have I done

* RIP minimap

* FUN FUN FUN FUN FUN

* Adds shuttle_manipulator.dmi

MUH HOLOGRAMS

* Is it done? IS IT OVER

* Peer review

* Some bug fixes

* Makes that damn greentext shut up

* Shuttle registration

* Made the Emergency Escape Bar more robust

No climbing on the bar.

* Do not stare into the operation end of the device

* Compile shame

* THE MOST DUMB

* Passive barmaiden

* Emergency shuttle memes

* MORE SAFETY CODE

* Fancy shuttle manipulator icons

* Smoothing it out

* We are going to have a lot of fun with this one

* Independent blobbernauts

* WABBAJACK WABBAJACK

* Message for attempting to authenticate old style

* Angry alert noise is back

* Revert "Independent blobbernauts"

This reverts commit 34d6af7c9c88cfc2864990cb37b586bb90163dd3.

* No parrot sleep plz

* Moves the special shuttle stuff to special.dm

* No Bartender like a Centcom Bartender

* Non-controversial map changes

- Backup shuttle moved closer to Centcom main structure, docking tube
created
- Moved shuttle import landmark to above Centcom main building
- Added shuttle displays to Conference Room
- Squashed the Chapel a bit in Metastation
- Made the docking port on Z2 massive
- Made the docking port on Metastation a lot larger

* Hacks and slashes at Box

A bunch of things are extended and squashed so Box shuttle dock can
support the MetaStation emergency shuttle.

* Some Metastationshit

* Never ending changes

* Wabbajack to TGM

* Modified the bar, I think that's all of them

* Stops Barmaiden wandering around

* More code review

* Whitspace, the bane of us all

* DIE WHITESPACE DIE
2016-05-26 15:15:19 +02:00

117 lines
3.3 KiB
Plaintext

/**
* tgui states
*
* Base state and helpers for states. Just does some sanity checks, implement a state for in-depth checks.
**/
/**
* public
*
* Checks the UI state for a mob.
*
* required user mob The mob who opened/is using the UI.
* required state datum/ui_state The state to check.
*
* return UI_state The state of the UI.
**/
/datum/proc/ui_status(mob/user, datum/ui_state/state)
var/src_object = ui_host()
. = UI_CLOSE
if(!state)
return
if(istype(user, /mob/dead/observer))
// If they turn on ghost AI control, admins can always interact.
if(IsAdminGhost(user))
. = max(., UI_INTERACTIVE)
// Regular ghosts can always at least view if in range.
if(get_dist(src_object, src) < user.client.view)
. = max(., UI_UPDATE)
// Check if the state allows interaction
var/result = state.can_use_topic(src_object, user)
. = max(., result)
/**
* private
*
* Checks if a user can use src_object's UI, and returns the state.
* Can call a mob proc, which allows overrides for each mob.
*
* required src_object datum The object/datum which owns the UI.
* required user mob The mob who opened/is using the UI.
*
* return UI_state The state of the UI.
**/
/datum/ui_state/proc/can_use_topic(src_object, mob/user)
return UI_CLOSE // Don't allow interaction by default.
/**
* public
*
* Standard interaction/sanity checks. Different mob types may have overrides.
*
* return UI_state The state of the UI.
**/
/mob/proc/shared_ui_interaction(src_object)
if(!client) // Close UIs if mindless.
return UI_CLOSE
else if(stat) // Disable UIs if unconcious.
return UI_DISABLED
else if(incapacitated() || lying) // Update UIs if incapicitated but concious.
return UI_UPDATE
return UI_INTERACTIVE
/mob/living/silicon/ai/shared_ui_interaction(src_object)
if(lacks_power()) // Disable UIs if the AI is unpowered.
return UI_DISABLED
return ..()
/mob/living/silicon/robot/shared_ui_interaction(src_object)
if(cell.charge <= 0 || lockcharge) // Disable UIs if the Borg is unpowered or locked.
return UI_DISABLED
return ..()
/**
* public
*
* Check the distance for a living mob.
* Really only used for checks outside the context of a mob.
* Otherwise, use shared_living_ui_distance().
*
* required src_object The object which owns the UI.
* required user mob The mob who opened/is using the UI.
*
* return UI_state The state of the UI.
**/
/atom/proc/contents_ui_distance(src_object, mob/living/user)
return user.shared_living_ui_distance(src_object) // Just call this mob's check.
/**
* public
*
* Distance versus interaction check.
*
* required src_object atom/movable The object which owns the UI.
*
* return UI_state The state of the UI.
**/
/mob/living/proc/shared_living_ui_distance(atom/movable/src_object)
if(!(src_object in view(src))) // If the object is obscured, close it.
return UI_CLOSE
var/dist = get_dist(src_object, src)
if(dist <= 1) // Open and interact if 1-0 tiles away.
return UI_INTERACTIVE
else if(dist <= 2) // View only if 2-3 tiles away.
return UI_UPDATE
else if(dist <= 5) // Disable if 5 tiles away.
return UI_DISABLED
return UI_CLOSE // Otherwise, we got nothing.
/mob/living/carbon/human/shared_living_ui_distance(atom/movable/src_object)
if(dna.check_mutation(TK) && tkMaxRangeCheck(src, src_object))
return UI_INTERACTIVE
return ..()