IReagentEffect and some chemistry stuff uses EntityUid
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
/// Perform a reaction on a solution. This assumes all reaction criteria are met.
|
||||
/// Removes the reactants from the solution, then returns a solution with all products.
|
||||
/// </summary>
|
||||
private Solution PerformReaction(Solution solution, IEntity owner, ReactionPrototype reaction, FixedPoint2 unitReactions)
|
||||
private Solution PerformReaction(Solution solution, EntityUid ownerUid, ReactionPrototype reaction, FixedPoint2 unitReactions)
|
||||
{
|
||||
//Remove reactants
|
||||
foreach (var reactant in reaction.Reactants)
|
||||
@@ -76,16 +76,16 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
}
|
||||
|
||||
// Trigger reaction effects
|
||||
OnReaction(solution, reaction, owner, unitReactions);
|
||||
OnReaction(solution, reaction, ownerUid, unitReactions);
|
||||
|
||||
return products;
|
||||
}
|
||||
|
||||
protected virtual void OnReaction(Solution solution, ReactionPrototype reaction, IEntity owner, FixedPoint2 unitReactions)
|
||||
protected virtual void OnReaction(Solution solution, ReactionPrototype reaction, EntityUid ownerUid, FixedPoint2 unitReactions)
|
||||
{
|
||||
foreach (var effect in reaction.Effects)
|
||||
{
|
||||
effect.React(solution, owner, unitReactions.Double());
|
||||
effect.React(solution, ownerUid, unitReactions.Double(), EntityManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
/// Removes the reactants from the solution, then returns a solution with all products.
|
||||
/// WARNING: Does not trigger reactions between solution and new products.
|
||||
/// </summary>
|
||||
private Solution ProcessReactions(Solution solution, IEntity owner)
|
||||
private Solution ProcessReactions(Solution solution, EntityUid ownerUid)
|
||||
{
|
||||
//TODO: make a hashmap at startup and then look up reagents in the contents for a reaction
|
||||
var overallProducts = new Solution();
|
||||
@@ -102,7 +102,7 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
{
|
||||
if (CanReact(solution, reaction, out var unitReactions))
|
||||
{
|
||||
var reactionProducts = PerformReaction(solution, owner, reaction, unitReactions);
|
||||
var reactionProducts = PerformReaction(solution, ownerUid, reaction, unitReactions);
|
||||
overallProducts.AddSolution(reactionProducts);
|
||||
break;
|
||||
}
|
||||
@@ -113,29 +113,29 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
/// <summary>
|
||||
/// Continually react a solution until no more reactions occur.
|
||||
/// </summary>
|
||||
public void FullyReactSolution(Solution solution, IEntity owner)
|
||||
public void FullyReactSolution(Solution solution, EntityUid ownerUid)
|
||||
{
|
||||
for (var i = 0; i < MaxReactionIterations; i++)
|
||||
{
|
||||
var products = ProcessReactions(solution, owner);
|
||||
var products = ProcessReactions(solution, ownerUid);
|
||||
|
||||
if (products.TotalVolume <= 0)
|
||||
return;
|
||||
|
||||
solution.AddSolution(products);
|
||||
}
|
||||
Logger.Error($"{nameof(Solution)} on {owner} (Uid: {owner.Uid}) could not finish reacting in under {MaxReactionIterations} loops.");
|
||||
Logger.Error($"{nameof(Solution)} {ownerUid} could not finish reacting in under {MaxReactionIterations} loops.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Continually react a solution until no more reactions occur, with a volume constraint.
|
||||
/// If a reaction's products would exceed the max volume, some product is deleted.
|
||||
/// </summary>
|
||||
public void FullyReactSolution(Solution solution, IEntity owner, FixedPoint2 maxVolume)
|
||||
public void FullyReactSolution(Solution solution, EntityUid ownerUid, FixedPoint2 maxVolume)
|
||||
{
|
||||
for (var i = 0; i < MaxReactionIterations; i++)
|
||||
{
|
||||
var products = ProcessReactions(solution, owner);
|
||||
var products = ProcessReactions(solution, ownerUid);
|
||||
|
||||
if (products.TotalVolume <= 0)
|
||||
return;
|
||||
@@ -150,7 +150,7 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
|
||||
solution.AddSolution(products);
|
||||
}
|
||||
Logger.Error($"{nameof(Solution)} on {owner} (Uid: {owner.Uid}) could not finish reacting in under {MaxReactionIterations} loops.");
|
||||
Logger.Error($"{nameof(Solution)} {ownerUid} could not finish reacting in under {MaxReactionIterations} loops.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user