* - fix: No concealed rune interaction. * - fix: Wizard rule min players. * - add: Holosign stuff. * - add: Don't despawn dragon. * - tweak: Implants. * - fix: Hijack. * - remove: Hardsuit objective. * - fix: Holosigns. * - fix: Fix chair rotation. * - fix: No shooting while delayed. * - fix: Changeling felinid polymorph. * - fix: Fix stuck in container in container. * - fix: Fix flash in containers. * - fix: Whistle chameleon. * - fix: Loc. * - fix: No shooting in body bags. * - fix: Error. * - fix: Ling felinid fix attempt 2.
69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
using Content.Shared.Coordinates;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Polymorph.Components;
|
|
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 (!_timing.IsFirstTimePredicted)
|
|
return;
|
|
|
|
TryMakeLoudWhistle(uid, args.User, component);
|
|
args.Handled = true;
|
|
}
|
|
|
|
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<HumanoidAppearanceComponent>(_transform.GetMapCoordinates(uid), component.Distance))
|
|
{
|
|
//Avoid pinging invisible entities
|
|
if (TryComp(iterator, out stealth) && stealth.Enabled)
|
|
continue;
|
|
|
|
if (HasComp<ChameleonDisguisedComponent>(iterator)) // WD
|
|
continue;
|
|
|
|
//We don't want to ping user of whistle
|
|
if (iterator.Owner == owner)
|
|
continue;
|
|
|
|
ExclamateTarget(iterator, component);
|
|
}
|
|
}
|
|
}
|