Added base workbench window (#372)

* Added base workbench window

* Fixed serialization errors

* Created base UI layout

* Updated ui

* Updated UI after crafting
This commit is contained in:
Tornado Tech
2024-08-06 21:25:59 +10:00
committed by GitHub
parent dc853b6662
commit 1b0bf2ad18
12 changed files with 446 additions and 17 deletions

View File

@@ -0,0 +1,33 @@
using Content.Shared._CP14.Workbench;
namespace Content.Server._CP14.Workbench;
public sealed partial class CP14WorkbenchSystem
{
private void OnCraft(Entity<CP14WorkbenchComponent> entity, ref CP14WorkbenchUiCraftMessage args)
{
if (!entity.Comp.Recipes.Contains(args.Recipe))
return;
if (!_proto.TryIndex(args.Recipe, out var prototype))
return;
StartCraft(entity, args.Actor, prototype);
}
private void UpdateUIRecipes(Entity<CP14WorkbenchComponent> entity)
{
var placedEntities = _lookup.GetEntitiesInRange(Transform(entity).Coordinates, WorkbenchRadius);
var recipes = new List<CP14WorkbenchUiRecipesEntry>();
foreach (var recipeId in entity.Comp.Recipes)
{
var recipe = _proto.Index(recipeId);
var entry = new CP14WorkbenchUiRecipesEntry(recipeId, CanCraftRecipe(recipe, placedEntities));
recipes.Add(entry);
}
_userInterface.SetUiState(entity.Owner, CP14WorkbenchUiKey.Key, new CP14WorkbenchUiRecipesState(recipes));
}
}