mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Everything except the YAML slop... * She solution on my manager till I sajfslkahfsjakfhaskjfshajksafhfsakhfasjfas * another 1000 lines * fix chem dispenser size * go my shnelf * Implicit ass * rider is being mean for some reason * dasdas * borger * better formatting go! * clothes/bloodstream * Cartons * cups and bottles * mmm soder * bar drinks * Spray bottles and some size tweaks with hindsight * 99 bottles of beer on the wall I hate YAML * push that shit * mmm burger * Sneed * sheets * condiments * mmm yummy * fridge yummyfood * meat... * sub 300 * burger... * bready * let them eat cake * does she know how to make a grilled cheese? * pizza pie! * misc shit * soup or salad * Food and drinks, vanquished * the cubes!!! * Almost free from YAML... * fix test fails and some yaml issues * fix prediction, almost done * fix all test fails * remove master merge artifacts and undo autonetworking * review and compatibility * graaah * unfuck master merge I hate github * merg conflicts * sfsa * ehoop * sadas * afsafsaasf * merge conflicts * fucked up the merge conflicts * merge conflict is fucked I might need to completely redo this branch * test fail * no calcium???? --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
67 lines
2.7 KiB
C#
67 lines
2.7 KiB
C#
using Content.Shared.Popups;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Interaction;
|
|
|
|
namespace Content.Shared.Chemistry.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// Entity system used to handle when solution containers are 'spiked'
|
|
/// with another entity. Triggers the source entity afterwards.
|
|
/// Uses refillable solution as the target solution, as that indicates
|
|
/// 'easy' refills.
|
|
///
|
|
/// Examples of spikable entity interactions include pills being dropped into glasses,
|
|
/// eggs being cracked into bowls, and so on.
|
|
/// </summary>
|
|
public sealed class SolutionSpikerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<RefillableSolutionComponent, InteractUsingEvent>(OnInteractUsing);
|
|
}
|
|
|
|
private void OnInteractUsing(Entity<RefillableSolutionComponent> entity, ref InteractUsingEvent args)
|
|
{
|
|
if (TrySpike(args.Used, (args.Target, entity.Comp), args.User))
|
|
args.Handled = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Immediately transfer all reagents from this entity, to the other entity.
|
|
/// The source entity will then be acted on by TriggerSystem.
|
|
/// </summary>
|
|
/// <param name="source">Source of the solution.</param>
|
|
/// <param name="target">Target to spike with the solution from source.</param>
|
|
/// <param name="user">User spiking the target solution.</param>
|
|
private bool TrySpike(Entity<SolutionSpikerComponent?> source,
|
|
Entity<RefillableSolutionComponent?> target,
|
|
EntityUid user)
|
|
{
|
|
if (!Resolve(source, ref source.Comp, false)
|
|
|| !_solution.TryGetRefillableSolution((target, target.Comp), out var targetSoln, out var targetSolution)
|
|
|| !_solution.TryGetSolution(source.Owner, source.Comp.SourceSolution, out _, out var sourceSolution))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (targetSolution.Volume == 0 && !source.Comp.IgnoreEmpty)
|
|
{
|
|
_popup.PopupClient(Loc.GetString(source.Comp.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user);
|
|
return false;
|
|
}
|
|
|
|
if (!_solution.ForceAddSolution(targetSoln.Value, sourceSolution))
|
|
return false;
|
|
|
|
_popup.PopupClient(Loc.GetString(source.Comp.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user);
|
|
sourceSolution.RemoveAllSolution();
|
|
if (source.Comp.Delete)
|
|
QueueDel(source);
|
|
|
|
return true;
|
|
}
|
|
}
|