Files
tbd-station-14/Content.Shared/Chemistry/EntitySystems/ReactiveContainerSystem.cs
SlamBamActionman 4626904fa8 [#20285 fix] Carp Plush and Rehydratables can now be put into mop bucket (#33079)
* Make shark plush janitor-bucketable

* fix bucketed grey shark texture

* Make sprites less shiny and adapt copyright notice

* Made shark way way less shiny

* Allow carp plush and rehydratables in mop bucket.

* Remove old mop bucket shark sprites

* Fix post-merge bugs

* Fix errors

* Move ReactiveContainer stuff to shared

That should mean it is now predicted.

* Custom eject verb for the mop bucket

* Fixes OnSolutionChange, removes pop-up as there already is one.

* .ftl is not necessary as the custom pop-up was removed

* Review fixes

* Update Content.Shared/Chemistry/Components/ReactiveContainerComponent.cs

* Update Content.Shared/Chemistry/EntitySystems/ReactiveContainerSystem.cs

---------

Co-authored-by: Psychpsyo <psychpsyo@gmail.com>
Co-authored-by: Psychpsyo <60073468+Psychpsyo@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2024-10-31 19:46:19 +01:00

54 lines
2.0 KiB
C#

using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Robust.Shared.Containers;
namespace Content.Shared.Chemistry.EntitySystems;
public sealed class ReactiveContainerSystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly ReactiveSystem _reactiveSystem = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ReactiveContainerComponent, EntInsertedIntoContainerMessage>(OnInserted);
SubscribeLocalEvent<ReactiveContainerComponent, SolutionContainerChangedEvent>(OnSolutionChange);
}
private void OnInserted(EntityUid uid, ReactiveContainerComponent comp, EntInsertedIntoContainerMessage args)
{
// Only reactive entities can react with the solution
if (!HasComp<ReactiveComponent>(args.Entity))
return;
if (!_solutionContainerSystem.TryGetSolution(uid, comp.Solution, out _, out var solution))
return;
if (solution.Volume == 0)
return;
_reactiveSystem.DoEntityReaction(args.Entity, solution, ReactionMethod.Touch);
}
private void OnSolutionChange(EntityUid uid, ReactiveContainerComponent comp, SolutionContainerChangedEvent args)
{
if (!_solutionContainerSystem.TryGetSolution(uid, comp.Solution, out _, out var solution))
return;
if (solution.Volume == 0)
return;
if (!TryComp<ContainerManagerComponent>(uid, out var manager))
return;
if (!_containerSystem.TryGetContainer(uid, comp.Container, out var container))
return;
foreach (var entity in container.ContainedEntities)
{
if (!HasComp<ReactiveComponent>(entity))
continue;
_reactiveSystem.DoEntityReaction(entity, solution, ReactionMethod.Touch);
}
}
}