Emaggable protolathe (#18456)

This commit is contained in:
ubis1
2023-08-07 17:21:04 +03:00
committed by GitHub
parent 1c476731ed
commit e203423665
5 changed files with 101 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ using Content.Server.Power.EntitySystems;
using Content.Server.Stack;
using Content.Server.UserInterface;
using Content.Shared.Database;
using Content.Shared.Emag.Components;
using Content.Shared.Lathe;
using Content.Shared.Materials;
using Content.Shared.Research.Components;
@@ -31,7 +32,6 @@ namespace Content.Server.Lathe
[Dependency] private readonly UserInterfaceSystem _uiSys = default!;
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
[Dependency] private readonly StackSystem _stack = default!;
public override void Initialize()
{
base.Initialize();
@@ -48,8 +48,8 @@ namespace Content.Server.Lathe
SubscribeLocalEvent<LatheComponent, BeforeActivatableUIOpenEvent>((u, c, _) => UpdateUserInterfaceState(u, c));
SubscribeLocalEvent<LatheComponent, MaterialAmountChangedEvent>(OnMaterialAmountChanged);
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheGetRecipesEvent>(OnGetRecipes);
SubscribeLocalEvent<EmagLatheRecipesComponent, LatheGetRecipesEvent>(GetEmagLatheRecipes);
}
public override void Update(float frameTime)
@@ -202,6 +202,24 @@ namespace Content.Server.Lathe
}
}
private void GetEmagLatheRecipes(EntityUid uid, EmagLatheRecipesComponent component, LatheGetRecipesEvent args)
{
if (uid != args.Lathe || !TryComp<TechnologyDatabaseComponent>(uid, out var technologyDatabase))
return;
if (!HasComp<EmaggedComponent>(uid))
return;
foreach (var recipe in component.EmagDynamicRecipes)
{
if (!technologyDatabase.UnlockedRecipes.Contains(recipe) || args.Recipes.Contains(recipe))
continue;
args.Recipes.Add(recipe);
}
foreach (var recipe in component.EmagStaticRecipes)
{
args.Recipes.Add(recipe);
}
}
private void OnMaterialAmountChanged(EntityUid uid, LatheComponent component, ref MaterialAmountChangedEvent args)
{
UpdateUserInterfaceState(uid, component);
@@ -272,7 +290,6 @@ namespace Content.Server.Lathe
{
return GetAvailableRecipes(uid, component).Contains(recipe.ID);
}
#region UI Messages
private void OnLatheQueueRecipeMessage(EntityUid uid, LatheComponent component, LatheQueueRecipeMessage args)