Port research disks from nyano (#9081)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
30
Content.Server/Research/Disk/ResearchDiskSystem.cs
Normal file
30
Content.Server/Research/Disk/ResearchDiskSystem.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user