mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-28 01:51:46 +00:00
## About The Pull Request * A generic /mob/eye/camera type has been made, containing everything needed to interface with a cameranet * /mob/eye/ai_eye has been refactored into a generic /mob/eye/camera instance * Advanced cameras no longer inherit from AI eyes, splitting off behaviour * Camera code has been somewhat cleaned up * Probably some more stuff I'm forgetting right now ## Big man Southport:  ## Changelog 🆑 code: made /proc/getviewsize() pure refactor: mob/eye/ai_eye has been restructured, now inheriting from a generic mob/eye/camera type refactor: advanced cameras and their subtypes are now mob/eye/camera/remote subtypes code: the cameranet no longer expects the user to be an AI eye code: remote camera eyes have had their initialization streamlined code: remote cameras handle assigning and unassigning users by themselves now code: remote cameras now use weakrefs instead of hard referencing owners and origins code: also the sentient disease is_define was removed (we don't have those anymore) fix: AI eyes no longer assign real names to themselves, fixing their orbit name /🆑 --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
41 lines
1.4 KiB
Plaintext
41 lines
1.4 KiB
Plaintext
/proc/getviewsize(view = world.view)
|
|
SHOULD_BE_PURE(TRUE)
|
|
|
|
if(isnum(view))
|
|
var/totalviewrange = (view < 0 ? -1 : 1) + 2 * view
|
|
return list(totalviewrange, totalviewrange)
|
|
else
|
|
var/list/viewrangelist = splittext(view, "x")
|
|
return list(text2num(viewrangelist[1]), text2num(viewrangelist[2]))
|
|
|
|
|
|
/// Takes a string or num view, and converts it to pixel width/height in a list(pixel_width, pixel_height)
|
|
/proc/view_to_pixels(view)
|
|
if(!view)
|
|
return list(0, 0)
|
|
var/list/view_info = getviewsize(view)
|
|
view_info[1] *= ICON_SIZE_X
|
|
view_info[2] *= ICON_SIZE_Y
|
|
return view_info
|
|
|
|
/**
|
|
* Frustrated with bugs in can_see(), this instead uses viewers for a much more effective approach.
|
|
* ### Things to note:
|
|
* - Src/source must be a mob. `viewers()` returns mobs.
|
|
* - Adjacent objects are always considered visible.
|
|
*/
|
|
|
|
/// The default tile-distance between two atoms for one to consider the other as visible.
|
|
#define DEFAULT_SIGHT_DISTANCE 7
|
|
|
|
/// Basic check to see if the src object can see the target object.
|
|
#define CAN_I_SEE(target) ((src in viewers(DEFAULT_SIGHT_DISTANCE, target)) || in_range(target, src))
|
|
|
|
|
|
/// Checks the visibility between two other objects.
|
|
#define CAN_THEY_SEE(target, source) ((source in viewers(DEFAULT_SIGHT_DISTANCE, target)) || in_range(target, source))
|
|
|
|
|
|
/// Further checks distance between source and target.
|
|
#define CAN_SEE_RANGED(target, source, dist) ((source in viewers(dist, target)) || in_range(target, source))
|