Nerf ninja research stealing (#26421)

* nerf ninja steal objective

* fubar
This commit is contained in:
Nemanja
2024-03-25 20:52:27 -04:00
committed by GitHub
parent 327a6e90d1
commit 3b9c5d43ec
4 changed files with 75 additions and 8 deletions

View File

@@ -1,11 +1,13 @@
using Content.Shared.Research.Components;
using Content.Shared.Research.Systems;
using Robust.Shared.Random;
namespace Content.Server.Research.Systems;
public sealed class ResearchStealerSystem : SharedResearchStealerSystem
{
[Dependency] private readonly SharedResearchSystem _research = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
@@ -24,16 +26,26 @@ public sealed class ResearchStealerSystem : SharedResearchStealerSystem
if (!TryComp<TechnologyDatabaseComponent>(target, out var database))
return;
var ev = new ResearchStolenEvent(uid, target, database.UnlockedTechnologies);
var ev = new ResearchStolenEvent(uid, target, new());
var count = _random.Next(comp.MinToSteal, comp.MaxToSteal + 1);
for (var i = 0; i < count; i++)
{
if (database.UnlockedTechnologies.Count == 0)
break;
var toRemove = _random.Pick(database.UnlockedTechnologies);
if (_research.TryRemoveTechnology((target, database), toRemove))
ev.Techs.Add(toRemove);
}
RaiseLocalEvent(uid, ref ev);
// oops, no more advanced lasers!
_research.ClearTechs(target, database);
args.Handled = true;
}
}
/// <summary>
/// Event raised on the user when research is stolen from a R&D server.
/// Event raised on the user when research is stolen from a RND server.
/// Techs contains every technology id researched.
/// </summary>
[ByRefEvent]
public record struct ResearchStolenEvent(EntityUid Used, EntityUid Target, List<String> Techs);
public record struct ResearchStolenEvent(EntityUid Used, EntityUid Target, List<string> Techs);