using Content.Server.Body.Circulatory; using Content.Server.Chemistry.Components; using Content.Shared.Chemistry.Components.SolutionManager; using Content.Shared.Chemistry.EntitySystems; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Physics.Dynamics; namespace Content.Server.Chemistry.EntitySystems { [UsedImplicitly] internal sealed class SolutionInjectOnCollideSystem : EntitySystem { [Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(HandleInit); SubscribeLocalEvent(HandleInjection); } private void HandleInit(EntityUid uid, SolutionInjectOnCollideComponent component, ComponentInit args) { component.Owner .EnsureComponentWarn($"{nameof(SolutionInjectOnCollideComponent)} requires a SolutionContainerManager on {component.Owner}!"); } private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, StartCollideEvent args) { if (!args.OtherFixture.Body.Owner.TryGetComponent(out var bloodstream) || !_solutionsSystem.TryGetInjectableSolution(component.Owner.Uid, out var solution)) return; var solRemoved = solution.SplitSolution(component.TransferAmount); var solRemovedVol = solRemoved.TotalVolume; var solToInject = solRemoved.SplitSolution(solRemovedVol * component.TransferEfficiency); bloodstream.TryTransferSolution(solToInject); } } }