-namespace Content.Server.Chemistry.Components;
+using Content.Shared.Chemistry.EntitySystems;
+using Robust.Shared.GameStates;
-[RegisterComponent]
+namespace Content.Shared.Chemistry.Components;
+
+[RegisterComponent, NetworkedComponent, Access(typeof(SolutionSpikerSystem))]
public sealed partial class SolutionSpikerComponent : Component
{
/// <summary>
/// The source solution to take the reagents from in order
/// to spike the other solution container.
/// </summary>
- [DataField]
- public string SourceSolution { get; private set; } = string.Empty;
+ [DataField(required: true)]
+ public string SourceSolution = string.Empty;
/// <summary>
/// If spiking with this entity should ignore empty containers or not.
/// </summary>
[DataField]
- public bool IgnoreEmpty { get; private set; }
+ public bool IgnoreEmpty;
+
+ /// <summary>
+ /// If true, the entity is deleted after spiking.
+ /// This is almost certainly what you want.
+ /// </summary>
+ [DataField]
+ public bool Delete = true;
/// <summary>
/// What should pop up when spiking with this entity.
/// </summary>
[DataField]
- public LocId Popup { get; private set; } = "spike-solution-generic";
+ public LocId Popup = "spike-solution-generic";
/// <summary>
/// What should pop up when spiking fails because the container was empty.
/// </summary>
[DataField]
- public LocId PopupEmpty { get; private set; } = "spike-solution-empty-generic";
+ public LocId PopupEmpty = "spike-solution-empty-generic";
}
-using Content.Server.Chemistry.Components;
-using Content.Server.Chemistry.Containers.EntitySystems;
-using Content.Server.Explosion.EntitySystems;
-using Content.Server.Popups;
+using Content.Shared.Popups;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Interaction;
-namespace Content.Server.Chemistry.EntitySystems;
+namespace Content.Shared.Chemistry.EntitySystems;
/// <summary>
/// Entity system used to handle when solution containers are 'spiked'
/// Examples of spikable entity interactions include pills being dropped into glasses,
/// eggs being cracked into bowls, and so on.
/// </summary>
-public sealed class SolutionSpikableSystem : EntitySystem
+public sealed class SolutionSpikerSystem : EntitySystem
{
- [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
- [Dependency] private readonly TriggerSystem _triggerSystem = default!;
- [Dependency] private readonly PopupSystem _popupSystem = default!;
+ [Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
public override void Initialize()
{
{
if (!Resolve(source, ref spikableSource, ref managerSource, false)
|| !Resolve(target, ref spikableTarget, ref managerTarget, false)
- || !_solutionContainerSystem.TryGetRefillableSolution((target, spikableTarget, managerTarget), out var targetSoln, out var targetSolution)
- || !_solutionContainerSystem.TryGetSolution((source, managerSource), spikableSource.SourceSolution, out _, out var sourceSolution))
+ || !_solution.TryGetRefillableSolution((target, spikableTarget, managerTarget), out var targetSoln, out var targetSolution)
+ || !_solution.TryGetSolution((source, managerSource), spikableSource.SourceSolution, out _, out var sourceSolution))
{
return;
}
if (targetSolution.Volume == 0 && !spikableSource.IgnoreEmpty)
{
- _popupSystem.PopupEntity(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user);
+ _popup.PopupClient(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user);
return;
}
- if (!_solutionContainerSystem.ForceAddSolution(targetSoln.Value, sourceSolution))
+ if (!_solution.ForceAddSolution(targetSoln.Value, sourceSolution))
return;
- _popupSystem.PopupEntity(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user);
+ _popup.PopupClient(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user);
sourceSolution.RemoveAllSolution();
- _triggerSystem.Trigger(source, user);
+ if (spikableSource.Delete)
+ QueueDel(source);
}
}