diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMenu.xaml.cs index fd3319c434..7a1a4f08f3 100644 --- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs +++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Linq; +using System.Text; using Content.Shared.Lathe; using Content.Shared.Materials; using Content.Shared.Research.Prototypes; @@ -53,7 +54,7 @@ public sealed partial class LatheMenu : DefaultWindow if (_entityManager.TryGetComponent(owner.Lathe, out var latheComponent)) { - if (latheComponent.DynamicRecipes == null) + if (!latheComponent.DynamicRecipes.Any()) { ServerListButton.Visible = false; ServerSyncButton.Visible = false; @@ -132,7 +133,7 @@ public sealed partial class LatheMenu : DefaultWindow sb.Append('\n'); var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, component.MaterialUseMultiplier); - + sb.Append(adjustedAmount); sb.Append(' '); sb.Append(Loc.GetString(proto.Name)); diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 25b5dcbb81..d3fa6d23cd 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -53,13 +53,14 @@ namespace Content.Server.Lathe public override void Update(float frameTime) { - foreach (var (comp, lathe) in EntityQuery()) + var query = EntityQueryEnumerator(); + while(query.MoveNext(out var uid, out var comp, out var lathe)) { if (lathe.CurrentRecipe == null) continue; if ( _timing.CurTime - comp.StartTime >= comp.ProductionLength) - FinishProducing(comp.Owner, lathe); + FinishProducing(uid, lathe); } } @@ -108,9 +109,7 @@ namespace Content.Server.Lathe public List GetAllBaseRecipes(LatheComponent component) { - return component.DynamicRecipes == null - ? component.StaticRecipes - : component.StaticRecipes.Union(component.DynamicRecipes).ToList(); + return component.StaticRecipes.Union(component.DynamicRecipes).ToList(); } public bool TryAddToQueue(EntityUid uid, LatheRecipePrototype recipe, LatheComponent? component = null) @@ -191,10 +190,15 @@ namespace Content.Server.Lathe private void OnGetRecipes(EntityUid uid, TechnologyDatabaseComponent component, LatheGetRecipesEvent args) { - if (uid != args.Lathe || !TryComp(uid, out var latheComponent) || latheComponent.DynamicRecipes == null) + if (uid != args.Lathe || !TryComp(uid, out var latheComponent)) return; - args.Recipes = args.Recipes.Union(component.UnlockedRecipes.Where(r => latheComponent.DynamicRecipes.Contains(r))).ToList(); + foreach (var recipe in latheComponent.DynamicRecipes) + { + if (!component.UnlockedRecipes.Contains(recipe)) + continue; + args.Recipes.Add(recipe); + } } private void OnMaterialAmountChanged(EntityUid uid, LatheComponent component, ref MaterialAmountChangedEvent args) diff --git a/Content.Shared/Lathe/LatheComponent.cs b/Content.Shared/Lathe/LatheComponent.cs index 4cfd94c80f..15c8b44c7f 100644 --- a/Content.Shared/Lathe/LatheComponent.cs +++ b/Content.Shared/Lathe/LatheComponent.cs @@ -20,7 +20,7 @@ namespace Content.Shared.Lathe /// All of the recipes that the lathe is capable of researching /// [DataField("dynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public readonly List? DynamicRecipes; + public readonly List DynamicRecipes = new(); /// /// The lathe's construction queue diff --git a/Content.Shared/Research/Components/TechnologyDatabaseComponent.cs b/Content.Shared/Research/Components/TechnologyDatabaseComponent.cs index 28999087c6..b9936956ad 100644 --- a/Content.Shared/Research/Components/TechnologyDatabaseComponent.cs +++ b/Content.Shared/Research/Components/TechnologyDatabaseComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Lathe; using Content.Shared.Research.Prototypes; using Content.Shared.Research.Systems; using Robust.Shared.GameStates; @@ -6,7 +7,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy namespace Content.Shared.Research.Components; -[RegisterComponent, NetworkedComponent, Access(typeof(SharedResearchSystem)), AutoGenerateComponentState] +[RegisterComponent, NetworkedComponent, Access(typeof(SharedResearchSystem), typeof(SharedLatheSystem)), AutoGenerateComponentState] public sealed partial class TechnologyDatabaseComponent : Component { /// diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 5bd4c087b2..db34becbb9 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -1,6 +1,56 @@ - type: entity + id: BaseLathe parent: [ BaseMachinePowered, ConstructibleMachine ] + abstract: true + name: lathe + components: + - type: Appearance + - type: WiresVisuals + - type: Fixtures + fixtures: + fix1: + shape: + !type:PhysShapeAabb + bounds: "-0.4,-0.4,0.4,0.4" + density: 190 + mask: + - MachineMask + layer: + - MachineLayer + - type: Lathe + - type: MaterialStorage + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:ChangeConstructionNodeBehavior + node: machineFrame + - !type:DoActsBehavior + acts: ["Destruction"] + - type: WiresPanel + - type: Wires + BoardName: "Autolathe" + LayoutId: Autolathe + - type: ActivatableUI + key: enum.LatheUiKey.Key + - type: ActivatableUIRequiresPower + - type: UserInterface + interfaces: + - key: enum.LatheUiKey.Key + type: LatheBoundUserInterface + - type: Transform + anchored: true + - type: Pullable + - type: StaticPrice + price: 800 + - type: ResearchClient + - type: TechnologyDatabase + +- type: entity id: Autolathe + parent: BaseLathe name: autolathe description: It produces items using metal and glass. components: @@ -17,31 +67,6 @@ map: ["enum.MaterialStorageVisualLayers.Inserting"] - state: panel map: ["enum.WiresVisualLayers.MaintenancePanel"] - - type: Appearance - - type: WiresVisuals - - type: Physics - bodyType: Static - - type: Fixtures - fixtures: - fix1: - shape: - !type:PhysShapeAabb - bounds: "-0.4,-0.4,0.4,0.4" - density: 190 - mask: - - MachineMask - layer: - - MachineLayer - - type: Destructible - thresholds: - - trigger: - !type:DamageTrigger - damage: 100 - behaviors: - - !type:ChangeConstructionNodeBehavior - node: machineFrame - - !type:DoActsBehavior - acts: ["Destruction"] - type: Machine board: AutolatheMachineCircuitboard - type: MaterialStorage @@ -50,20 +75,6 @@ - Sheet - RawMaterial - Ingot - - type: WiresPanel - - type: Wires - BoardName: "Autolathe" - LayoutId: Autolathe - - type: ActivatableUI - key: enum.LatheUiKey.Key - - type: ActivatableUIRequiresPower - - type: UserInterface - interfaces: - - key: enum.LatheUiKey.Key - type: LatheBoundUserInterface - - type: Transform - anchored: true - - type: Pullable - type: Lathe idleState: icon runningState: building @@ -111,12 +122,10 @@ - SubstationMachineCircuitboard - CellRechargerCircuitboard - WeaponCapacitorRechargerCircuitboard - - type: StaticPrice - price: 800 - type: entity - parent: [ BaseMachinePowered, ConstructibleMachine ] id: Protolathe + parent: BaseLathe name: protolathe description: Converts raw materials into useful objects. components: @@ -133,57 +142,17 @@ map: ["enum.MaterialStorageVisualLayers.Inserting"] - state: panel map: ["enum.WiresVisualLayers.MaintenancePanel"] - - type: Appearance - - type: WiresVisuals - - type: Physics - bodyType: Static - - type: Fixtures - fixtures: - fix1: - shape: - !type:PhysShapeAabb - bounds: "-0.4,-0.4,0.4,0.4" - density: 190 - mask: - - MachineMask - layer: - - MachineLayer - - type: ResearchClient - - type: Destructible - thresholds: - - trigger: - !type:DamageTrigger - damage: 100 - behaviors: - - !type:ChangeConstructionNodeBehavior - node: machineFrame - - !type:DoActsBehavior - acts: ["Destruction"] - type: Machine board: ProtolatheMachineCircuitboard - - type: WiresPanel - type: Wires BoardName: "Protolathe" LayoutId: Protolathe - - type: TechnologyDatabase - type: MaterialStorage whitelist: tags: - Sheet - RawMaterial - Ingot - - type: ActivatableUI - key: enum.LatheUiKey.Key #Yes only having 1 of them here doesn't break anything - - type: ActivatableUIRequiresPower - - type: UserInterface - interfaces: - - key: enum.LatheUiKey.Key - type: LatheBoundUserInterface - - key: enum.ResearchClientUiKey.Key - type: ResearchClientBoundUserInterface - - type: Transform - anchored: true - - type: Pullable - type: Lathe idleState: icon runningState: building @@ -257,8 +226,8 @@ - JawsOfLife - type: entity - parent: Protolathe id: CircuitImprinter + parent: BaseLathe name: circuit imprinter description: Prints circuit boards for machines. components: @@ -351,8 +320,8 @@ - Ingot - type: entity - parent: Protolathe id: ExosuitFabricator + parent: BaseLathe name: exosuit fabricator description: Creates parts for robotics and other mechanical needs components: @@ -405,10 +374,9 @@ guides: - Robotics - - type: entity - parent: Protolathe id: SecurityTechFab + parent: BaseLathe name: security techfab description: Prints equipment for use by security crew. components: @@ -497,8 +465,8 @@ - Ingot - type: entity - parent: Protolathe id: MedicalTechFab + parent: BaseLathe name: medical techfab description: Prints equipment for use by the medbay. components: @@ -559,7 +527,7 @@ board: MedicalTechFabCircuitboard - type: entity - parent: Autolathe + parent: BaseLathe id: UniformPrinter name: uniform printer description: Prints new or replacement uniforms. @@ -678,7 +646,7 @@ - Ingot - type: entity - parent: Autolathe + parent: BaseLathe id: OreProcessor name: ore processor description: It produces sheets and ingots using ores. @@ -704,6 +672,8 @@ tags: - Ore - type: Lathe + idleState: icon + runningState: building staticRecipes: - SheetSteel30 - SheetGlass30 @@ -717,7 +687,7 @@ - MaterialBananium1 - type: entity - parent: Autolathe + parent: BaseLathe id: Sheetifier name: sheet-meister 2000 description: A very sheety machine.