Add cheese & dough reactions (#5547)

* git mv

* rename CreateEntityReaction -> CreateEntityTileReaction

* cheese

* change microwave recipes

* remove unnecessary test

* TryGet->Get
This commit is contained in:
Leon Friedrich
2021-11-27 11:50:14 +13:00
committed by GitHub
parent 7ecd08b8ca
commit 61423be24e
14 changed files with 169 additions and 91 deletions

View File

@@ -45,6 +45,12 @@ namespace Content.Shared.Chemistry.Reaction
// TODO SERV3: Empty on the client, (de)serialize on the server with module manager is server module
[DataField("sound", serverOnly: true)] public SoundSpecifier Sound { get; private set; } = new SoundPathSpecifier("/Audio/Effects/Chemistry/bubbles.ogg");
/// <summary>
/// If true, this reaction will only consume only integer multiples of the reactant amounts. If there are not
/// enough reactants, the reaction does not occur. Useful for spawn-entity reactions (e.g. creating cheese).
/// </summary>
[DataField("quantized")] public bool Quantized = false;
}
/// <summary>

View File

@@ -46,6 +46,17 @@ namespace Content.Shared.Chemistry.Reaction
if (!solution.ContainsReagent(reactantName, out var reactantQuantity))
return false;
if (reactantData.Value.Catalyst)
{
// catalyst is not consumed, so will not limit the reaction. But it still needs to be present, and
// for quantized reactions we need to have a minimum amount
if (reactantQuantity == FixedPoint2.Zero || reaction.Quantized && reactantQuantity < reactantCoefficient)
return false;
continue;
}
var unitReactions = reactantQuantity / reactantCoefficient;
if (unitReactions < lowestUnitReactions)
@@ -53,7 +64,11 @@ namespace Content.Shared.Chemistry.Reaction
lowestUnitReactions = unitReactions;
}
}
return true;
if (reaction.Quantized)
lowestUnitReactions = (int) lowestUnitReactions;
return lowestUnitReactions > 0;
}
/// <summary>

View File

@@ -1,7 +1,10 @@
using System.Collections.Generic;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Kitchen
@@ -19,21 +22,21 @@ namespace Content.Shared.Kitchen
[DataField("name")]
private string _name = string.Empty;
[DataField("reagents")]
private readonly Dictionary<string, int> _ingsReagents = new();
[DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<uint, ReagentPrototype>))]
private readonly Dictionary<string, uint> _ingsReagents = new();
[DataField("solids")]
private readonly Dictionary<string, int> _ingsSolids = new ();
[DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<uint, EntityPrototype>))]
private readonly Dictionary<string, uint> _ingsSolids = new ();
[DataField("result")]
[DataField("result", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Result { get; } = string.Empty;
[DataField("time")]
public int CookTime { get; } = 5;
public uint CookTime { get; } = 5;
public string Name => Loc.GetString(_name);
public IReadOnlyDictionary<string, int> IngredientsReagents => _ingsReagents;
public IReadOnlyDictionary<string, int> IngredientsSolids => _ingsSolids;
public IReadOnlyDictionary<string, uint> IngredientsReagents => _ingsReagents;
public IReadOnlyDictionary<string, uint> IngredientsSolids => _ingsSolids;
}
}