Clean up terrible solution entity reaction copy pasta.

This commit is contained in:
Pieter-Jan Briers
2021-01-23 16:49:22 +01:00
parent ae91059c0b
commit 85fcf7290c
6 changed files with 23 additions and 36 deletions

View File

@@ -3,6 +3,8 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
@@ -315,6 +317,20 @@ namespace Content.Shared.Chemistry
return newSolution;
}
public void DoEntityReaction(IEntity entity, ReactionMethod method)
{
var proto = IoCManager.Resolve<IPrototypeManager>();
foreach (var (reagentId, quantity) in _contents)
{
if (!proto.TryIndex(reagentId, out ReagentPrototype reagent))
continue;
var removedAmount = reagent.ReactionEntity(entity, method, quantity);
RemoveReagent(reagentId, removedAmount);
}
}
[Serializable, NetSerializable]
public readonly struct ReagentQuantity: IComparable<ReagentQuantity>
{