Skip to content
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

Closed

Conversation

TheShuEd
Copy link
Member

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
🆑

  • tweak: Containers can now block vision for entities that sit within it.

@github-actions github-actions bot added size/M Denotes a PR that changes 100-999 lines. S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Nov 14, 2024
@TheShuEd TheShuEd added T: New Feature Type: New feature or content, or extending existing content A: General Interactions Area: General in-game interactions that don't relate to another area. and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Nov 14, 2024
@Everturning
Copy link

works for lockers too?

@TheShuEd
Copy link
Member Author

yes

@Stewie523
Copy link

Not everything needs to be logical. This is just annoying.

@thebadman4662
Copy link

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.

@TheShuEd TheShuEd changed the title You can't see while you're in a crate Containers block vision Nov 14, 2024
@SlamBamActionman SlamBamActionman added P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. D3: Low Difficulty: Some codebase knowledge required. labels Nov 14, 2024
@keronshb
Copy link
Contributor

I feel the vision blocking is a bit too harsh. It either should have a wider radius or it should gradually get worse.
Close = see, further = fuzzy, furthest = blind

@Kadeo64
Copy link
Contributor

Kadeo64 commented Nov 15, 2024

lockers have the eye slits

you should be able to see out of them

@KaiserMaus
Copy link

Maybe add the same block vision when player travel in disposal tube?

@Shaddap1
Copy link
Contributor

lockers have the eye slits

you should be able to see out of them

I hate being that guy but ackshually not all lockers have slits.

@NoElkaTheGod
Copy link
Contributor

lockers have the eye slits

Yet somehow they are completely airtight

@SaphireLattice SaphireLattice added the S: Needs Review Status: Requires additional reviews before being fully accepted label Nov 15, 2024
@TheShuEd
Copy link
Member Author

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.

@slarticodefast slarticodefast added the S: Undergoing Maintainer Discussion Status: Currently going through an extended discussion amongst maintainers, as per procedure. label Nov 28, 2024
Comment on lines +3 to +11
/// <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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs networking.

Comment on lines +16 to +54
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));
}
}
Copy link
Contributor

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.

Comment on lines +42 to +53
{
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));
}
Copy link
Contributor

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.

@metalgearsloth metalgearsloth added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted labels Nov 28, 2024
@TheShuEd
Copy link
Member Author

TheShuEd commented Dec 6, 2024

Keron is against this kind of implementation of these mechanics, and proper implementation means working with shaders, which I'm not ready for.

@TheShuEd TheShuEd closed this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: General Interactions Area: General in-game interactions that don't relate to another area. D3: Low Difficulty: Some codebase knowledge required. P2: Raised Priority: Item has a raised priority, indicating it might get increased maintainer attention. S: Awaiting Changes Status: Changes are required before another review can happen S: Undergoing Maintainer Discussion Status: Currently going through an extended discussion amongst maintainers, as per procedure. size/M Denotes a PR that changes 100-999 lines. T: New Feature Type: New feature or content, or extending existing content
Projects
None yet
Development

Successfully merging this pull request may close these issues.