Files
crystall-punk-14/Content.Shared/_CP14/Skill/Effects/UnlockRecipes.cs
Red 14b0fc5b4a Workbench and crystals (#1502)
* solutionResource

* fuck research system + QoL workbench update

* colorful quartz returns

* Refactor workbench skill requirements handling

Replaces the SkillRequired requirement with a direct RequiredSkills field on CP14WorkbenchRecipePrototype. Updates client and server logic to check skills directly, simplifying recipe skill checks and related UI logic.

* Initial commit

Add initial project files and setup.
2025-07-05 20:44:38 +03:00

58 lines
1.7 KiB
C#

using System.Text;
using Content.Shared._CP14.Skill.Prototypes;
using Content.Shared._CP14.Workbench.Prototypes;
using Content.Shared._CP14.Workbench.Requirements;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.Skill.Effects;
/// <summary>
/// This effect only exists for parsing the description.
/// </summary>
public sealed partial class UnlockRecipes : CP14SkillEffect
{
public override void AddSkill(IEntityManager entManager, EntityUid target)
{
//
}
public override void RemoveSkill(IEntityManager entManager, EntityUid target)
{
//
}
public override string? GetName(IEntityManager entMagager, IPrototypeManager protoManager)
{
return null;
}
public override string? GetDescription(IEntityManager entMagager, IPrototypeManager protoManager, ProtoId<CP14SkillPrototype> skill)
{
var allRecipes = protoManager.EnumeratePrototypes<CP14WorkbenchRecipePrototype>();
var sb = new StringBuilder();
sb.Append(Loc.GetString("cp14-skill-desc-unlock-recipes") + "\n");
var affectedRecipes = new List<CP14WorkbenchRecipePrototype>();
foreach (var recipe in allRecipes)
{
foreach (var req in recipe.RequiredSkills)
{
if (req == skill)
{
affectedRecipes.Add(recipe);
break;
}
}
}
foreach (var recipe in affectedRecipes)
{
if (!protoManager.TryIndex(recipe.Result, out var indexedResult))
continue;
sb.Append("- " + indexedResult.Name + "\n");
}
return sb.ToString();
}
}