-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #530 from dwasint/i-can-see-god
gods all seeing eye gazes down at me
- Loading branch information
Showing
19 changed files
with
346 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// A list that caches base appearances of triangles for later access. | ||
GLOBAL_LIST_EMPTY(triangle_appearances) | ||
|
||
/// Returns a mutable appearance of a triangle of the given points, and caches it for later use | ||
/proc/get_triangle_appearance(x1,y1, x2,y2, x3,y3, icon_size = 32, icon = 'monkestation/code/modules/shadowcasting/icons/geometric.dmi', icon_state = "triangle") | ||
var/key = "[x1]_[y2]_[x2]_[y2]_[x3]_[y3]_[icon_size]_[icon]_[icon_state]" | ||
if(GLOB.triangle_appearances[key]) | ||
return GLOB.triangle_appearances[key] | ||
var/mutable_appearance/triangle_appearance = mutable_appearance(icon, icon_state) | ||
triangle_appearance.transform = transform_triangle(x1,y1, x2,y2, x3,y3, icon_size) | ||
GLOB.triangle_appearances[key] = triangle_appearance | ||
return triangle_appearance | ||
|
||
/// Returns a matrix which when applied to a proper triangle image, creates an arbitrary triangle | ||
/proc/transform_triangle(x1, y1, x2, y2, x3, y3, icon_size = 32) | ||
var/i = 1/icon_size | ||
var/a = (x3*i)-(x2*i) | ||
var/b = -(x2*i)+(x1*i) | ||
var/c = (x3*0.5)+(x1*0.5) | ||
var/d = (y1*i)-(y2*i) | ||
var/e = -(y2*i)+(y3*i) | ||
var/f = (y1*0.5)+(y3*0.5) | ||
return matrix(a,b,c,e,d,f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/mob | ||
///Should the mob use the shadowcasting component when a client is logged to it? | ||
var/shadow_caster = FALSE | ||
|
||
|
||
/mob/proc/update_shadowcasting() | ||
if(!shadow_caster || !client) | ||
return | ||
for(var/atom/movable/screen/plane_master/plane_master as anything in hud_used.get_true_plane_masters(SHADOWCASTING_PLANE)) | ||
plane_master.alpha = 96 | ||
for(var/atom/movable/screen/plane_master/plane_master as anything in hud_used.get_true_plane_masters(SHADOWCASTING_PLANE)) | ||
plane_master.add_filter("blur", 2, gauss_blur_filter(size = 3)) | ||
var/datum/component/shadowcasting = GetComponent(/datum/component/shadowcasting) | ||
if(!shadowcasting) | ||
AddComponent(/datum/component/shadowcasting) |
42 changes: 42 additions & 0 deletions
42
monkestation/code/modules/shadowcasting/_shadow_controller.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* This subsystem updates shadowcasting overlays for updates not caused by mob movement. | ||
*/ | ||
SUBSYSTEM_DEF(shadowcasting) | ||
name = "Shadowcasting" | ||
wait = 2 | ||
init_order = INIT_ORDER_SHADOWCASTING | ||
flags = SS_TICKER | ||
var/static/list/turf/turf_queue = list() | ||
|
||
/datum/controller/subsystem/shadowcasting/stat_entry(msg) | ||
msg = "T:[length(turf_queue)]|" | ||
return ..() | ||
|
||
/datum/controller/subsystem/shadowcasting/Initialize() | ||
fire(FALSE, TRUE) | ||
initialized = TRUE | ||
|
||
return SS_INIT_SUCCESS | ||
|
||
/datum/controller/subsystem/shadowcasting/fire(resumed, init_tick_checks) | ||
MC_SPLIT_TICK_INIT(3) | ||
if(!init_tick_checks) | ||
MC_SPLIT_TICK | ||
|
||
var/list/queue = turf_queue | ||
var/i = 0 | ||
for (i in 1 to length(queue)) | ||
var/turf/shadow_source = queue[i] | ||
|
||
shadow_source.update_shadowcasting() | ||
|
||
if(init_tick_checks) | ||
CHECK_TICK | ||
else if (MC_TICK_CHECK) | ||
break | ||
if (i) | ||
queue.Cut(1, i+1) | ||
|
||
/datum/controller/subsystem/shadowcasting/Recover() | ||
initialized = SSshadowcasting.initialized | ||
return ..() |
Binary file not shown.
95 changes: 95 additions & 0 deletions
95
monkestation/code/modules/shadowcasting/shadow_component.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// lots of ctrl c ctrl v from fov component no fucks given | ||
/datum/component/shadowcasting | ||
/// Whether we are applying the masks now or not | ||
var/applied_shadow = FALSE | ||
/// Atom that shows shadowcasting overlays | ||
var/atom/movable/shadowcasting_holder/visual_shadow | ||
|
||
/datum/component/shadowcasting/Initialize() | ||
. = ..() | ||
if(!ismob(parent)) | ||
return COMPONENT_INCOMPATIBLE | ||
var/mob/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 | ||
|
||
for(var/atom/movable/screen/plane_master/plane_master as anything in mob_parent.hud_used.get_true_plane_masters(SHADOWCASTING_PLANE)) | ||
plane_master.unhide_plane(mob_parent) | ||
|
||
visual_shadow = new | ||
update_shadow() | ||
|
||
/datum/component/shadowcasting/RegisterWithParent() | ||
. = ..() | ||
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(update_shadow)) | ||
RegisterSignal(parent, COMSIG_MOB_RESET_PERSPECTIVE, PROC_REF(update_shadow)) | ||
RegisterSignal(parent, COMSIG_MOB_SIGHT_CHANGE, PROC_REF(update_shadow)) | ||
RegisterSignal(parent, COMSIG_MOB_LOGOUT, PROC_REF(mob_logout)) | ||
|
||
/datum/component/shadowcasting/UnregisterFromParent() | ||
. = ..() | ||
UnregisterSignal(parent, list( | ||
COMSIG_MOVABLE_MOVED, | ||
COMSIG_MOB_RESET_PERSPECTIVE, | ||
COMSIG_MOB_SIGHT_CHANGE, | ||
COMSIG_MOB_LOGOUT, | ||
)) | ||
|
||
/datum/component/shadowcasting/Destroy(force, silent) | ||
var/mob/living/mob_parent = parent | ||
for(var/atom/movable/screen/plane_master/plane_master as anything in mob_parent.hud_used.get_true_plane_masters(SHADOWCASTING_PLANE)) | ||
plane_master.hide_plane(mob_parent) | ||
|
||
if(applied_shadow) | ||
remove_shadow() | ||
if(visual_shadow) | ||
QDEL_NULL(visual_shadow) | ||
return ..() | ||
|
||
/datum/component/shadowcasting/proc/update_shadow() | ||
SIGNAL_HANDLER | ||
var/mob/living/parent_mob = parent | ||
var/client/parent_client = parent_mob.client | ||
if(!parent_client) //Love client volatility!! | ||
return | ||
|
||
var/user_turf = get_turf(parent_mob) | ||
var/atom/top_most_atom = get_atom_on_turf(parent_mob) | ||
var/user_extends_eye = parent_client.eye != top_most_atom | ||
var/user_sees_turfs = parent_mob.sight & SEE_TURFS | ||
var/user_blind = parent_mob.sight & BLIND | ||
|
||
var/should_apply_mask = user_turf && !user_extends_eye && !user_sees_turfs && !user_blind | ||
if(should_apply_mask) | ||
add_shadow(user_turf) | ||
else | ||
remove_shadow() | ||
|
||
/datum/component/shadowcasting/proc/add_shadow(turf/mob_turf) | ||
var/mob/parent_mob = parent | ||
var/client/parent_client = parent_mob.client | ||
if(!parent_client) //Love client volatility!! | ||
return | ||
applied_shadow = TRUE | ||
if(!mob_turf.shadowcasting_image) | ||
mob_turf.update_shadowcasting_image() | ||
visual_shadow.reflector.overlays = null | ||
visual_shadow.reflector.overlays += mob_turf.shadowcasting_image | ||
visual_shadow.loc = get_turf(parent_mob) | ||
parent_client.images |= visual_shadow.reflector | ||
|
||
/datum/component/shadowcasting/proc/remove_shadow() | ||
var/mob/parent_mob = parent | ||
var/client/parent_client = parent_mob.client | ||
if(!parent_client) //Love client volatility!! | ||
return | ||
applied_shadow = FALSE | ||
visual_shadow.moveToNullspace() | ||
parent_client.images -= visual_shadow.reflector | ||
|
||
/// When a mob logs out, delete the component | ||
/datum/component/shadowcasting/proc/mob_logout(mob/source) | ||
SIGNAL_HANDLER | ||
qdel(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/atom/movable/shadowcasting_holder | ||
appearance_flags = KEEP_TOGETHER|TILE_BOUND|PIXEL_SCALE|LONG_GLIDE | ||
plane = SHADOWCASTING_PLANE | ||
animate_movement = NO_STEPS | ||
invisibility = INVISIBILITY_LIGHTING | ||
anchored = TRUE | ||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT | ||
var/image/reflector | ||
|
||
/atom/movable/shadowcasting_holder/Initialize(mapload) | ||
. = ..() | ||
reflector = new() | ||
reflector.override = TRUE | ||
reflector.loc = src | ||
|
||
/atom/movable/shadowcasting_holder/Destroy(force) | ||
. = ..() | ||
reflector = null |
Oops, something went wrong.