31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using Content.Shared.Interaction;
|
|
using Content.Server.Research.Components;
|
|
using Content.Server.Popups;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Research.Disk
|
|
{
|
|
public sealed class ResearchDiskSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ResearchDiskComponent, AfterInteractEvent>(OnAfterInteract);
|
|
}
|
|
|
|
private void OnAfterInteract(EntityUid uid, ResearchDiskComponent component, AfterInteractEvent args)
|
|
{
|
|
if (!args.CanReach)
|
|
return;
|
|
|
|
if (!TryComp<ResearchServerComponent>(args.Target, out var server))
|
|
return;
|
|
|
|
server.Points += component.Points;
|
|
_popupSystem.PopupEntity(Loc.GetString("research-disk-inserted", ("points", component.Points)), args.Target.Value, Filter.Entities(args.User));
|
|
EntityManager.QueueDeleteEntity(uid);
|
|
}
|
|
}
|
|
}
|