* Techweb rework * more ui work * finishing ui * Finish all the C# logic * the techs + lathes * remove old-tech * mirror-review
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using System.Linq;
|
|
using Content.Shared.Interaction;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.Research.Prototypes;
|
|
using Content.Server.Research.Systems;
|
|
using Content.Shared.Research.Components;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.Research.Disk
|
|
{
|
|
public sealed class ResearchDiskSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly ResearchSystem _research = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ResearchDiskComponent, AfterInteractEvent>(OnAfterInteract);
|
|
SubscribeLocalEvent<ResearchDiskComponent, MapInitEvent>(OnMapInit);
|
|
}
|
|
|
|
private void OnAfterInteract(EntityUid uid, ResearchDiskComponent component, AfterInteractEvent args)
|
|
{
|
|
if (!args.CanReach)
|
|
return;
|
|
|
|
if (!TryComp<ResearchServerComponent>(args.Target, out var server))
|
|
return;
|
|
|
|
_research.ModifyServerPoints(args.Target.Value, component.Points, server);
|
|
_popupSystem.PopupEntity(Loc.GetString("research-disk-inserted", ("points", component.Points)), args.Target.Value, args.User);
|
|
EntityManager.QueueDeleteEntity(uid);
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, ResearchDiskComponent component, MapInitEvent args)
|
|
{
|
|
if (!component.UnlockAllTech)
|
|
return;
|
|
|
|
component.Points = _prototype.EnumeratePrototypes<TechnologyPrototype>()
|
|
.Sum(tech => tech.Cost);
|
|
}
|
|
}
|
|
}
|