Port research disks from nyano (#9081)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Rane
2022-06-28 10:41:08 -04:00
committed by GitHub
parent 793f0e1281
commit e86e6a5cce
11 changed files with 165 additions and 19 deletions

View 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);
}
}
}