* 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
44 lines
1.5 KiB
C#
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);
|
|
}
|
|
}
|