Files
tbd-station-14/Content.Server/Chemistry/EntitySystems/ReactionMixerSystem.cs
Verm 089c9cb967 You can bless more containers with a bible (#26526)
* Made more things blessable

* Removed junk

* Remove whatever that was

* Make bowls blessable

* New mixablesolution component, converted everything to work with it

* Fix minor mishaps

* Fix extra spaces in bottle yml

* Fix last extra space, fix bottle havign the wrong solution name

* Remvoe unneeded event(I think), fix alcohol bottles not being mixable

* I missed cans
2024-04-20 16:16:55 +10:00

44 lines
1.5 KiB
C#

using Content.Shared.Chemistry.Reaction;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Popups;
namespace Content.Server.Chemistry.EntitySystems;
public sealed partial class ReactionMixerSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainers = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ReactionMixerComponent, AfterInteractEvent>(OnAfterInteract);
}
private void OnAfterInteract(Entity<ReactionMixerComponent> entity, ref AfterInteractEvent args)
{
if (!args.Target.HasValue || !args.CanReach)
return;
var mixAttemptEvent = new MixingAttemptEvent(entity);
RaiseLocalEvent(entity, ref mixAttemptEvent);
if (mixAttemptEvent.Cancelled)
{
return;
}
if (!_solutionContainers.TryGetMixableSolution(args.Target.Value, out var solution, out _))
return;
_popup.PopupEntity(Loc.GetString(entity.Comp.MixMessage, ("mixed", Identity.Entity(args.Target.Value, EntityManager)), ("mixer", Identity.Entity(entity.Owner, EntityManager))), args.User, args.User);
_solutionContainers.UpdateChemicals(solution.Value, true, entity.Comp);
var afterMixingEvent = new AfterMixingEvent(entity, args.Target.Value);
RaiseLocalEvent(entity, afterMixingEvent);
}
}