2021-11-11 16:10:57 -07:00
|
|
|
|
using Content.Server.Body.Components;
|
2021-11-30 16:47:21 -07:00
|
|
|
|
using Content.Server.Body.Systems;
|
2021-10-29 13:40:15 +01:00
|
|
|
|
using Content.Server.Chemistry.EntitySystems;
|
2021-02-03 11:26:46 -03:00
|
|
|
|
using Content.Shared.Chemistry;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-11-03 16:48:03 -07:00
|
|
|
|
using Content.Shared.FixedPoint;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Smoking;
|
2021-02-03 11:26:46 -03:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 11:30:03 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2021-02-03 11:26:46 -03:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Chemistry.Components
|
2021-02-03 11:26:46 -03:00
|
|
|
|
{
|
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
|
[ComponentReference(typeof(SolutionAreaEffectComponent))]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class SmokeSolutionAreaEffectComponent : SolutionAreaEffectComponent
|
2021-02-03 11:26:46 -03:00
|
|
|
|
{
|
2021-12-08 17:04:21 +01:00
|
|
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
|
|
|
|
|
|
2021-11-22 01:40:14 -07:00
|
|
|
|
public new const string SolutionName = "solutionArea";
|
2021-02-03 11:26:46 -03:00
|
|
|
|
|
|
|
|
|
|
protected override void UpdateVisuals()
|
|
|
|
|
|
{
|
2021-12-08 17:04:21 +01:00
|
|
|
|
if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance) &&
|
2021-12-03 15:53:09 +01:00
|
|
|
|
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
2021-02-03 11:26:46 -03:00
|
|
|
|
{
|
2021-09-06 15:49:44 +02:00
|
|
|
|
appearance.SetData(SmokeVisuals.Color, solution.Color);
|
2021-02-03 11:26:46 -03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
|
protected override void ReactWithEntity(EntityUid entity, double solutionFraction)
|
2021-02-03 11:26:46 -03:00
|
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
|
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
2021-02-03 11:26:46 -03:00
|
|
|
|
return;
|
|
|
|
|
|
|
2021-12-08 17:04:21 +01:00
|
|
|
|
if (!_entMan.TryGetComponent(entity, out BloodstreamComponent? bloodstream))
|
2021-02-03 11:26:46 -03:00
|
|
|
|
return;
|
|
|
|
|
|
|
2021-12-08 17:04:21 +01:00
|
|
|
|
if (_entMan.TryGetComponent(entity, out InternalsComponent? internals) &&
|
2021-02-03 11:26:46 -03:00
|
|
|
|
internals.AreInternalsWorking())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2021-11-22 02:17:35 -07:00
|
|
|
|
var chemistry = EntitySystem.Get<ReactiveSystem>();
|
2021-09-06 15:49:44 +02:00
|
|
|
|
var cloneSolution = solution.Clone();
|
2022-02-17 15:00:41 -07:00
|
|
|
|
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.ChemicalSolution.AvailableVolume);
|
2021-02-03 11:26:46 -03:00
|
|
|
|
var transferSolution = cloneSolution.SplitSolution(transferAmount);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var reagentQuantity in transferSolution.Contents.ToArray())
|
|
|
|
|
|
{
|
2021-11-03 16:48:03 -07:00
|
|
|
|
if (reagentQuantity.Quantity == FixedPoint2.Zero) continue;
|
2021-12-03 15:53:09 +01:00
|
|
|
|
chemistry.ReactionEntity(entity, ReactionMethod.Ingestion, reagentQuantity.ReagentId, reagentQuantity.Quantity, transferSolution);
|
2021-02-03 11:26:46 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-30 16:47:21 -07:00
|
|
|
|
var bloodstreamSys = EntitySystem.Get<BloodstreamSystem>();
|
2022-02-17 15:00:41 -07:00
|
|
|
|
bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream);
|
2021-02-03 11:26:46 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnKill()
|
|
|
|
|
|
{
|
2021-12-09 12:29:27 +01:00
|
|
|
|
if (_entMan.Deleted(Owner))
|
2021-02-03 11:26:46 -03:00
|
|
|
|
return;
|
2021-12-08 17:04:21 +01:00
|
|
|
|
_entMan.DeleteEntity(Owner);
|
2021-02-03 11:26:46 -03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|