Fix secfab being able to print protolathe items (#17443)

This commit is contained in:
Nemanja
2023-06-18 18:35:19 -04:00
committed by GitHub
parent c6cc55f4d9
commit 8411739e00
5 changed files with 78 additions and 102 deletions

View File

@@ -1,4 +1,5 @@
using System.Text; using System.Linq;
using System.Text;
using Content.Shared.Lathe; using Content.Shared.Lathe;
using Content.Shared.Materials; using Content.Shared.Materials;
using Content.Shared.Research.Prototypes; using Content.Shared.Research.Prototypes;
@@ -53,7 +54,7 @@ public sealed partial class LatheMenu : DefaultWindow
if (_entityManager.TryGetComponent<LatheComponent>(owner.Lathe, out var latheComponent)) if (_entityManager.TryGetComponent<LatheComponent>(owner.Lathe, out var latheComponent))
{ {
if (latheComponent.DynamicRecipes == null) if (!latheComponent.DynamicRecipes.Any())
{ {
ServerListButton.Visible = false; ServerListButton.Visible = false;
ServerSyncButton.Visible = false; ServerSyncButton.Visible = false;
@@ -132,7 +133,7 @@ public sealed partial class LatheMenu : DefaultWindow
sb.Append('\n'); sb.Append('\n');
var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, component.MaterialUseMultiplier); var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, component.MaterialUseMultiplier);
sb.Append(adjustedAmount); sb.Append(adjustedAmount);
sb.Append(' '); sb.Append(' ');
sb.Append(Loc.GetString(proto.Name)); sb.Append(Loc.GetString(proto.Name));

View File

@@ -53,13 +53,14 @@ namespace Content.Server.Lathe
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var (comp, lathe) in EntityQuery<LatheProducingComponent, LatheComponent>()) var query = EntityQueryEnumerator<LatheProducingComponent, LatheComponent>();
while(query.MoveNext(out var uid, out var comp, out var lathe))
{ {
if (lathe.CurrentRecipe == null) if (lathe.CurrentRecipe == null)
continue; continue;
if ( _timing.CurTime - comp.StartTime >= comp.ProductionLength) if ( _timing.CurTime - comp.StartTime >= comp.ProductionLength)
FinishProducing(comp.Owner, lathe); FinishProducing(uid, lathe);
} }
} }
@@ -108,9 +109,7 @@ namespace Content.Server.Lathe
public List<string> GetAllBaseRecipes(LatheComponent component) public List<string> GetAllBaseRecipes(LatheComponent component)
{ {
return component.DynamicRecipes == null return component.StaticRecipes.Union(component.DynamicRecipes).ToList();
? component.StaticRecipes
: component.StaticRecipes.Union(component.DynamicRecipes).ToList();
} }
public bool TryAddToQueue(EntityUid uid, LatheRecipePrototype recipe, LatheComponent? component = null) 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) private void OnGetRecipes(EntityUid uid, TechnologyDatabaseComponent component, LatheGetRecipesEvent args)
{ {
if (uid != args.Lathe || !TryComp<LatheComponent>(uid, out var latheComponent) || latheComponent.DynamicRecipes == null) if (uid != args.Lathe || !TryComp<LatheComponent>(uid, out var latheComponent))
return; 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) private void OnMaterialAmountChanged(EntityUid uid, LatheComponent component, ref MaterialAmountChangedEvent args)

View File

@@ -20,7 +20,7 @@ namespace Content.Shared.Lathe
/// All of the recipes that the lathe is capable of researching /// All of the recipes that the lathe is capable of researching
/// </summary> /// </summary>
[DataField("dynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))] [DataField("dynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
public readonly List<string>? DynamicRecipes; public readonly List<string> DynamicRecipes = new();
/// <summary> /// <summary>
/// The lathe's construction queue /// The lathe's construction queue

View File

@@ -1,3 +1,4 @@
using Content.Shared.Lathe;
using Content.Shared.Research.Prototypes; using Content.Shared.Research.Prototypes;
using Content.Shared.Research.Systems; using Content.Shared.Research.Systems;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
@@ -6,7 +7,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Shared.Research.Components; 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 public sealed partial class TechnologyDatabaseComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -1,6 +1,56 @@
- type: entity - type: entity
id: BaseLathe
parent: [ BaseMachinePowered, ConstructibleMachine ] 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 id: Autolathe
parent: BaseLathe
name: autolathe name: autolathe
description: It produces items using metal and glass. description: It produces items using metal and glass.
components: components:
@@ -17,31 +67,6 @@
map: ["enum.MaterialStorageVisualLayers.Inserting"] map: ["enum.MaterialStorageVisualLayers.Inserting"]
- state: panel - state: panel
map: ["enum.WiresVisualLayers.MaintenancePanel"] 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 - type: Machine
board: AutolatheMachineCircuitboard board: AutolatheMachineCircuitboard
- type: MaterialStorage - type: MaterialStorage
@@ -50,20 +75,6 @@
- Sheet - Sheet
- RawMaterial - RawMaterial
- Ingot - 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 - type: Lathe
idleState: icon idleState: icon
runningState: building runningState: building
@@ -111,12 +122,10 @@
- SubstationMachineCircuitboard - SubstationMachineCircuitboard
- CellRechargerCircuitboard - CellRechargerCircuitboard
- WeaponCapacitorRechargerCircuitboard - WeaponCapacitorRechargerCircuitboard
- type: StaticPrice
price: 800
- type: entity - type: entity
parent: [ BaseMachinePowered, ConstructibleMachine ]
id: Protolathe id: Protolathe
parent: BaseLathe
name: protolathe name: protolathe
description: Converts raw materials into useful objects. description: Converts raw materials into useful objects.
components: components:
@@ -133,57 +142,17 @@
map: ["enum.MaterialStorageVisualLayers.Inserting"] map: ["enum.MaterialStorageVisualLayers.Inserting"]
- state: panel - state: panel
map: ["enum.WiresVisualLayers.MaintenancePanel"] 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 - type: Machine
board: ProtolatheMachineCircuitboard board: ProtolatheMachineCircuitboard
- type: WiresPanel
- type: Wires - type: Wires
BoardName: "Protolathe" BoardName: "Protolathe"
LayoutId: Protolathe LayoutId: Protolathe
- type: TechnologyDatabase
- type: MaterialStorage - type: MaterialStorage
whitelist: whitelist:
tags: tags:
- Sheet - Sheet
- RawMaterial - RawMaterial
- Ingot - 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 - type: Lathe
idleState: icon idleState: icon
runningState: building runningState: building
@@ -257,8 +226,8 @@
- JawsOfLife - JawsOfLife
- type: entity - type: entity
parent: Protolathe
id: CircuitImprinter id: CircuitImprinter
parent: BaseLathe
name: circuit imprinter name: circuit imprinter
description: Prints circuit boards for machines. description: Prints circuit boards for machines.
components: components:
@@ -351,8 +320,8 @@
- Ingot - Ingot
- type: entity - type: entity
parent: Protolathe
id: ExosuitFabricator id: ExosuitFabricator
parent: BaseLathe
name: exosuit fabricator name: exosuit fabricator
description: Creates parts for robotics and other mechanical needs description: Creates parts for robotics and other mechanical needs
components: components:
@@ -405,10 +374,9 @@
guides: guides:
- Robotics - Robotics
- type: entity - type: entity
parent: Protolathe
id: SecurityTechFab id: SecurityTechFab
parent: BaseLathe
name: security techfab name: security techfab
description: Prints equipment for use by security crew. description: Prints equipment for use by security crew.
components: components:
@@ -497,8 +465,8 @@
- Ingot - Ingot
- type: entity - type: entity
parent: Protolathe
id: MedicalTechFab id: MedicalTechFab
parent: BaseLathe
name: medical techfab name: medical techfab
description: Prints equipment for use by the medbay. description: Prints equipment for use by the medbay.
components: components:
@@ -559,7 +527,7 @@
board: MedicalTechFabCircuitboard board: MedicalTechFabCircuitboard
- type: entity - type: entity
parent: Autolathe parent: BaseLathe
id: UniformPrinter id: UniformPrinter
name: uniform printer name: uniform printer
description: Prints new or replacement uniforms. description: Prints new or replacement uniforms.
@@ -678,7 +646,7 @@
- Ingot - Ingot
- type: entity - type: entity
parent: Autolathe parent: BaseLathe
id: OreProcessor id: OreProcessor
name: ore processor name: ore processor
description: It produces sheets and ingots using ores. description: It produces sheets and ingots using ores.
@@ -704,6 +672,8 @@
tags: tags:
- Ore - Ore
- type: Lathe - type: Lathe
idleState: icon
runningState: building
staticRecipes: staticRecipes:
- SheetSteel30 - SheetSteel30
- SheetGlass30 - SheetGlass30
@@ -717,7 +687,7 @@
- MaterialBananium1 - MaterialBananium1
- type: entity - type: entity
parent: Autolathe parent: BaseLathe
id: Sheetifier id: Sheetifier
name: sheet-meister 2000 name: sheet-meister 2000
description: A very sheety machine. description: A very sheety machine.