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