Files
Delta-v/Content.Shared/Whistle/WhistleSystem.cs
T
pathetic meowmeow c57721eca5 Visual nubody (humanoid appearance refactor) (#42476)
* initial visual nubody

* oops overlay

* im so pheeming rn

* conversion...

* tests

* comeback of the underwear

* oops eyes

* blabbl

* zeds

* yaml linted

* search and visible count constraints

* reordering

* preserve previously selected markings colors

* fix test

* some ui niceties

* ordering

* make DB changes backwards-compatible/downgrade-friendly

* fix things again

* fix migration

* vulpkanin markings limit increase

* wrapping

* code cleanup and more code cleanup and more code cleanup and more code cleanup and

* fix slop ports

* better sampling API

* make filter work + use the method i made for its intended purpose

* fix test fails real quick

* magic mirror cleanup, remove TODO

* don't 0-init the organ profile data

* remove deltastates

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>

# Conflicts:
#	Content.Server/Humanoid/Components/RandomHumanoidAppearanceComponent.cs
#	Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs

# Conflicts:
#	Resources/Prototypes/Species/diona.yml

# Conflicts:
#	Content.Server/Zombies/ZombieSystem.Transform.cs
2026-06-29 12:43:35 +02:00

64 lines
2.0 KiB
C#

using Content.Shared.Coordinates;
using Content.Shared.Humanoid;
using Content.Shared.Interaction.Events;
using Content.Shared.Stealth.Components;
using JetBrains.Annotations;
using Robust.Shared.Timing;
namespace Content.Shared.Whistle;
public sealed class WhistleSystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WhistleComponent, UseInHandEvent>(OnUseInHand);
}
private void ExclamateTarget(EntityUid target, WhistleComponent component)
{
SpawnAttachedTo(component.Effect, target.ToCoordinates());
}
public void OnUseInHand(EntityUid uid, WhistleComponent component, UseInHandEvent args)
{
if (args.Handled || !_timing.IsFirstTimePredicted)
return;
args.Handled = TryMakeLoudWhistle(uid, args.User, component);
}
public bool TryMakeLoudWhistle(EntityUid uid, EntityUid owner, WhistleComponent? component = null)
{
if (!Resolve(uid, ref component, false) || component.Distance <= 0)
return false;
MakeLoudWhistle(uid, owner, component);
return true;
}
private void MakeLoudWhistle(EntityUid uid, EntityUid owner, WhistleComponent component)
{
StealthComponent? stealth = null;
foreach (var iterator in
_entityLookup.GetEntitiesInRange<HumanoidProfileComponent>(_transform.GetMapCoordinates(uid), component.Distance))
{
//Avoid pinging invisible entities
if (TryComp(iterator, out stealth) && stealth.Enabled)
continue;
//We don't want to ping user of whistle
if (iterator.Owner == owner)
continue;
ExclamateTarget(iterator, component);
}
}
}