mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* 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
64 lines
2.0 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|