mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
## About The Pull Request FOV as it is currently implemented is incompatible* with wallening. I'm doin wallening, so we gotta redo things here. The issue is the masking of mobs. Wallening relies on sidemap (layering based off physical position), which only works on things on the same plane (because planes are basically sheets we render down onto) So rather then masking mobs, let's reuse the masking idea from old fov, and use it to cut out a bit of the game render plane, and blur/over-saturate the bit that's masked out. My hope is this makes things visible in light, but not as much in darkness, alongside making more vivid shit more easily seen (just like real life) Here's some videos, what follows after is the commits I care about (since I had to rip a bunch of planes to nothing, so the files changed tab might be a bit of a mess) Oh also I had to remove the darkness pref since the darkness is doing a lot of the heavy lifting now. I'm sorry. Edit: NEW FOV SPRITES! Thanks dongle your aviator glasses will guide us to a better future. https://github.com/tgstation/tgstation/assets/58055496/afa9eeb8-8b7b-4364-b0c0-7ac8070b5609 https://github.com/tgstation/tgstation/assets/58055496/0eff040c-8bf1-47e4-a4f3-dac56fb2ccc8 ## Commits I Care About [Implements something like fov, but without the planes as layers hell](a604c7b1c8) Rather then masking out mobs standing behind us, we use a combo color matrix and blur filter to make the stuff covered by fov harder to see. We achive this by splitting the game plane into two, masking both by fov (one normally and one inversely), and then applying effects to one of the two. I want to make the fov fullscreens more gradient, but as an effect this is a good start [Removes WALL_PLANE_UPPER by adding a WALL_PLANE overlay to material walls (init cost comes here)](2548933739) @Mothblocks see this. comment in commit explains further but uh, we need to draw material walls to the light mask plane so things actually can be seen on them, but we can't do that and also have them be big, so they get an overlay. Sorry, slight init time bump, about 0.5 seconds. I can kill it with wallening. [Moves SEETHROUGH_PLANE above ABOVE_GAME_PLANE](beec4c00e0) I don't think it actually wants to draw here @Time-Green I think this was you so pinging for opinion [Resprites FOV masks to be clean (and more consistent)](f02ad13696) [f02ad13](f02ad13696) This is 100% donglesplonge's work, he's spent a week or so going back and forth with me sharpening these to a mirror shine, real chill ## Why It's Good For The Game Walls are closing in ## Changelog 🆑 LemonInTheDark, Donglesplonge image: Redoes fov "mask" sprites. They're clean, have a very pleasant dithering effect, and look real fuckin good! del: Changed FOV, it no longer hides mobs, instead it blurs the hidden area, and makes it a bit darker/oversaturated /🆑 ###### * It's technically possible if we start using render targets to create 2 sets of sources but that's insane and we aren't doing it
128 lines
4.6 KiB
Plaintext
128 lines
4.6 KiB
Plaintext
/// Component which handles Field of View masking for clients. FoV attributes are at /mob/living
|
|
/datum/component/fov_handler
|
|
/// Currently applied x size of the fov masks
|
|
var/current_fov_x = BASE_FOV_MASK_X_DIMENSION
|
|
/// Currently applied y size of the fov masks
|
|
var/current_fov_y = BASE_FOV_MASK_Y_DIMENSION
|
|
/// Whether we are applying the masks now
|
|
var/applied_mask = FALSE
|
|
/// The angle of the mask we are applying
|
|
var/fov_angle = FOV_180_DEGREES
|
|
/// The blocker mask applied to a client's screen
|
|
var/atom/movable/screen/fov_blocker/blocker_mask
|
|
|
|
/datum/component/fov_handler/Initialize(fov_type = FOV_180_DEGREES)
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/mob/living/mob_parent = parent
|
|
var/client/parent_client = mob_parent.client
|
|
if(!parent_client) //Love client volatility!!
|
|
qdel(src) //no QDEL hint for components, and we dont want this to print a warning regarding bad component application
|
|
return
|
|
|
|
ADD_TRAIT(mob_parent, TRAIT_FOV_APPLIED, REF(src))
|
|
|
|
blocker_mask = new
|
|
set_fov_angle(fov_type)
|
|
on_dir_change(mob_parent, mob_parent.dir, mob_parent.dir)
|
|
update_fov_size()
|
|
update_mask()
|
|
|
|
/datum/component/fov_handler/Destroy()
|
|
var/mob/living/mob_parent = parent
|
|
|
|
REMOVE_TRAIT(mob_parent, TRAIT_FOV_APPLIED, REF(src))
|
|
if(applied_mask)
|
|
remove_mask()
|
|
if(blocker_mask) // In a case of early deletion due to volatile client
|
|
QDEL_NULL(blocker_mask)
|
|
return ..()
|
|
|
|
/datum/component/fov_handler/proc/set_fov_angle(new_angle)
|
|
fov_angle = new_angle
|
|
blocker_mask.icon_state = "[fov_angle]"
|
|
|
|
/// Updates the size of the FOV masks by comparing them to client view size.
|
|
/datum/component/fov_handler/proc/update_fov_size()
|
|
SIGNAL_HANDLER
|
|
var/mob/parent_mob = parent
|
|
var/client/parent_client = parent_mob.client
|
|
if(!parent_client) //Love client volatility!!
|
|
return
|
|
var/list/view_size = getviewsize(parent_client.view)
|
|
if(view_size[1] == current_fov_x && view_size[2] == current_fov_y)
|
|
return
|
|
current_fov_x = BASE_FOV_MASK_X_DIMENSION
|
|
current_fov_y = BASE_FOV_MASK_Y_DIMENSION
|
|
var/matrix/new_matrix = new
|
|
var/x_shift = view_size[1] - current_fov_x
|
|
var/y_shift = view_size[2] - current_fov_y
|
|
var/x_scale = view_size[1] / current_fov_x
|
|
var/y_scale = view_size[2] / current_fov_y
|
|
current_fov_x = view_size[1]
|
|
current_fov_y = view_size[2]
|
|
blocker_mask.transform = new_matrix.Scale(x_scale, y_scale)
|
|
blocker_mask.transform = new_matrix.Translate(x_shift * 16, y_shift * 16)
|
|
|
|
/// Updates the mask application to client by checking `stat` and `eye`
|
|
/datum/component/fov_handler/proc/update_mask()
|
|
SIGNAL_HANDLER
|
|
var/mob/parent_mob = parent
|
|
var/client/parent_client = parent_mob.client
|
|
if(!parent_client) //Love client volatility!!
|
|
return
|
|
var/user_living = parent_mob != DEAD
|
|
var/atom/top_most_atom = get_atom_on_turf(parent_mob)
|
|
var/user_extends_eye = parent_client.eye != top_most_atom
|
|
var/should_apply_mask = user_living && !user_extends_eye
|
|
|
|
if(should_apply_mask == applied_mask)
|
|
return
|
|
|
|
if(should_apply_mask)
|
|
add_mask()
|
|
else
|
|
remove_mask()
|
|
|
|
/datum/component/fov_handler/proc/remove_mask()
|
|
var/mob/parent_mob = parent
|
|
var/client/parent_client = parent_mob.client
|
|
// Prevents stupid ass hard deletes
|
|
parent_mob.hud_used.always_visible_inventory -= blocker_mask
|
|
if(!parent_client) //Love client volatility!!
|
|
return
|
|
applied_mask = FALSE
|
|
parent_client.screen -= blocker_mask
|
|
|
|
/datum/component/fov_handler/proc/add_mask()
|
|
var/mob/parent_mob = parent
|
|
var/client/parent_client = parent_mob.client
|
|
if(!parent_client) //Love client volatility!!
|
|
return
|
|
applied_mask = TRUE
|
|
parent_client.screen += blocker_mask
|
|
parent_mob.hud_used.always_visible_inventory += blocker_mask
|
|
|
|
/// When a direction of the user changes, so do the masks
|
|
/datum/component/fov_handler/proc/on_dir_change(mob/source, old_dir, new_dir)
|
|
SIGNAL_HANDLER
|
|
blocker_mask.dir = new_dir
|
|
|
|
/// When a mob logs out, delete the component
|
|
/datum/component/fov_handler/proc/mob_logout(mob/source)
|
|
SIGNAL_HANDLER
|
|
qdel(src)
|
|
|
|
/datum/component/fov_handler/RegisterWithParent()
|
|
. = ..()
|
|
RegisterSignal(parent, COMSIG_ATOM_DIR_CHANGE, PROC_REF(on_dir_change))
|
|
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(update_mask))
|
|
RegisterSignal(parent, COMSIG_LIVING_REVIVE, PROC_REF(update_mask))
|
|
RegisterSignal(parent, COMSIG_MOB_CLIENT_CHANGE_VIEW, PROC_REF(update_fov_size))
|
|
RegisterSignal(parent, COMSIG_MOB_RESET_PERSPECTIVE, PROC_REF(update_mask))
|
|
RegisterSignal(parent, COMSIG_MOB_LOGOUT, PROC_REF(mob_logout))
|
|
|
|
/datum/component/fov_handler/UnregisterFromParent()
|
|
. = ..()
|
|
UnregisterSignal(parent, list(COMSIG_MOB_RESET_PERSPECTIVE, COMSIG_ATOM_DIR_CHANGE, COMSIG_LIVING_DEATH, COMSIG_LIVING_REVIVE, COMSIG_MOB_LOGOUT))
|