mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Remove Shared System IPrototypeManager instances * Remove RecipeManager IPrototypeManager instance * Fix ItemSystem IPrototypeManager refs, use TryComp * SharedItemSystem changes, EntWhitelist CompName * HasComponent->HasComp
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.FixedPoint;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Chemistry;
|
|
|
|
[UsedImplicitly]
|
|
public sealed partial class ReactiveSystem : EntitySystem
|
|
{
|
|
|
|
// TODO: Someone add documentation, I beg you
|
|
public void DoEntityReaction(EntityUid uid, Solution solution, ReactionMethod method)
|
|
{
|
|
foreach (var reagent in solution.Contents.ToArray())
|
|
{
|
|
ReactionEntity(uid, method, reagent);
|
|
}
|
|
}
|
|
|
|
public void ReactionEntity(EntityUid uid, ReactionMethod method, ReagentQuantity reagentQuantity)
|
|
{
|
|
if (reagentQuantity.Quantity == FixedPoint2.Zero)
|
|
return;
|
|
|
|
// We throw if the reagent specified doesn't exist.
|
|
if (!ProtoMan.Resolve<ReagentPrototype>(reagentQuantity.Reagent.Prototype, out var proto))
|
|
return;
|
|
|
|
var ev = new ReactionEntityEvent(method, reagentQuantity, proto);
|
|
RaiseLocalEvent(uid, ref ev);
|
|
}
|
|
}
|
|
public enum ReactionMethod
|
|
{
|
|
Touch,
|
|
Injection,
|
|
Ingestion,
|
|
}
|
|
|
|
[ByRefEvent]
|
|
public readonly record struct ReactionEntityEvent(ReactionMethod Method, ReagentQuantity ReagentQuantity, ReagentPrototype Reagent);
|