-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Containers block vision #33317
Containers block vision #33317
Conversation
works for lockers too? |
yes |
Not everything needs to be logical. This is just annoying. |
At least nukies might not need to gun down every disposal bin/locker if they do not want instant stunkill or something 🤔 Not taking damage when you are hiding in container is weird too but thats another issue I guess. |
I feel the vision blocking is a bit too harsh. It either should have a wider radius or it should gradually get worse. |
lockers have the eye slits you should be able to see out of them |
Maybe add the same block vision when player travel in disposal tube? |
I hate being that guy but ackshually not all lockers have slits. |
Yet somehow they are completely airtight |
The current implementation is very simple and just blinds the character completely. IIRC the blindness shader doesn't have a “range of visibility” parameter, so it's much harder to do. So currently, I'm not going to implement different levels of visibility for different container types, as that's out of scope. |
/// <summary> | ||
/// Blinds entities that are parented to this entity (are in this locker, crate or bag) | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ChildBlockVisionComponent : Component | ||
{ | ||
[DataField] | ||
public bool Enabled = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs networking.
base.Initialize(); | ||
|
||
_transformQuery = GetEntityQuery<TransformComponent>(); | ||
_blockQuery = GetEntityQuery<ChildBlockVisionComponent>(); | ||
_mapQuery = GetEntityQuery<MapGridComponent>(); | ||
|
||
SubscribeLocalEvent<EyeComponent, CanSeeAttemptEvent>(OnSeeAttempt); | ||
SubscribeLocalEvent<EyeComponent, EntParentChangedMessage>(OnChangeParent); | ||
} | ||
|
||
private void OnChangeParent(Entity<EyeComponent> ent, ref EntParentChangedMessage args) | ||
{ | ||
_blindable.UpdateIsBlind(ent.Owner); | ||
} | ||
|
||
private void OnSeeAttempt(Entity<EyeComponent> ent, ref CanSeeAttemptEvent args) | ||
{ | ||
var parent = _transform.GetParentUid(ent); | ||
if (HaveBlockVisionParent(parent)) | ||
args.Cancel(); | ||
} | ||
|
||
/// <summary> | ||
/// recursively go through all parents up to the map. If one of the parents has a vision blocking component, we see nothing. | ||
/// </summary> | ||
private bool HaveBlockVisionParent(EntityUid ent) | ||
{ | ||
if (!_transformQuery.HasComp(ent)) | ||
return false; | ||
|
||
if (_mapQuery.HasComp(ent)) | ||
return false; | ||
|
||
if (_blockQuery.TryComp(ent, out var block) && block.Enabled) | ||
return true; | ||
|
||
return HaveBlockVisionParent(_transform.GetParentUid(ent)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be subscribing to directed events for engine components as this can very easily break in the future when the engine needs it.
{ | ||
if (!_transformQuery.HasComp(ent)) | ||
return false; | ||
|
||
if (_mapQuery.HasComp(ent)) | ||
return false; | ||
|
||
if (_blockQuery.TryComp(ent, out var block) && block.Enabled) | ||
return true; | ||
|
||
return HaveBlockVisionParent(_transform.GetParentUid(ent)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're resolving the transformcomponent twice, once unnecessarily.
Remove the transformqueryhascomp.
Keron is against this kind of implementation of these mechanics, and proper implementation means working with shaders, which I'm not ready for. |
About the PR
Containers can now block vision for entities that sit within it.
Why / Balance
Logic
Media
2024-11-14.21-16-05.mp4
Requirements
Changelog
🆑