fix infinite lathe printing bug (#12343)
This commit is contained in:
@@ -122,7 +122,11 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
else
|
||||
sb.Append('\n');
|
||||
|
||||
sb.Append((int) (amount * component.MaterialUseMultiplier));
|
||||
var adjustedAmount = amount;
|
||||
if (prototype.ApplyMaterialDiscount)
|
||||
adjustedAmount = (int) (adjustedAmount * component.MaterialUseMultiplier);
|
||||
|
||||
sb.Append(adjustedAmount);
|
||||
sb.Append(' ');
|
||||
sb.Append(proto.Name);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,11 @@ namespace Content.Server.Lathe
|
||||
|
||||
foreach (var (mat, amount) in recipe.RequiredMaterials)
|
||||
{
|
||||
_materialStorage.TryChangeMaterialAmount(uid, mat, (int) (-amount * component.MaterialUseMultiplier));
|
||||
var adjustedAmount = recipe.ApplyMaterialDiscount
|
||||
? (int) (-amount * component.MaterialUseMultiplier)
|
||||
: -amount;
|
||||
|
||||
_materialStorage.TryChangeMaterialAmount(uid, mat, adjustedAmount);
|
||||
}
|
||||
component.Queue.Add(recipe);
|
||||
|
||||
|
||||
@@ -50,7 +50,11 @@ public abstract class SharedLatheSystem : EntitySystem
|
||||
|
||||
foreach (var (material, needed) in recipe.RequiredMaterials)
|
||||
{
|
||||
if (_materialStorage.GetMaterialAmount(component.Owner, material) < amount * needed * component.MaterialUseMultiplier)
|
||||
var adjustedAmount = recipe.ApplyMaterialDiscount
|
||||
? (int) (amount * component.MaterialUseMultiplier)
|
||||
: amount;
|
||||
|
||||
if (_materialStorage.GetMaterialAmount(component.Owner, material) < adjustedAmount * needed)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Shared.Research.Prototypes
|
||||
public sealed class LatheRecipePrototype : IPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
[IdDataFieldAttribute]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField("name")]
|
||||
@@ -42,7 +42,6 @@ namespace Content.Shared.Research.Prototypes
|
||||
{
|
||||
if (_name.Trim().Length != 0) return _name;
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (protoMan == null) return _description;
|
||||
protoMan.TryIndex(_result, out EntityPrototype? prototype);
|
||||
if (prototype?.Name != null)
|
||||
_name = prototype.Name;
|
||||
@@ -60,7 +59,6 @@ namespace Content.Shared.Research.Prototypes
|
||||
{
|
||||
if (_description.Trim().Length != 0) return _description;
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (protoMan == null) return _description;
|
||||
protoMan.TryIndex(_result, out EntityPrototype? prototype);
|
||||
if (prototype?.Description != null)
|
||||
_description = prototype.Description;
|
||||
@@ -98,5 +96,8 @@ namespace Content.Shared.Research.Prototypes
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public TimeSpan CompleteTime => _completeTime;
|
||||
|
||||
[DataField("applyMaterialDiscount")]
|
||||
public bool ApplyMaterialDiscount = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
dynamicRecipes:
|
||||
- LightTube
|
||||
- LightBulb
|
||||
- SheetSteel
|
||||
- SheetSteel #these sheet recipe costs don't scale with upgrades
|
||||
- SheetGlass1
|
||||
- SheetRGlass
|
||||
- SheetPlastic
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
sprite: Objects/Materials/Sheets/metal.rsi
|
||||
state: steel
|
||||
result: SheetSteel1
|
||||
applyMaterialDiscount: false
|
||||
completetime: 2
|
||||
materials:
|
||||
Steel: 100
|
||||
@@ -24,6 +25,7 @@
|
||||
sprite: Objects/Materials/Sheets/glass.rsi
|
||||
state: glass
|
||||
result: SheetGlass1
|
||||
applyMaterialDiscount: false
|
||||
completetime: 2
|
||||
materials:
|
||||
Glass: 100
|
||||
@@ -44,6 +46,7 @@
|
||||
sprite: Objects/Materials/Sheets/glass.rsi
|
||||
state: rglass
|
||||
result: SheetRGlass1
|
||||
applyMaterialDiscount: false
|
||||
completetime: 2
|
||||
materials:
|
||||
Glass: 100
|
||||
@@ -129,6 +132,7 @@
|
||||
sprite: Objects/Materials/Sheets/other.rsi
|
||||
state: plastic
|
||||
result: SheetPlastic1
|
||||
applyMaterialDiscount: false
|
||||
completetime: 2
|
||||
materials:
|
||||
Plastic: 100
|
||||
|
||||
Reference in New Issue
Block a user