mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 01:34:01 +00:00
[MIRROR] Multiz Rework: Human Suffering Edition (Contains PLANE CUBE) [MDB IGNORE] (#16472)
* Multiz Rework: Human Suffering Edition (Contains PLANE CUBE) * skyrat changes * bodyparts merge * unres door floorlight fix * Future upstream fix for blindness * upcoming upstream airlock fix * fix button emissive * Fix FOV markings? Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: tastyfish <crazychris32@gmail.com>
This commit is contained in:
@@ -1,218 +1,460 @@
|
||||
// I hate this place
|
||||
INITIALIZE_IMMEDIATE(/atom/movable/screen/plane_master)
|
||||
/atom/movable/screen/plane_master
|
||||
screen_loc = "CENTER"
|
||||
icon_state = "blank"
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
plane = LOWEST_EVER_PLANE
|
||||
var/show_alpha = 255
|
||||
var/hide_alpha = 0
|
||||
/// Will be sent to the debug ui as a description for each plane
|
||||
/// Also useful as a place to explain to coders how/why your plane works, and what it's meant to do
|
||||
/// Plaintext and basic html are fine to use here.
|
||||
/// I'll bonk you if I find you putting "lmao stuff" in here, make this useful.
|
||||
var/documentation = ""
|
||||
/// Our real alpha value, so alpha can persist through being hidden/shown
|
||||
var/true_alpha = 255
|
||||
/// Tracks if we're using our true alpha, or being manipulated in some other way
|
||||
var/alpha_enabled = TRUE
|
||||
|
||||
/// The plane master group we're a member of, our "home"
|
||||
var/datum/plane_master_group/home
|
||||
|
||||
/// If our plane master allows for offsetting
|
||||
/// Mostly used for planes that really don't need to be duplicated, like the hud planes
|
||||
var/allows_offsetting = TRUE
|
||||
/// Our offset from our "true" plane, see below
|
||||
var/offset
|
||||
/// When rendering multiz, lower levels get their own set of plane masters
|
||||
/// Real plane here represents the "true" plane value of something, ignoring the offset required to handle lower levels
|
||||
var/real_plane
|
||||
|
||||
//--rendering relay vars--
|
||||
///integer: what plane we will relay this planes render to
|
||||
var/render_relay_plane = RENDER_PLANE_GAME
|
||||
///bool: Whether this plane should get a render target automatically generated
|
||||
var/generate_render_target = TRUE
|
||||
///integer: blend mode to apply to the render relay in case you dont want to use the plane_masters blend_mode
|
||||
/// list of planes we will relay this plane's render to
|
||||
var/list/render_relay_planes = list(RENDER_PLANE_GAME)
|
||||
/// blend mode to apply to the render relay in case you dont want to use the plane_masters blend_mode
|
||||
var/blend_mode_override
|
||||
///reference: current relay this plane is utilizing to render
|
||||
var/atom/movable/render_plane_relay/relay
|
||||
/// list of current relays this plane is utilizing to render
|
||||
var/list/atom/movable/render_plane_relay/relays = list()
|
||||
/// if render relays have already be generated
|
||||
var/relays_generated = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/proc/Show(override)
|
||||
alpha = override || show_alpha
|
||||
/// If this plane master should be hidden from the player at roundstart
|
||||
/// We do this so PMs can opt into being temporary, to reduce load on clients
|
||||
var/start_hidden = FALSE
|
||||
/// If this plane master is being forced to hide.
|
||||
/// Hidden PMs will dump ANYTHING relayed or drawn onto them. Be careful with this
|
||||
/// Remember: a hidden plane master will dump anything drawn directly to it onto the output render. It does NOT hide its contents
|
||||
/// Use alpha for that
|
||||
var/force_hidden = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/proc/Hide(override)
|
||||
alpha = override || hide_alpha
|
||||
/// If this plane should be scaled by multiz
|
||||
/// Planes with this set should NEVER be relay'd into each other, as that will cause visual fuck
|
||||
var/multiz_scaled = TRUE
|
||||
|
||||
//Why do plane masters need a backdrop sometimes? Read https://secure.byond.com/forum/?post=2141928
|
||||
//Trust me, you need one. Period. If you don't think you do, you're doing something extremely wrong.
|
||||
/atom/movable/screen/plane_master/proc/backdrop(mob/mymob)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
if(!isnull(render_relay_plane))
|
||||
relay_render_to_plane(mymob, render_relay_plane)
|
||||
|
||||
///Things rendered on "openspace"; holes in multi-z
|
||||
/atom/movable/screen/plane_master/openspace_backdrop
|
||||
name = "open space backdrop plane master"
|
||||
plane = OPENSPACE_BACKDROP_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_MULTIPLY
|
||||
alpha = 255
|
||||
|
||||
/atom/movable/screen/plane_master/openspace
|
||||
name = "open space plane master"
|
||||
plane = OPENSPACE_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
|
||||
/atom/movable/screen/plane_master/openspace/Initialize(mapload)
|
||||
/atom/movable/screen/plane_master/Initialize(mapload, datum/plane_master_group/home, offset = 0)
|
||||
. = ..()
|
||||
add_filter("first_stage_openspace", 1, drop_shadow_filter(color = "#04080FAA", size = -10))
|
||||
add_filter("second_stage_openspace", 2, drop_shadow_filter(color = "#04080FAA", size = -15))
|
||||
add_filter("third_stage_openspace", 3, drop_shadow_filter(color = "#04080FAA", size = -20))
|
||||
src.offset = offset
|
||||
true_alpha = alpha
|
||||
real_plane = plane
|
||||
|
||||
///For any transparent multi-z tiles we want to render
|
||||
/atom/movable/screen/plane_master/transparent
|
||||
name = "transparent plane master"
|
||||
plane = TRANSPARENT_FLOOR_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
if(!set_home(home))
|
||||
return INITIALIZE_HINT_QDEL
|
||||
update_offset()
|
||||
if(!documentation && !(istype(src, /atom/movable/screen/plane_master) || istype(src, /atom/movable/screen/plane_master/rendering_plate)))
|
||||
stack_trace("Plane master created without a description. Document how your thing works so people will know in future, and we can display it in the debug menu")
|
||||
if(start_hidden)
|
||||
hide_plane(home.our_hud?.mymob)
|
||||
generate_render_relays()
|
||||
|
||||
/atom/movable/screen/plane_master/Destroy()
|
||||
if(home)
|
||||
// NOTE! We do not clear ourselves from client screens
|
||||
// We relay on whoever qdel'd us to reset our hud, and properly purge us
|
||||
home.plane_masters -= "[plane]"
|
||||
home = null
|
||||
. = ..()
|
||||
QDEL_LIST(relays)
|
||||
|
||||
/// Sets the plane group that owns us, it also determines what screen we render to
|
||||
/// Returns FALSE if the set_home fails, TRUE otherwise
|
||||
/atom/movable/screen/plane_master/proc/set_home(datum/plane_master_group/home)
|
||||
if(!istype(home, /datum/plane_master_group))
|
||||
return FALSE
|
||||
src.home = home
|
||||
if(home.map)
|
||||
screen_loc = "[home.map]:[screen_loc]"
|
||||
assigned_map = home.map
|
||||
return TRUE
|
||||
|
||||
/// Updates our "offset", basically what layer of multiz we're meant to render
|
||||
/// Top is 0, goes up as you go down
|
||||
/// It's taken into account by render targets and relays, so we gotta make sure they're on the same page
|
||||
/atom/movable/screen/plane_master/proc/update_offset()
|
||||
name = "[initial(name)] #[offset]"
|
||||
SET_PLANE_W_SCALAR(src, real_plane, offset)
|
||||
for(var/i in 1 to length(render_relay_planes))
|
||||
render_relay_planes[i] = GET_NEW_PLANE(render_relay_planes[i], offset)
|
||||
if(initial(render_target))
|
||||
render_target = OFFSET_RENDER_TARGET(initial(render_target), offset)
|
||||
|
||||
/atom/movable/screen/plane_master/proc/set_alpha(new_alpha)
|
||||
true_alpha = new_alpha
|
||||
if(!alpha_enabled)
|
||||
return
|
||||
alpha = new_alpha
|
||||
|
||||
/atom/movable/screen/plane_master/proc/disable_alpha()
|
||||
alpha_enabled = FALSE
|
||||
alpha = 0
|
||||
|
||||
/atom/movable/screen/plane_master/proc/enable_alpha()
|
||||
alpha_enabled = TRUE
|
||||
alpha = true_alpha
|
||||
|
||||
/// Shows a plane master to the passed in mob
|
||||
/// Override this to apply unique effects and such
|
||||
/// Returns TRUE if the call is allowed, FALSE otherwise
|
||||
/atom/movable/screen/plane_master/proc/show_to(mob/mymob)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
if(force_hidden)
|
||||
return FALSE
|
||||
|
||||
var/client/our_client = mymob?.client
|
||||
if(!our_client)
|
||||
return TRUE
|
||||
|
||||
our_client.screen += src
|
||||
our_client.screen += relays
|
||||
return TRUE
|
||||
|
||||
/// Hides a plane master from the passeed in mob
|
||||
/// Do your effect cleanup here
|
||||
/atom/movable/screen/plane_master/proc/hide_from(mob/oldmob)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
var/client/their_client = oldmob?.client
|
||||
if(!their_client)
|
||||
return
|
||||
their_client.screen -= src
|
||||
their_client.screen -= relays
|
||||
|
||||
|
||||
/// Forces this plane master to hide, until unhide_plane is called
|
||||
/// This allows us to disable unused PMs without breaking anything else
|
||||
/atom/movable/screen/plane_master/proc/hide_plane(mob/cast_away)
|
||||
force_hidden = TRUE
|
||||
hide_from(cast_away)
|
||||
|
||||
/// Disables any forced hiding, allows the plane master to be used as normal
|
||||
/atom/movable/screen/plane_master/proc/unhide_plane(mob/enfold)
|
||||
force_hidden = FALSE
|
||||
show_to(enfold)
|
||||
|
||||
/// Mirrors our force hidden state to the hidden state of the plane that came before, assuming it's valid
|
||||
/// This allows us to mirror any hidden sets from before we were created, no matter how low that chance is
|
||||
/atom/movable/screen/plane_master/proc/mirror_parent_hidden()
|
||||
var/mob/our_mob = home?.our_hud?.mymob
|
||||
var/atom/movable/screen/plane_master/true_plane = our_mob?.hud_used.get_plane_master(plane)
|
||||
if(true_plane == src || !true_plane)
|
||||
return
|
||||
|
||||
if(true_plane.force_hidden == force_hidden)
|
||||
return
|
||||
|
||||
// If one of us already exists and it's not hidden, unhide ourselves
|
||||
if(true_plane.force_hidden)
|
||||
hide_plane(our_mob)
|
||||
else
|
||||
unhide_plane(our_mob)
|
||||
|
||||
/atom/movable/screen/plane_master/clickcatcher
|
||||
name = "Click Catcher"
|
||||
documentation = "Contains the screen object we use as a backdrop to catch clicks on portions of the screen that would otherwise contain nothing else. \
|
||||
<br>Will always be below almost everything else"
|
||||
plane = CLICKCATCHER_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
multiz_scaled = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/clickcatcher/Initialize(mapload, datum/plane_master_group/home, offset)
|
||||
. = ..()
|
||||
RegisterSignal(SSmapping, COMSIG_PLANE_OFFSET_INCREASE, .proc/offset_increased)
|
||||
offset_increased(SSmapping, 0, SSmapping.max_plane_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/clickcatcher/proc/offset_increased(datum/source, old_off, new_off)
|
||||
SIGNAL_HANDLER
|
||||
// We only want need the lowest level
|
||||
// If my system better supported changing PM plane values mid op I'd do that, but I do NOT so
|
||||
if(new_off > offset)
|
||||
hide_plane(home?.our_hud?.mymob)
|
||||
|
||||
/atom/movable/screen/plane_master/parallax_white
|
||||
name = "Parallax whitifier"
|
||||
documentation = "Essentially a backdrop for the parallax plane. We're rendered just below it, so we'll be multiplied by its well, parallax.\
|
||||
<br>If you want something to look as if it has parallax on it, draw it to this plane."
|
||||
plane = PLANE_SPACE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
|
||||
///Contains space parallax
|
||||
/atom/movable/screen/plane_master/parallax
|
||||
name = "Parallax"
|
||||
documentation = "Contains parallax, or to be more exact the screen objects that hold parallax.\
|
||||
<br>Note the BLEND_MULTIPLY. The trick here is how low our plane value is. Because of that, we draw below almost everything in the game.\
|
||||
<br>We abuse this to ensure we multiply against the Parallax whitifier plane, or space's plane. It's set to full white, so when you do the multiply you just get parallax out where it well, makes sense to be.\
|
||||
<br>Also notice that the parent parallax plane is mirrored down to all children. We want to support viewing parallax across all z levels at once."
|
||||
plane = PLANE_SPACE_PARALLAX
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
blend_mode = BLEND_MULTIPLY
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
multiz_scaled = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/parallax/Initialize(mapload, datum/plane_master_group/home, offset)
|
||||
. = ..()
|
||||
if(offset != 0)
|
||||
// You aren't the source? don't change yourself
|
||||
return
|
||||
RegisterSignal(SSmapping, COMSIG_PLANE_OFFSET_INCREASE, .proc/on_offset_increase)
|
||||
offset_increase(0, SSmapping.max_plane_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/parallax/proc/on_offset_increase(datum/source, old_offset, new_offset)
|
||||
SIGNAL_HANDLER
|
||||
offset_increase(old_offset, new_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/parallax/proc/offset_increase(old_offset, new_offset)
|
||||
// Parallax will be mirrored down to any new planes that are added, so it will properly render across mirage borders
|
||||
for(var/offset in old_offset to new_offset)
|
||||
if(offset != 0)
|
||||
// Overlay so we don't multiply twice, and thus fuck up our rendering
|
||||
add_relay_to(GET_NEW_PLANE(plane, offset), BLEND_OVERLAY)
|
||||
|
||||
/atom/movable/screen/plane_master/gravpulse
|
||||
name = "Gravpulse"
|
||||
documentation = "Ok so this one's fun. Basically, we want to be able to distort the game plane when a grav annom is around.\
|
||||
<br>So we draw the pattern we want to use to this plane, and it's then used as a render target by a distortion filter on the game plane.\
|
||||
<br>Note the blend mode and lack of relay targets. This plane exists only to distort, it's never rendered anywhere."
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
plane = GRAVITY_PULSE_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
blend_mode = BLEND_ADD
|
||||
render_target = GRAVITY_PULSE_RENDER_TARGET
|
||||
render_relay_planes = list()
|
||||
|
||||
///Contains just the floor
|
||||
/atom/movable/screen/plane_master/floor
|
||||
name = "floor plane master"
|
||||
name = "Floor"
|
||||
documentation = "The well, floor. This is mostly used as a sorting mechanism, but it also lets us create a \"border\" around the game world plane, so its drop shadow will actually work."
|
||||
plane = FLOOR_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
///Contains most things in the game world
|
||||
/atom/movable/screen/plane_master/game_world
|
||||
name = "game world plane master"
|
||||
/atom/movable/screen/plane_master/game
|
||||
name = "Lower game world"
|
||||
documentation = "Exists mostly because of FOV shit. Basically, if you've just got a normal not ABOVE fov thing, and you don't want it masked, stick it here yeah?"
|
||||
plane = GAME_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
/atom/movable/screen/plane_master/game_world/backdrop(mob/mymob)
|
||||
. = ..()
|
||||
remove_filter("AO")
|
||||
if(istype(mymob) && mymob.client?.prefs?.read_preference(/datum/preference/toggle/ambient_occlusion))
|
||||
add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA"))
|
||||
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_fov_hidden
|
||||
name = "game world fov hidden plane master"
|
||||
name = "lower game world fov hidden"
|
||||
documentation = "If you want something to be hidden by fov, stick it on this plane. We're masked by the fov blocker plane, so the items on us can actually well, disappear."
|
||||
plane = GAME_PLANE_FOV_HIDDEN
|
||||
render_relay_plane = GAME_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_fov_hidden/Initialize(mapload)
|
||||
. = ..()
|
||||
add_filter("vision_cone", 1, alpha_mask_filter(render_source = FIELD_OF_VISION_BLOCKER_RENDER_TARGET, flags = MASK_INVERSE))
|
||||
add_filter("vision_cone", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset), flags = MASK_INVERSE))
|
||||
|
||||
/atom/movable/screen/plane_master/field_of_vision_blocker
|
||||
name = "Field of vision blocker"
|
||||
documentation = "This is one of those planes that's only used as a filter. It masks out things that want to be hidden by fov.\
|
||||
<br>Literally just contains FOV images, or masks."
|
||||
plane = FIELD_OF_VISION_BLOCKER_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_target = FIELD_OF_VISION_BLOCKER_RENDER_TARGET
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
render_relay_planes = list()
|
||||
// We do NOT allow offsetting, because there's no case where you would want to block only one layer, at least currently
|
||||
allows_offsetting = FALSE
|
||||
start_hidden = TRUE
|
||||
// We mark as multiz_scaled FALSE so transforms don't effect us, and we draw to the planes below us as if they were us.
|
||||
// This is safe because we will ALWAYS be on the top z layer, so it DON'T MATTER
|
||||
multiz_scaled = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/field_of_vision_blocker/Initialize(mapload, datum/plane_master_group/home, offset)
|
||||
. = ..()
|
||||
mirror_parent_hidden()
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_upper
|
||||
name = "upper game world plane master"
|
||||
name = "Upper game world"
|
||||
documentation = "Ok so fov is kinda fucky, because planes in byond serve both as effect groupings and as rendering orderers. Since that's true, we need a plane that we can stick stuff that draws above fov blocked stuff on."
|
||||
plane = GAME_PLANE_UPPER
|
||||
render_relay_plane = GAME_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_upper_fov_hidden
|
||||
name = "upper game world fov hidden plane master"
|
||||
name = "Upper game world fov hidden"
|
||||
documentation = "Just as we need a place to draw things \"above\" the hidden fov plane, we also need to be able to hide stuff that draws over the upper game plane."
|
||||
plane = GAME_PLANE_UPPER_FOV_HIDDEN
|
||||
render_relay_plane = GAME_PLANE_FOV_HIDDEN
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_upper_fov_hidden/Initialize()
|
||||
. = ..()
|
||||
// Dupe of the other hidden plane
|
||||
add_filter("vision_cone", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(FIELD_OF_VISION_BLOCKER_RENDER_TARGET, offset), flags = MASK_INVERSE))
|
||||
|
||||
/atom/movable/screen/plane_master/seethrough
|
||||
name = "Seethrough"
|
||||
documentation = "Holds the seethrough versions (done using image overrides) of large objects. Mouse transparent, so you can click through them."
|
||||
plane = SEETHROUGH_PLANE
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
render_relay_planes = list(GAME_PLANE)
|
||||
start_hidden = TRUE
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_above
|
||||
name = "above game world plane master"
|
||||
name = "Above game world"
|
||||
documentation = "We need a place that's unmasked by fov that also draws above the upper game world fov hidden plane. I told you fov was hacky man."
|
||||
plane = ABOVE_GAME_PLANE
|
||||
render_relay_plane = GAME_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
/atom/movable/screen/plane_master/game_world_above_no_mouse
|
||||
name = "above game world no mouse plane master"
|
||||
plane = ABOVE_GAME_NO_MOUSE_PLANE
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
render_relay_plane = GAME_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
/atom/movable/screen/plane_master/massive_obj
|
||||
name = "massive object plane master"
|
||||
plane = MASSIVE_OBJ_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
/atom/movable/screen/plane_master/ghost
|
||||
name = "ghost plane master"
|
||||
plane = GHOST_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
|
||||
/atom/movable/screen/plane_master/point
|
||||
name = "point plane master"
|
||||
plane = POINT_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
|
||||
|
||||
/**
|
||||
* Plane master handling byond internal blackness
|
||||
* vars are set as to replicate behavior when rendering to other planes
|
||||
* do not touch this unless you know what you are doing
|
||||
*/
|
||||
// Blackness renders weird when you view down openspace, because of transforms and borders and such
|
||||
// This is a consequence of not using lummy's grouped transparency, but I couldn't get that to work without totally fucking up
|
||||
// Sight flags, and shooting vis_contents usage to the moon. So we're doin it different.
|
||||
// Look into lessening this, maybe mirror down all the time? idk
|
||||
// Part of the issue is it isn't actually the blackness plane, it's just normal blackness
|
||||
// (If image vis contents worked (it should in 515), and we were ok with a maptick cost (wait for threaded maptick)) this could be fixed
|
||||
/atom/movable/screen/plane_master/blackness
|
||||
name = "darkness plane master"
|
||||
name = "Darkness"
|
||||
documentation = "This is quite fiddly, so bear with me. By default (in byond) everything in the game is rendered onto plane 0. It's the default plane. \
|
||||
<br>But, because we've moved everything we control off plane 0, all that's left is stuff byond internally renders. \
|
||||
<br>What we're doing here is using plane 0 to capture \"Blackness\", or the mask that hides tiles. Note, this only works if our mob has the SEE_PIXELS or SEE_BLACKNESS sight flags.\
|
||||
<br>We relay this plane master (on plane 0) down to other copies of itself, depending on the layer your mob is on at the moment.\
|
||||
<br>Of note: plane master blackness, and the blackness that comes from having nothing to display look similar, but are not the same thing,\
|
||||
mind yourself when you're working with this plane, you might have accidentially been trying to work with the wrong thing."
|
||||
plane = BLACKNESS_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
// Note: we don't set this to blend multiply because it just dies when its alpha is modified, because of fun byond bugs
|
||||
// Marked as multiz_scaled = FALSE because it should not scale, scaling lets you see "through" the floor
|
||||
multiz_scaled = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/blackness/show_to(mob/mymob)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
if(offset != 0)
|
||||
// You aren't the source? don't change yourself
|
||||
return
|
||||
RegisterSignal(mymob, COMSIG_MOB_SIGHT_CHANGE, .proc/handle_sight_value)
|
||||
handle_sight_value(mymob, mymob.sight, 0)
|
||||
var/datum/hud/hud = home.our_hud
|
||||
if(hud)
|
||||
RegisterSignal(hud, COMSIG_HUD_OFFSET_CHANGED, .proc/on_offset_change)
|
||||
offset_change(0, hud.current_plane_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/blackness/hide_from(mob/oldmob)
|
||||
. = ..()
|
||||
if(offset != 0)
|
||||
return
|
||||
UnregisterSignal(oldmob, COMSIG_MOB_SIGHT_CHANGE)
|
||||
var/datum/hud/hud = home.our_hud
|
||||
if(hud)
|
||||
UnregisterSignal(hud, COMSIG_HUD_OFFSET_CHANGED, .proc/on_offset_change)
|
||||
|
||||
/// Reacts to some new plane master value
|
||||
/atom/movable/screen/plane_master/blackness/proc/handle_sight_value(datum/source, new_sight, old_sight)
|
||||
SIGNAL_HANDLER
|
||||
// Tryin to set a sight flag that cuts blackness eh?
|
||||
if(new_sight & BLACKNESS_CUTTING)
|
||||
// Better set alpha then, so it'll actually work
|
||||
// We just get the one because there is only one blackness PM, it's just mirrored around
|
||||
disable_alpha()
|
||||
else
|
||||
enable_alpha()
|
||||
|
||||
/atom/movable/screen/plane_master/blackness/proc/on_offset_change(datum/source, old_offset, new_offset)
|
||||
SIGNAL_HANDLER
|
||||
offset_change(old_offset, new_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/blackness/proc/offset_change(old_offset, new_offset)
|
||||
// Basically, the rule here is the blackness we harvest from the mob using the SEE_BLACKNESS flag will be relayed to the darkness
|
||||
// Plane that we're actually on
|
||||
if(old_offset != 0) // If our old target wasn't just ourselves
|
||||
remove_relay_from(GET_NEW_PLANE(plane, old_offset))
|
||||
|
||||
if(new_offset != 0)
|
||||
add_relay_to(GET_NEW_PLANE(plane, new_offset))
|
||||
|
||||
/atom/movable/screen/plane_master/area
|
||||
name = "Area"
|
||||
documentation = "Holds the areas themselves, which ends up meaning it holds any overlays/effects we apply to areas. NOT snow or rad storms, those go on above lighting"
|
||||
plane = AREA_PLANE
|
||||
|
||||
/atom/movable/screen/plane_master/massive_obj
|
||||
name = "Massive object"
|
||||
documentation = "Huge objects need to render above everything else on the game plane, otherwise they'd well, get clipped and look not that huge. This does that."
|
||||
plane = MASSIVE_OBJ_PLANE
|
||||
|
||||
/atom/movable/screen/plane_master/point
|
||||
name = "Point"
|
||||
documentation = "I mean like, what do you want me to say? Points draw over pretty much everything else, so they get their own plane. Remember we layer render relays to draw planes in their proper order on render plates."
|
||||
plane = POINT_PLANE
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
///Contains all turf lighting
|
||||
/atom/movable/screen/plane_master/turf_lighting
|
||||
name = "Turf Lighting"
|
||||
documentation = "Contains all lighting drawn to turfs. Not so complex, draws directly onto the lighting plate."
|
||||
plane = LIGHTING_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_relay_planes = list(RENDER_PLANE_LIGHTING)
|
||||
blend_mode_override = BLEND_ADD
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
/// This will not work through multiz, because of a byond bug with BLEND_MULTIPLY
|
||||
/// Bug report is up, waiting on a fix
|
||||
/atom/movable/screen/plane_master/o_light_visual
|
||||
name = "Overlight light visual"
|
||||
documentation = "Holds overlay lighting objects, or the sort of lighting that's a well, overlay stuck to something.\
|
||||
<br>Exists because lighting updating is really slow, and movement needs to feel smooth.\
|
||||
<br>We draw to the game plane, and mask out space for ourselves on the lighting plane so any color we have has the chance to display."
|
||||
plane = O_LIGHTING_VISUAL_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_target = O_LIGHTING_VISUAL_RENDER_TARGET
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
blend_mode = BLEND_MULTIPLY
|
||||
appearance_flags = PLANE_MASTER | NO_CLIENT_COLOR | PIXEL_SCALE
|
||||
//byond internal end
|
||||
|
||||
///Contains all lighting objects
|
||||
/atom/movable/screen/plane_master/lighting
|
||||
name = "lighting plane master"
|
||||
plane = LIGHTING_PLANE
|
||||
blend_mode_override = BLEND_MULTIPLY
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
|
||||
/atom/movable/screen/plane_master/lighting/backdrop(mob/mymob)
|
||||
. = ..()
|
||||
mymob.overlay_fullscreen("lighting_backdrop_lit", /atom/movable/screen/fullscreen/lighting_backdrop/lit)
|
||||
mymob.overlay_fullscreen("lighting_backdrop_unlit", /atom/movable/screen/fullscreen/lighting_backdrop/unlit)
|
||||
|
||||
/*!
|
||||
* This system works by exploiting BYONDs color matrix filter to use layers to handle emissive blockers.
|
||||
*
|
||||
* Emissive overlays are pasted with an atom color that converts them to be entirely some specific color.
|
||||
* Emissive blockers are pasted with an atom color that converts them to be entirely some different color.
|
||||
* Emissive overlays and emissive blockers are put onto the same plane.
|
||||
* The layers for the emissive overlays and emissive blockers cause them to mask eachother similar to normal BYOND objects.
|
||||
* A color matrix filter is applied to the emissive plane to mask out anything that isn't whatever the emissive color is.
|
||||
* This is then used to alpha mask the lighting plane.
|
||||
*/
|
||||
/atom/movable/screen/plane_master/lighting/Initialize(mapload)
|
||||
. = ..()
|
||||
add_filter("emissives", 1, alpha_mask_filter(render_source = EMISSIVE_RENDER_TARGET, flags = MASK_INVERSE))
|
||||
add_filter("object_lighting", 2, alpha_mask_filter(render_source = O_LIGHTING_VISUAL_RENDER_TARGET, flags = MASK_INVERSE))
|
||||
|
||||
/atom/movable/screen/plane_master/above_lighting
|
||||
name = "Above lighting"
|
||||
plane = ABOVE_LIGHTING_PLANE
|
||||
documentation = "Anything on the game plane that needs a space to draw on that will be above the lighting plane.\
|
||||
<br>Mostly little alerts and effects, also sometimes contains things that are meant to look as if they glow."
|
||||
|
||||
/**
|
||||
* Handles emissive overlays and emissive blockers.
|
||||
*/
|
||||
/atom/movable/screen/plane_master/emissive
|
||||
name = "emissive plane master"
|
||||
name = "Emissive"
|
||||
documentation = "This system works by exploiting BYONDs color matrix filter to use layers to handle emissive blockers.\
|
||||
<br>Emissive overlays are pasted with an atom color that converts them to be entirely some specific color.\
|
||||
<br>Emissive blockers are pasted with an atom color that converts them to be entirely some different color.\
|
||||
<br>Emissive overlays and emissive blockers are put onto the same plane (This one).\
|
||||
<br>The layers for the emissive overlays and emissive blockers cause them to mask eachother similar to normal BYOND objects.\
|
||||
<br>A color matrix filter is applied to the emissive plane to mask out anything that isn't whatever the emissive color is.\
|
||||
<br>This is then used to alpha mask the lighting plane."
|
||||
plane = EMISSIVE_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
render_target = EMISSIVE_RENDER_TARGET
|
||||
render_relay_plane = null
|
||||
render_relay_planes = list()
|
||||
|
||||
/atom/movable/screen/plane_master/emissive/Initialize(mapload)
|
||||
. = ..()
|
||||
add_filter("em_block_masking", 1, color_matrix_filter(GLOB.em_mask_matrix))
|
||||
|
||||
/atom/movable/screen/plane_master/above_lighting
|
||||
name = "above lighting plane master"
|
||||
plane = ABOVE_LIGHTING_PLANE
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
///Contains space parallax
|
||||
/atom/movable/screen/plane_master/parallax
|
||||
name = "parallax plane master"
|
||||
plane = PLANE_SPACE_PARALLAX
|
||||
blend_mode = BLEND_MULTIPLY
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
/atom/movable/screen/plane_master/parallax_white
|
||||
name = "parallax whitifier plane master"
|
||||
plane = PLANE_SPACE
|
||||
|
||||
/atom/movable/screen/plane_master/pipecrawl
|
||||
name = "pipecrawl plane master"
|
||||
name = "Pipecrawl"
|
||||
documentation = "Holds pipecrawl images generated during well, pipecrawling.\
|
||||
<br>Has a few effects and a funky color matrix designed to make things a bit more visually readable."
|
||||
plane = PIPECRAWL_IMAGES_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
start_hidden = TRUE
|
||||
|
||||
/atom/movable/screen/plane_master/pipecrawl/Initialize(mapload)
|
||||
. = ..()
|
||||
@@ -221,85 +463,99 @@
|
||||
color = list(1.2,0,0,0, 0,1.2,0,0, 0,0,1.2,0, 0,0,0,1, 0,0,0,0)
|
||||
// This serves a similar purpose, I want the pipes to pop
|
||||
add_filter("pipe_dropshadow", 1, drop_shadow_filter(x = -1, y= -1, size = 1, color = "#0000007A"))
|
||||
mirror_parent_hidden()
|
||||
|
||||
/atom/movable/screen/plane_master/camera_static
|
||||
name = "camera static plane master"
|
||||
name = "Camera static"
|
||||
documentation = "Holds camera static images. Usually only visible to people who can well, see static.\
|
||||
<br>We use images rather then vis contents because they're lighter on maptick, and maptick sucks butt."
|
||||
plane = CAMERA_STATIC_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
start_hidden = TRUE
|
||||
|
||||
/atom/movable/screen/plane_master/excited_turfs
|
||||
name = "atmos excited turfs"
|
||||
plane = ATMOS_GROUP_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
alpha = 0
|
||||
/atom/movable/screen/plane_master/camera_static/show_to(mob/mymob)
|
||||
// If we aren't an AI, we have no need for this plane master (most of the time, ai eyes are weird and annoying)
|
||||
if(force_hidden && isAI(mymob))
|
||||
unhide_plane(mymob)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
if(isAI(mymob))
|
||||
return
|
||||
return FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/o_light_visual
|
||||
name = "overlight light visual plane master"
|
||||
plane = O_LIGHTING_VISUAL_PLANE
|
||||
render_target = O_LIGHTING_VISUAL_RENDER_TARGET
|
||||
/atom/movable/screen/plane_master/high_game
|
||||
name = "High Game"
|
||||
documentation = "Holds anything that wants to be displayed above the rest of the game plane, and doesn't want to be clickable. \
|
||||
<br>This includes atmos debug overlays, blind sound images, and mining scanners. \
|
||||
<br>Really only exists for its layering potential, we don't use this for any vfx"
|
||||
plane = HIGH_GAME_PLANE
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
/atom/movable/screen/plane_master/ghost
|
||||
name = "Ghost"
|
||||
documentation = "Ghosts draw here, so they don't get mixed up in the visuals of the game world. Note, this is not not how we HIDE ghosts from people, that's done with invisible and see_invisible."
|
||||
plane = GHOST_PLANE
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
|
||||
/atom/movable/screen/plane_master/fullscreen
|
||||
name = "Fullscreen"
|
||||
documentation = "Holds anything that applies to or above the full screen. \
|
||||
<br>Note, it's still rendered underneath hud objects, but this lets us control the order that things like death/damage effects render in."
|
||||
plane = FULLSCREEN_PLANE
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
allows_offsetting = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/sound_effect_visual
|
||||
name = "Sound Effect Visuals"
|
||||
documentation = "Holds anything that is a game visual, but is displayed over fullscreen effects. \
|
||||
<br>Displayed over fullscreen effects, but still under runechat and the HUD."
|
||||
plane = SOUND_EFFECT_VISUAL_PLANE
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
blend_mode = BLEND_MULTIPLY
|
||||
blend_mode_override = BLEND_MULTIPLY
|
||||
|
||||
/atom/movable/screen/plane_master/runechat
|
||||
name = "runechat plane master"
|
||||
name = "Runechat"
|
||||
documentation = "Holds runechat images, that text that pops up when someone say something. Uses a dropshadow to well, look nice."
|
||||
plane = RUNECHAT_PLANE
|
||||
appearance_flags = PLANE_MASTER
|
||||
blend_mode = BLEND_OVERLAY
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
|
||||
/atom/movable/screen/plane_master/runechat/backdrop(mob/mymob)
|
||||
/atom/movable/screen/plane_master/runechat/show_to(mob/mymob)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
remove_filter("AO")
|
||||
if(istype(mymob) && mymob.client?.prefs?.read_preference(/datum/preference/toggle/ambient_occlusion))
|
||||
add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA"))
|
||||
|
||||
/atom/movable/screen/plane_master/gravpulse
|
||||
name = "gravpulse plane"
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
plane = GRAVITY_PULSE_PLANE
|
||||
blend_mode = BLEND_ADD
|
||||
blend_mode_override = BLEND_ADD
|
||||
render_target = GRAVITY_PULSE_RENDER_TARGET
|
||||
render_relay_plane = null
|
||||
|
||||
/atom/movable/screen/plane_master/area
|
||||
name = "area plane"
|
||||
plane = AREA_PLANE
|
||||
|
||||
/atom/movable/screen/plane_master/balloon_chat
|
||||
name = "balloon alert plane"
|
||||
name = "Balloon chat"
|
||||
documentation = "Holds ballon chat images, those little text bars that pop up for a second when you do some things. NOT runechat."
|
||||
plane = BALLOON_CHAT_PLANE
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
|
||||
/atom/movable/screen/plane_master/fullscreen
|
||||
name = "fullscreen alert plane"
|
||||
plane = FULLSCREEN_PLANE
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
/atom/movable/screen/plane_master/field_of_vision_blocker
|
||||
name = "field of vision blocker plane master"
|
||||
plane = FIELD_OF_VISION_BLOCKER_PLANE
|
||||
render_target = FIELD_OF_VISION_BLOCKER_RENDER_TARGET
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
render_relay_plane = null
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
|
||||
/atom/movable/screen/plane_master/hud
|
||||
name = "HUD plane"
|
||||
name = "HUD"
|
||||
documentation = "Contains anything that want to be rendered on the hud. Typically is just screen elements."
|
||||
plane = HUD_PLANE
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
allows_offsetting = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/above_hud
|
||||
name = "above HUD plane"
|
||||
name = "Above HUD"
|
||||
documentation = "Anything that wants to be drawn ABOVE the rest of the hud. Typically close buttons and other elements that need to be always visible. Think preventing draggable action button memes."
|
||||
plane = ABOVE_HUD_PLANE
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
allows_offsetting = FALSE
|
||||
|
||||
/atom/movable/screen/plane_master/splashscreen
|
||||
name = "splashscreen plane"
|
||||
name = "Splashscreen"
|
||||
documentation = "Anything that's drawn above LITERALLY everything else. Think cinimatics and the well, spashscreen."
|
||||
plane = SPLASHSCREEN_PLANE
|
||||
render_relay_plane = RENDER_PLANE_NON_GAME
|
||||
|
||||
|
||||
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
|
||||
render_relay_planes = list(RENDER_PLANE_NON_GAME)
|
||||
allows_offsetting = FALSE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///Atom that manages and controls multiple planes. It's an atom so we can hook into add_filter etc. Multiple controllers can control one plane.
|
||||
/atom/movable/plane_master_controller
|
||||
///List of planes in this controllers control. Initially this is a normal list, but becomes an assoc list of plane numbers as strings | plane instance
|
||||
///List of planes as defines in this controllers control
|
||||
var/list/controlled_planes = list()
|
||||
///hud that owns this controller
|
||||
var/datum/hud/owner_hud
|
||||
@@ -12,71 +12,68 @@ INITIALIZE_IMMEDIATE(/atom/movable/plane_master_controller)
|
||||
. = ..()
|
||||
if(!istype(hud))
|
||||
return
|
||||
|
||||
owner_hud = hud
|
||||
var/assoc_controlled_planes = list()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/instance = owner_hud.plane_masters["[i]"]
|
||||
if(!instance) //If we looked for a hud that isn't instanced, just keep going
|
||||
stack_trace("[i] isn't a valid plane master layer for [owner_hud.type], are you sure it exists in the first place?")
|
||||
continue
|
||||
assoc_controlled_planes["[i]"] = instance
|
||||
controlled_planes = assoc_controlled_planes
|
||||
|
||||
/atom/movable/plane_master_controller/proc/get_planes()
|
||||
var/returned_planes = list()
|
||||
for(var/true_plane in controlled_planes)
|
||||
returned_planes += get_true_plane(true_plane)
|
||||
return returned_planes
|
||||
|
||||
/atom/movable/plane_master_controller/proc/get_true_plane(true_plane)
|
||||
var/list/returned_planes = owner_hud.get_true_plane_masters(true_plane)
|
||||
if(!length(returned_planes)) //If we looked for a hud that isn't instanced, just keep going
|
||||
stack_trace("[plane] isn't a valid plane master layer for [owner_hud.type], are you sure it exists in the first place?")
|
||||
return
|
||||
|
||||
return returned_planes
|
||||
|
||||
///Full override so we can just use filterrific
|
||||
/atom/movable/plane_master_controller/add_filter(name, priority, list/params)
|
||||
. = ..()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.add_filter(name, priority, params)
|
||||
|
||||
///Full override so we can just use filterrific
|
||||
/atom/movable/plane_master_controller/remove_filter(name_or_names)
|
||||
. = ..()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.remove_filter(name_or_names)
|
||||
|
||||
/atom/movable/plane_master_controller/update_filters()
|
||||
. = ..()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.update_filters()
|
||||
|
||||
///Gets all filters for this controllers plane masters
|
||||
/atom/movable/plane_master_controller/proc/get_filters(name)
|
||||
. = list()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
. += pm_iterator.get_filter(name)
|
||||
|
||||
///Transitions all filters owned by this plane master controller
|
||||
/atom/movable/plane_master_controller/transition_filter(name, time, list/new_params, easing, loop)
|
||||
. = ..()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.transition_filter(name, time, new_params, easing, loop)
|
||||
|
||||
///Full override so we can just use filterrific
|
||||
/atom/movable/plane_master_controller/add_atom_colour(coloration, colour_priority)
|
||||
. = ..()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.add_atom_colour(coloration, colour_priority)
|
||||
|
||||
|
||||
///Removes an instance of colour_type from the atom's atom_colours list
|
||||
/atom/movable/plane_master_controller/remove_atom_colour(colour_priority, coloration)
|
||||
. = ..()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.remove_atom_colour(colour_priority, coloration)
|
||||
|
||||
|
||||
///Resets the atom's color to null, and then sets it to the highest priority colour available
|
||||
/atom/movable/plane_master_controller/update_atom_colour()
|
||||
for(var/i in controlled_planes)
|
||||
var/atom/movable/screen/plane_master/pm_iterator = controlled_planes[i]
|
||||
for(var/atom/movable/screen/plane_master/pm_iterator as anything in get_planes())
|
||||
pm_iterator.update_atom_colour()
|
||||
|
||||
|
||||
@@ -84,7 +81,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/plane_master_controller)
|
||||
name = PLANE_MASTERS_GAME
|
||||
controlled_planes = list(
|
||||
FLOOR_PLANE,
|
||||
TRANSPARENT_FLOOR_PLANE,
|
||||
RENDER_PLANE_TRANSPARENT,
|
||||
GAME_PLANE,
|
||||
GAME_PLANE_FOV_HIDDEN,
|
||||
GAME_PLANE_UPPER,
|
||||
@@ -108,7 +105,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/plane_master_controller)
|
||||
GAME_PLANE_FOV_HIDDEN,
|
||||
GAME_PLANE_UPPER,
|
||||
GAME_PLANE_UPPER_FOV_HIDDEN,
|
||||
ABOVE_GAME_NO_MOUSE_PLANE,
|
||||
SEETHROUGH_PLANE,
|
||||
ABOVE_GAME_PLANE,
|
||||
MASSIVE_OBJ_PLANE,
|
||||
GHOST_PLANE,
|
||||
@@ -118,8 +115,9 @@ INITIALIZE_IMMEDIATE(/atom/movable/plane_master_controller)
|
||||
ABOVE_LIGHTING_PLANE,
|
||||
CAMERA_STATIC_PLANE,
|
||||
PIPECRAWL_IMAGES_PLANE,
|
||||
ATMOS_GROUP_PLANE,
|
||||
HIGH_GAME_PLANE,
|
||||
FULLSCREEN_PLANE,
|
||||
SOUND_EFFECT_VISUAL_PLANE,
|
||||
RUNECHAT_PLANE,
|
||||
HUD_PLANE,
|
||||
ABOVE_HUD_PLANE,
|
||||
|
||||
153
code/_onclick/hud/rendering/plane_master_group.dm
Normal file
153
code/_onclick/hud/rendering/plane_master_group.dm
Normal file
@@ -0,0 +1,153 @@
|
||||
/// Datum that represents one "group" of plane masters
|
||||
/// So all the main window planes would be in one, all the spyglass planes in another
|
||||
/// Etc
|
||||
/datum/plane_master_group
|
||||
/// Our key in the group list on /datum/hud
|
||||
/// Should be unique for any group of plane masters in the world
|
||||
var/key
|
||||
/// Our parent hud
|
||||
var/datum/hud/our_hud
|
||||
/// List in the form "[plane]" = object, the plane masters we own
|
||||
var/list/atom/movable/screen/plane_master/plane_masters = list()
|
||||
/// The visual offset we are currently using
|
||||
var/active_offset = 0
|
||||
|
||||
/// What, if any, submap we render onto
|
||||
var/map = ""
|
||||
|
||||
/datum/plane_master_group/New(key, map = "")
|
||||
. = ..()
|
||||
src.key = key
|
||||
src.map = map
|
||||
build_plane_masters(0, SSmapping.max_plane_offset)
|
||||
|
||||
/datum/plane_master_group/Destroy()
|
||||
orphan_hud()
|
||||
QDEL_LIST_ASSOC_VAL(plane_masters)
|
||||
return ..()
|
||||
|
||||
/// Display a plane master group to some viewer, so show all our planes to it
|
||||
/datum/plane_master_group/proc/attach_to(datum/hud/viewing_hud)
|
||||
if(viewing_hud.master_groups[key])
|
||||
stack_trace("Hey brother, our key [key] is already in use by a plane master group on the passed in hud, belonging to [viewing_hud.mymob]. Ya fucked up, why are there dupes")
|
||||
return
|
||||
|
||||
our_hud = viewing_hud
|
||||
our_hud.master_groups[key] = src
|
||||
show_hud()
|
||||
transform_lower_turfs(our_hud, active_offset)
|
||||
|
||||
/// Hide the plane master from its current hud, fully clear it out
|
||||
/datum/plane_master_group/proc/orphan_hud()
|
||||
if(our_hud)
|
||||
our_hud.master_groups -= key
|
||||
hide_hud()
|
||||
our_hud = null
|
||||
|
||||
/// Well, refresh our group, mostly useful for plane specific updates
|
||||
/datum/plane_master_group/proc/refresh_hud()
|
||||
hide_hud()
|
||||
show_hud()
|
||||
|
||||
/// Fully regenerate our group, resetting our planes to their compile time values
|
||||
/datum/plane_master_group/proc/rebuild_hud()
|
||||
hide_hud()
|
||||
QDEL_LIST_ASSOC_VAL(plane_masters)
|
||||
build_plane_masters(0, SSmapping.max_plane_offset)
|
||||
show_hud()
|
||||
transform_lower_turfs(our_hud, active_offset)
|
||||
|
||||
/datum/plane_master_group/proc/hide_hud()
|
||||
for(var/thing in plane_masters)
|
||||
var/atom/movable/screen/plane_master/plane = plane_masters[thing]
|
||||
plane.hide_from(our_hud.mymob)
|
||||
|
||||
/datum/plane_master_group/proc/show_hud()
|
||||
for(var/thing in plane_masters)
|
||||
var/atom/movable/screen/plane_master/plane = plane_masters[thing]
|
||||
show_plane(plane)
|
||||
|
||||
/// This is mostly a proc so it can be overriden by popups, since they have unique behavior they want to do
|
||||
/datum/plane_master_group/proc/show_plane(atom/movable/screen/plane_master/plane)
|
||||
plane.show_to(our_hud.mymob)
|
||||
|
||||
/// Returns a list of all the plane master types we want to create
|
||||
/datum/plane_master_group/proc/get_plane_types()
|
||||
return subtypesof(/atom/movable/screen/plane_master) - /atom/movable/screen/plane_master/rendering_plate
|
||||
|
||||
/// Actually generate our plane masters, in some offset range (where offset is the z layers to render to, because each "layer" in a multiz stack gets its own plane master cube)
|
||||
/datum/plane_master_group/proc/build_plane_masters(starting_offset, ending_offset)
|
||||
for(var/atom/movable/screen/plane_master/mytype as anything in get_plane_types())
|
||||
for(var/plane_offset in starting_offset to ending_offset)
|
||||
if(plane_offset != 0 && !initial(mytype.allows_offsetting))
|
||||
continue
|
||||
var/atom/movable/screen/plane_master/instance = new mytype(null, src, plane_offset)
|
||||
plane_masters["[instance.plane]"] = instance
|
||||
prep_plane_instance(instance)
|
||||
|
||||
/// Similarly, exists so subtypes can do unique behavior to planes on creation
|
||||
/datum/plane_master_group/proc/prep_plane_instance(atom/movable/screen/plane_master/instance)
|
||||
return
|
||||
|
||||
// It would be nice to setup parallaxing for stairs and things when doing this
|
||||
// So they look nicer. if you can't it's all good, if you think you can sanely look at monster's work
|
||||
// It's hard, and potentially expensive. be careful
|
||||
/datum/plane_master_group/proc/transform_lower_turfs(datum/hud/source, new_offset, use_scale = TRUE)
|
||||
// No offset? piss off
|
||||
if(!SSmapping.max_plane_offset)
|
||||
return
|
||||
active_offset = new_offset
|
||||
// Each time we go "down" a visual z level, we'll reduce the scale by this amount
|
||||
// Chosen because mothblocks liked it, didn't cause motion sickness while also giving a sense of height
|
||||
var/scale_by = 0.965
|
||||
// If our mob can see through walls
|
||||
if(!use_scale)
|
||||
// This is a workaround for two things
|
||||
// First of all, if a mob can see objects but not turfs, they will not be shown the holder objects we use for
|
||||
// What I'd like to do is revert to images if this case throws, but image vis_contents is broken
|
||||
// https://www.byond.com/forum/post/2821969
|
||||
// If that's ever fixed, please just use that. thanks :)
|
||||
scale_by = 1
|
||||
|
||||
var/list/offsets = list()
|
||||
// We accept negatives so going down "zooms" away the drop above as it goes
|
||||
for(var/offset in -SSmapping.max_plane_offset to SSmapping.max_plane_offset)
|
||||
// No transformations if we're landing ON you
|
||||
if(offset == 0)
|
||||
offsets += null
|
||||
continue
|
||||
var/scale = scale_by ** (offset)
|
||||
var/matrix/multiz_shrink = matrix()
|
||||
multiz_shrink.Scale(scale)
|
||||
offsets += multiz_shrink
|
||||
|
||||
// So we can talk in 1 -> max_offset * 2 + 1, rather then -max_offset -> max_offset
|
||||
var/offset_offset = SSmapping.max_plane_offset + 1
|
||||
|
||||
for(var/plane_key in plane_masters)
|
||||
var/atom/movable/screen/plane_master/plane = plane_masters[plane_key]
|
||||
if(!plane.multiz_scaled || !plane.allows_offsetting)
|
||||
continue
|
||||
var/visual_offset = plane.offset - new_offset
|
||||
if(plane.force_hidden || visual_offset < 0)
|
||||
// We don't animate here because it should be invisble, but we do mark because it'll look nice
|
||||
plane.transform = offsets[visual_offset + offset_offset]
|
||||
continue
|
||||
animate(plane, transform = offsets[visual_offset + offset_offset], 0.05 SECONDS, easing = LINEAR_EASING)
|
||||
|
||||
/// Holds plane masters for popups, like camera windows
|
||||
/// Note: We do not scale this plane, even though we could
|
||||
/// This is because it's annoying to get turfs to position inside it correctly
|
||||
/// If you wanna try someday feel free, but I can't manage it
|
||||
/datum/plane_master_group/popup
|
||||
|
||||
/datum/plane_master_group/popup/transform_lower_turfs(datum/hud/source, new_offset, use_scale = TRUE)
|
||||
return ..(source, new_offset, FALSE)
|
||||
|
||||
/// Holds the main plane master
|
||||
/datum/plane_master_group/main
|
||||
|
||||
/datum/plane_master_group/main/transform_lower_turfs(datum/hud/source, new_offset, use_scale = TRUE)
|
||||
if(use_scale)
|
||||
return ..(source, new_offset, source.should_use_scale())
|
||||
return ..()
|
||||
@@ -24,61 +24,264 @@
|
||||
* remember that once planes are unified on a render plate you cant change the layering of them!
|
||||
*/
|
||||
/atom/movable/screen/plane_master/rendering_plate
|
||||
name = "default rendering plate"
|
||||
|
||||
name = "Default rendering plate"
|
||||
multiz_scaled = FALSE
|
||||
|
||||
///this plate renders the final screen to show to the player
|
||||
/atom/movable/screen/plane_master/rendering_plate/master
|
||||
name = "master rendering plate"
|
||||
name = "Master rendering plate"
|
||||
documentation = "The endpoint of all plane masters, you can think of this as the final \"view\" we draw.\
|
||||
<br>If offset is not 0 this will be drawn to the transparent plane of the floor above, but otherwise this is drawn to nothing, or shown to the player."
|
||||
plane = RENDER_PLANE_MASTER
|
||||
render_relay_plane = null
|
||||
generate_render_target = FALSE
|
||||
render_relay_planes = list()
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/master/show_to(mob/mymob)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
if(offset == 0)
|
||||
return
|
||||
// Non 0 offset render plates will relay up to the transparent plane above them, assuming they're not on the same z level as their target of course
|
||||
var/datum/hud/hud = home.our_hud
|
||||
if(hud)
|
||||
RegisterSignal(hud, COMSIG_HUD_OFFSET_CHANGED, .proc/on_offset_change)
|
||||
offset_change(hud.current_plane_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/master/hide_from(mob/oldmob)
|
||||
. = ..()
|
||||
if(offset == 0)
|
||||
return
|
||||
var/datum/hud/hud = home.our_hud
|
||||
if(hud)
|
||||
UnregisterSignal(hud, COMSIG_HUD_OFFSET_CHANGED, .proc/on_offset_change)
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/master/proc/on_offset_change(datum/source, old_offset, new_offset)
|
||||
SIGNAL_HANDLER
|
||||
offset_change(new_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/master/proc/offset_change(new_offset)
|
||||
if(new_offset == offset) // If we're on our own z layer, relay to nothing, just draw
|
||||
remove_relay_from(GET_NEW_PLANE(RENDER_PLANE_TRANSPARENT, offset - 1))
|
||||
else // Otherwise, regenerate the relay
|
||||
add_relay_to(GET_NEW_PLANE(RENDER_PLANE_TRANSPARENT, offset - 1))
|
||||
|
||||
///renders general in charachter game objects
|
||||
/atom/movable/screen/plane_master/rendering_plate/game_world
|
||||
name = "game rendering plate"
|
||||
/atom/movable/screen/plane_master/rendering_plate/game_plate
|
||||
name = "Game rendering plate"
|
||||
documentation = "Holds all objects that are ahhh, in character? is maybe the best way to describe it.\
|
||||
<br>We apply a displacement effect from the gravity pulse plane too, so we can warp the game world."
|
||||
plane = RENDER_PLANE_GAME
|
||||
render_relay_plane = RENDER_PLANE_MASTER
|
||||
render_relay_planes = list(RENDER_PLANE_MASTER)
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/game_world/Initialize(mapload)
|
||||
/atom/movable/screen/plane_master/rendering_plate/game_plate/Initialize(mapload)
|
||||
. = ..()
|
||||
add_filter("displacer", 1, displacement_map_filter(render_source = GRAVITY_PULSE_RENDER_TARGET, size = 10))
|
||||
add_filter("displacer", 1, displacement_map_filter(render_source = OFFSET_RENDER_TARGET(GRAVITY_PULSE_RENDER_TARGET, offset), size = 10))
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/transparent
|
||||
name = "Transparent plate"
|
||||
documentation = "The master rendering plate from the offset below ours will be mirrored onto this plane. That way we achive a \"stack\" effect.\
|
||||
<br>This plane exists to uplayer the master rendering plate to the correct spot in our z layer's rendering order"
|
||||
plane = RENDER_PLANE_TRANSPARENT
|
||||
appearance_flags = PLANE_MASTER
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/transparent/Initialize(mapload, datum/plane_master_group/home, offset)
|
||||
. = ..()
|
||||
// Don't display us if we're below everything else yeah?
|
||||
AddComponent(/datum/component/plane_hide_highest_offset)
|
||||
color = list(0.9,0,0,0, 0,0.9,0,0, 0,0,0.9,0, 0,0,0,1, 0,0,0,0)
|
||||
|
||||
///Contains most things in the game world
|
||||
/atom/movable/screen/plane_master/rendering_plate/game_world
|
||||
name = "Game world plate"
|
||||
documentation = "Contains most of the objects in the world. Mobs, machines, etc. Note the drop shadow, it gives a very nice depth effect."
|
||||
plane = RENDER_PLANE_GAME_WORLD
|
||||
appearance_flags = PLANE_MASTER //should use client color
|
||||
blend_mode = BLEND_OVERLAY
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/game_world/show_to(mob/mymob)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
remove_filter("AO")
|
||||
if(istype(mymob) && mymob.client?.prefs?.read_preference(/datum/preference/toggle/ambient_occlusion))
|
||||
add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA"))
|
||||
|
||||
///Contains all lighting objects
|
||||
/atom/movable/screen/plane_master/rendering_plate/lighting
|
||||
name = "Lighting plate"
|
||||
documentation = "Anything on this plane will be <b>multiplied</b> with the plane it's rendered onto (typically the game plane).\
|
||||
<br>That's how lighting functions at base. Because it uses BLEND_MULTIPLY and occasionally color matrixes, it needs a backdrop of blackness.\
|
||||
<br>See <a href=\"https://secure.byond.com/forum/?post=2141928\">This byond post</a>\
|
||||
<br>Lemme see uh, we're masked by the emissive plane so it can actually function (IE: make things glow in the dark).\
|
||||
<br>We're also masked by the overlay lighting plane, which contains all the movable lights in the game. It draws to us and also the game plane.\
|
||||
<br>Masks us out so it has the breathing room to apply its effect.\
|
||||
<br>Oh and we quite often have our alpha changed to achive night vision effects, or things of that sort."
|
||||
plane = RENDER_PLANE_LIGHTING
|
||||
blend_mode_override = BLEND_MULTIPLY
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/lighting/show_to(mob/mymob)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
// This applies a backdrop to our lighting plane
|
||||
// Why do plane masters need a backdrop sometimes? Read https://secure.byond.com/forum/?post=2141928
|
||||
// Basically, we need something to brighten
|
||||
// unlit is perhaps less needed rn, it exists to provide a fullbright for things that can't see the lighting plane
|
||||
// but we don't actually use invisibility to hide the lighting plane anymore, so it's pointless
|
||||
mymob.overlay_fullscreen("lighting_backdrop_lit", /atom/movable/screen/fullscreen/lighting_backdrop/lit)
|
||||
mymob.overlay_fullscreen("lighting_backdrop_unlit", /atom/movable/screen/fullscreen/lighting_backdrop/unlit)
|
||||
|
||||
// Sorry, this is a bit annoying
|
||||
// Basically, we only want the lighting plane we can actually see to attempt to render
|
||||
// If we don't our lower plane gets totally overriden by the black void of the upper plane
|
||||
var/datum/hud/hud = home.our_hud
|
||||
if(hud)
|
||||
RegisterSignal(hud, COMSIG_HUD_OFFSET_CHANGED, .proc/on_offset_change)
|
||||
offset_change(hud.current_plane_offset)
|
||||
set_alpha(mymob.lighting_alpha)
|
||||
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/lighting/hide_from(mob/oldmob)
|
||||
. = ..()
|
||||
oldmob.clear_fullscreen("lighting_backdrop_lit")
|
||||
oldmob.clear_fullscreen("lighting_backdrop_unlit")
|
||||
var/datum/hud/hud = home.our_hud
|
||||
if(hud)
|
||||
UnregisterSignal(hud, COMSIG_HUD_OFFSET_CHANGED, .proc/on_offset_change)
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/lighting/proc/on_offset_change(datum/source, old_offset, new_offset)
|
||||
SIGNAL_HANDLER
|
||||
offset_change(new_offset)
|
||||
|
||||
/atom/movable/screen/plane_master/rendering_plate/lighting/proc/offset_change(mob_offset)
|
||||
// Offsets stack down remember. This implies that we're above the mob's view plane, and shouldn't render
|
||||
if(offset < mob_offset)
|
||||
disable_alpha()
|
||||
else
|
||||
enable_alpha()
|
||||
|
||||
/*!
|
||||
* This system works by exploiting BYONDs color matrix filter to use layers to handle emissive blockers.
|
||||
*
|
||||
* Emissive overlays are pasted with an atom color that converts them to be entirely some specific color.
|
||||
* Emissive blockers are pasted with an atom color that converts them to be entirely some different color.
|
||||
* Emissive overlays and emissive blockers are put onto the same plane.
|
||||
* The layers for the emissive overlays and emissive blockers cause them to mask eachother similar to normal BYOND objects.
|
||||
* A color matrix filter is applied to the emissive plane to mask out anything that isn't whatever the emissive color is.
|
||||
* This is then used to alpha mask the lighting plane.
|
||||
*/
|
||||
/atom/movable/screen/plane_master/rendering_plate/lighting/Initialize(mapload)
|
||||
. = ..()
|
||||
add_filter("emissives", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(EMISSIVE_RENDER_TARGET, offset), flags = MASK_INVERSE))
|
||||
add_filter("object_lighting", 2, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(O_LIGHTING_VISUAL_RENDER_TARGET, offset), flags = MASK_INVERSE))
|
||||
|
||||
///render plate for OOC stuff like ghosts, hud-screen effects, etc
|
||||
/atom/movable/screen/plane_master/rendering_plate/non_game
|
||||
name = "non-game rendering plate"
|
||||
name = "Non-Game rendering plate"
|
||||
documentation = "Renders anything that's out of character. Mostly useful as a converse to the game rendering plate."
|
||||
plane = RENDER_PLANE_NON_GAME
|
||||
render_relay_plane = RENDER_PLANE_MASTER
|
||||
render_relay_planes = list(RENDER_PLANE_MASTER)
|
||||
|
||||
|
||||
/**
|
||||
* Plane master proc called in backdrop() that creates a relay object, sets it as needed and then adds it to the clients screen
|
||||
* Plane master proc called in Initialize() that creates relay objects, and sets them uo as needed
|
||||
* Sets:
|
||||
* * layer from plane to avoid z-fighting
|
||||
* * plane to relay the render to
|
||||
* * render_source so that the plane will render on this object
|
||||
* * planes to relay the render to
|
||||
* * render_source so that the plane will render on these objects
|
||||
* * mouse opacity to ensure proper mouse hit tracking
|
||||
* * name for debugging purposes
|
||||
* Other vars such as alpha will automatically be applied with the render source
|
||||
* Arguments:
|
||||
* * mymob: mob whose plane is being backdropped
|
||||
* * relay_plane: plane we are relaying this plane master to
|
||||
*/
|
||||
/atom/movable/screen/plane_master/proc/relay_render_to_plane(mob/mymob, relay_plane)
|
||||
if(relay in mymob.client.screen) //backdrop can be called multiple times
|
||||
return
|
||||
if(!render_target && generate_render_target)
|
||||
render_target = "*[name]: AUTOGENERATED RENDER TGT"
|
||||
relay = new()
|
||||
relay.render_source = render_target
|
||||
relay.plane = relay_plane
|
||||
relay.layer = (plane + abs(LOWEST_EVER_PLANE))*0.5 //layer must be positive but can be a decimal
|
||||
if(blend_mode_override)
|
||||
relay.blend_mode = blend_mode_override
|
||||
else
|
||||
relay.blend_mode = blend_mode
|
||||
relay.mouse_opacity = mouse_opacity
|
||||
relay.name = render_target
|
||||
mymob.client.screen += relay
|
||||
/atom/movable/screen/plane_master/proc/generate_render_relays()
|
||||
var/relay_loc = "CENTER"
|
||||
// If we're using a submap (say for a popup window) make sure we draw onto it
|
||||
if(home?.map)
|
||||
relay_loc = "[home.map]:[relay_loc]"
|
||||
|
||||
var/list/generated_planes = list()
|
||||
for(var/atom/movable/render_plane_relay/relay as anything in relays)
|
||||
generated_planes += relay.plane
|
||||
|
||||
for(var/relay_plane in (render_relay_planes - generated_planes))
|
||||
generate_relay_to(relay_plane, relay_loc)
|
||||
|
||||
if(blend_mode != BLEND_MULTIPLY)
|
||||
blend_mode = BLEND_DEFAULT
|
||||
relays_generated = TRUE
|
||||
|
||||
/// Creates a connection between this plane master and the passed in plane
|
||||
/// Helper for out of system code, shouldn't be used in this file
|
||||
/// Build system to differenchiate between generated and non generated render relays
|
||||
/atom/movable/screen/plane_master/proc/add_relay_to(target_plane, blend_override)
|
||||
if(get_relay_to(target_plane))
|
||||
return
|
||||
render_relay_planes += target_plane
|
||||
if(!relays_generated && isnull(blend_override))
|
||||
return
|
||||
var/client/display_lad = home?.our_hud?.mymob?.client
|
||||
generate_relay_to(target_plane, show_to = display_lad, blend_override = blend_override)
|
||||
|
||||
/proc/get_plane_master_render_base(name)
|
||||
return "*[name]: AUTOGENERATED RENDER TGT"
|
||||
|
||||
/atom/movable/screen/plane_master/proc/generate_relay_to(target_plane, relay_loc, client/show_to, blend_override)
|
||||
if(!length(relays) && !initial(render_target))
|
||||
render_target = OFFSET_RENDER_TARGET(get_plane_master_render_base(name), offset)
|
||||
if(!relay_loc)
|
||||
relay_loc = "CENTER"
|
||||
// If we're using a submap (say for a popup window) make sure we draw onto it
|
||||
if(home?.map)
|
||||
relay_loc = "[home.map]:[relay_loc]"
|
||||
var/blend_to_use = blend_override
|
||||
if(isnull(blend_to_use))
|
||||
blend_to_use = blend_mode_override || initial(blend_mode)
|
||||
|
||||
var/atom/movable/render_plane_relay/relay = new()
|
||||
relay.render_source = render_target
|
||||
relay.plane = target_plane
|
||||
relay.screen_loc = relay_loc
|
||||
// There are two rules here
|
||||
// 1: layer needs to be positive (negative layers are treated as float layers)
|
||||
// 2: lower planes (including offset ones) need to be layered below higher ones (because otherwise they'll render fucky)
|
||||
// By multiplying LOWEST_EVER_PLANE by 30, we give 30 offsets worth of room to planes before they start going negative
|
||||
// Bet
|
||||
relay.layer = (plane + abs(LOWEST_EVER_PLANE * 30)) //layer must be positive but can be a decimal
|
||||
relay.blend_mode = blend_to_use
|
||||
relay.mouse_opacity = mouse_opacity
|
||||
relay.name = render_target
|
||||
relays += relay
|
||||
// Relays are sometimes generated early, before huds have a mob to display stuff to
|
||||
// That's what this is for
|
||||
if(show_to)
|
||||
show_to.screen += relay
|
||||
return relay
|
||||
|
||||
/// Breaks a connection between this plane master, and the passed in place
|
||||
/atom/movable/screen/plane_master/proc/remove_relay_from(target_plane)
|
||||
render_relay_planes -= target_plane
|
||||
var/atom/movable/render_plane_relay/existing_relay = get_relay_to(target_plane)
|
||||
if(!existing_relay)
|
||||
return
|
||||
relays -= existing_relay
|
||||
if(!length(relays) && !initial(render_target))
|
||||
render_target = null
|
||||
var/client/lad = home?.our_hud?.mymob?.client
|
||||
if(lad)
|
||||
lad.screen -= existing_relay
|
||||
|
||||
/// Gets the relay atom we're using to connect to the target plane, if one exists
|
||||
/atom/movable/screen/plane_master/proc/get_relay_to(target_plane)
|
||||
for(var/atom/movable/render_plane_relay/relay in relays)
|
||||
if(relay.plane == target_plane)
|
||||
return relay
|
||||
|
||||
return null
|
||||
|
||||
/// Basically, trigger a full hud rebuild so our relays will be added to the screen
|
||||
/// I hate hud code
|
||||
/atom/movable/screen/plane_master/proc/rebuild_relays()
|
||||
relays = list()
|
||||
var/datum/hud/hud = home.our_hud
|
||||
hud.show_hud(hud.hud_version)
|
||||
|
||||
Reference in New Issue
Block a user