2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Server.Disposal.Tube.Components;
|
2021-09-20 19:06:48 +10:00
|
|
|
|
using Content.Shared.Movement;
|
2021-10-05 14:29:03 +11:00
|
|
|
|
using Content.Shared.Verbs;
|
|
|
|
|
|
using Robust.Server.GameObjects;
|
2021-09-20 19:06:48 +10:00
|
|
|
|
using Robust.Shared.Audio;
|
2021-05-13 02:05:46 +02:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-09-20 19:06:48 +10:00
|
|
|
|
using Robust.Shared.IoC;
|
2021-10-05 14:29:03 +11:00
|
|
|
|
using Robust.Shared.Localization;
|
2021-09-20 19:06:48 +10:00
|
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
|
using Robust.Shared.Timing;
|
2021-05-13 02:05:46 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Disposal.Tube
|
2021-05-13 02:05:46 +02:00
|
|
|
|
{
|
|
|
|
|
|
public sealed class DisposalTubeSystem : EntitySystem
|
|
|
|
|
|
{
|
2021-09-20 19:06:48 +10:00
|
|
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
|
|
|
|
|
2021-05-13 02:05:46 +02:00
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<DisposalTubeComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
|
2021-10-05 14:29:03 +11:00
|
|
|
|
|
2021-09-20 19:06:48 +10:00
|
|
|
|
SubscribeLocalEvent<DisposalTubeComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
2021-10-05 14:29:03 +11:00
|
|
|
|
SubscribeLocalEvent<DisposalTaggerComponent, GetInteractionVerbsEvent>(AddOpenUIVerbs);
|
|
|
|
|
|
SubscribeLocalEvent<DisposalRouterComponent, GetInteractionVerbsEvent>(AddOpenUIVerbs);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddOpenUIVerbs(EntityUid uid, DisposalTaggerComponent component, GetInteractionVerbsEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!args.CanAccess || !args.CanInteract)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!args.User.TryGetComponent<ActorComponent>(out var actor))
|
|
|
|
|
|
return;
|
|
|
|
|
|
var player = actor.PlayerSession;
|
|
|
|
|
|
|
|
|
|
|
|
Verb verb = new();
|
|
|
|
|
|
verb.Text = Loc.GetString("configure-verb-get-data-text");
|
|
|
|
|
|
verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png";
|
|
|
|
|
|
verb.Act = () => component.OpenUserInterface(actor);
|
|
|
|
|
|
args.Verbs.Add(verb);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddOpenUIVerbs(EntityUid uid, DisposalRouterComponent component, GetInteractionVerbsEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!args.CanAccess || !args.CanInteract)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!args.User.TryGetComponent<ActorComponent>(out var actor))
|
|
|
|
|
|
return;
|
|
|
|
|
|
var player = actor.PlayerSession;
|
|
|
|
|
|
|
|
|
|
|
|
Verb verb = new();
|
|
|
|
|
|
verb.Text = Loc.GetString("configure-verb-get-data-text");
|
|
|
|
|
|
verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png";
|
|
|
|
|
|
verb.Act = () => component.OpenUserInterface(actor);
|
|
|
|
|
|
args.Verbs.Add(verb);
|
2021-09-20 19:06:48 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnRelayMovement(EntityUid uid, DisposalTubeComponent component, RelayMovementEntityEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_gameTiming.CurTime < component.LastClang + DisposalTubeComponent.ClangDelay)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var entity = EntityManager.GetEntity(uid);
|
|
|
|
|
|
component.LastClang = _gameTiming.CurTime;
|
|
|
|
|
|
SoundSystem.Play(Filter.Pvs(entity), component.ClangSound.GetSound(), entity);
|
2021-05-13 02:05:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void BodyTypeChanged(
|
|
|
|
|
|
EntityUid uid,
|
|
|
|
|
|
DisposalTubeComponent component,
|
|
|
|
|
|
PhysicsBodyTypeChangedEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
component.AnchoredChanged();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|