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,6 +1,7 @@
using System.Linq;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -219,16 +220,58 @@ public abstract class SharedResearchSystem : EntitySystem
if (!Resolve(uid, ref component))
return;
var discipline = PrototypeManager.Index<TechDisciplinePrototype>(prototype.Discipline);
var discipline = PrototypeManager.Index(prototype.Discipline);
if (prototype.Tier < discipline.LockoutTier)
return;
component.MainDiscipline = prototype.Discipline;
Dirty(uid, component);
}
/// <summary>
/// Removes a technology and its recipes from a technology database.
/// </summary>
public bool TryRemoveTechnology(Entity<TechnologyDatabaseComponent> entity, ProtoId<TechnologyPrototype> tech)
{
return TryRemoveTechnology(entity, PrototypeManager.Index(tech));
}
/// <summary>
/// Removes a technology and its recipes from a technology database.
/// </summary>
[PublicAPI]
public bool TryRemoveTechnology(Entity<TechnologyDatabaseComponent> entity, TechnologyPrototype tech)
{
if (!entity.Comp.UnlockedTechnologies.Remove(tech.ID))
return false;
// check to make sure we didn't somehow get the recipe from another tech.
// unlikely, but whatever
var recipes = tech.RecipeUnlocks;
foreach (var recipe in recipes)
{
var hasTechElsewhere = false;
foreach (var unlockedTech in entity.Comp.UnlockedTechnologies)
{
var unlockedTechProto = PrototypeManager.Index<TechnologyPrototype>(unlockedTech);
if (!unlockedTechProto.RecipeUnlocks.Contains(recipe))
continue;
hasTechElsewhere = true;
break;
}
if (!hasTechElsewhere)
entity.Comp.UnlockedRecipes.Remove(recipe);
}
Dirty(entity, entity.Comp);
UpdateTechnologyCards(entity, entity);
return true;
}
/// <summary>
/// Clear all unlocked technologies from the database.
/// </summary>
[PublicAPI]
public void ClearTechs(EntityUid uid, TechnologyDatabaseComponent? comp = null)
{
if (!Resolve(uid, ref comp) || comp.UnlockedTechnologies.Count == 0)