* Rename SolutionContainerCaps -> Capability * Move IExamine event to Chemistry System. * ECS the ISolutionChange into SolutionChangeEvent * Unify SolutionContainer into a single shared component * Replace ISolutionInteraction with SolutionContainerComponent * Move all methods from SolutionContainer to ChemistrySystem * Refactor EntitySystem calls to Dependencies * Refactor SolutionContainer to SolutionManager * Fix yamls * Fix test fails * Fix post merge issues * Fix various issues with SolutionManager * More fixes * Fix more components * Fix events not being directed * Fixes for Hypospray * Separate removal and iteration on Metabolism * Fix creampie problems * Address some of sloth's issues * Refactors for Systems * Refactored solution location * Fix tests * Address more sloth issues * Fix dependency * Fix merge conflicts * Add xmldocs for Capabilities components * Remove HasSolution/TryGetDefaultSolution and Add/Remove Drainable/Refillable * Replace Grindable/Juiceable with Extractable * Refactor field names * Fix Drainable * Fix some issues with spillable and injector * Fix issues with Grinder * Fix Beaker having duplicate solutions * Fix foaming * Address some MGS issues * Fix Uid issues * Fix errors in solution Tranfer * Fixed some extra values constant values * Cola is drinkable now
63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using Content.Server.Body.Circulatory;
|
|
using Content.Server.Body.Respiratory;
|
|
using Content.Shared.Chemistry;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.Smoking;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.Server.Chemistry.Components
|
|
{
|
|
[RegisterComponent]
|
|
[ComponentReference(typeof(SolutionAreaEffectComponent))]
|
|
public class SmokeSolutionAreaEffectComponent : SolutionAreaEffectComponent
|
|
{
|
|
public override string Name => "SmokeSolutionAreaEffect";
|
|
public const string SolutionName = "smoke";
|
|
|
|
protected override void UpdateVisuals()
|
|
{
|
|
if (Owner.TryGetComponent(out AppearanceComponent? appearance) &&
|
|
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
|
{
|
|
appearance.SetData(SmokeVisuals.Color, solution.Color);
|
|
}
|
|
}
|
|
|
|
protected override void ReactWithEntity(IEntity entity, double solutionFraction)
|
|
{
|
|
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
|
return;
|
|
|
|
if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream))
|
|
return;
|
|
|
|
if (entity.TryGetComponent(out InternalsComponent? internals) &&
|
|
internals.AreInternalsWorking())
|
|
return;
|
|
|
|
var chemistry = EntitySystem.Get<ChemistrySystem>();
|
|
var cloneSolution = solution.Clone();
|
|
var transferAmount = ReagentUnit.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.EmptyVolume);
|
|
var transferSolution = cloneSolution.SplitSolution(transferAmount);
|
|
|
|
foreach (var reagentQuantity in transferSolution.Contents.ToArray())
|
|
{
|
|
if (reagentQuantity.Quantity == ReagentUnit.Zero) continue;
|
|
chemistry.ReactionEntity(entity, ReactionMethod.Ingestion, reagentQuantity.ReagentId, reagentQuantity.Quantity, transferSolution);
|
|
}
|
|
|
|
bloodstream.TryTransferSolution(transferSolution);
|
|
}
|
|
|
|
|
|
protected override void OnKill()
|
|
{
|
|
if (Owner.Deleted)
|
|
return;
|
|
Owner.Delete();
|
|
}
|
|
}
|
|
}
|