Solution refactor (#4407)
* Rename SolutionContainerCaps -> Capability * Move IExamine event to Chemistry System. * ECS the ISolutionChange into SolutionChangeEvent * Unify SolutionContainer into a single shared component * Replace ISolutionInteraction with SolutionContainerComponent * Move all methods from SolutionContainer to ChemistrySystem * Refactor EntitySystem calls to Dependencies * Refactor SolutionContainer to SolutionManager * Fix yamls * Fix test fails * Fix post merge issues * Fix various issues with SolutionManager * More fixes * Fix more components * Fix events not being directed * Fixes for Hypospray * Separate removal and iteration on Metabolism * Fix creampie problems * Address some of sloth's issues * Refactors for Systems * Refactored solution location * Fix tests * Address more sloth issues * Fix dependency * Fix merge conflicts * Add xmldocs for Capabilities components * Remove HasSolution/TryGetDefaultSolution and Add/Remove Drainable/Refillable * Replace Grindable/Juiceable with Extractable * Refactor field names * Fix Drainable * Fix some issues with spillable and injector * Fix issues with Grinder * Fix Beaker having duplicate solutions * Fix foaming * Address some MGS issues * Fix Uid issues * Fix errors in solution Tranfer * Fixed some extra values constant values * Cola is drinkable now
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Chemistry.Solution.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Notification;
|
||||
using Content.Shared.Notification.Managers;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -12,13 +11,13 @@ using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
|
||||
namespace Content.Server.Extinguisher
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class FireExtinguisherComponent : Component, IAfterInteract
|
||||
{
|
||||
public override string Name => "FireExtinguisher";
|
||||
private const string SolutionName = "fireExtinguisher";
|
||||
|
||||
[DataField("refillSound")] SoundSpecifier _refillSound = new SoundPathSpecifier("/Audio/Effects/refill.ogg");
|
||||
|
||||
@@ -27,24 +26,26 @@ namespace Content.Server.Extinguisher
|
||||
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
|
||||
if (eventArgs.Target == null || !eventArgs.CanReach)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eventArgs.Target.TryGetComponent(out ReagentTankComponent? tank)
|
||||
&& eventArgs.Target.TryGetComponent(out ISolutionInteractionsComponent? targetSolution)
|
||||
&& targetSolution.CanDrain
|
||||
&& Owner.TryGetComponent(out SolutionContainerComponent? container))
|
||||
var targetEntity = eventArgs.Target;
|
||||
if (eventArgs.Target.HasComponent<ReagentTankComponent>()
|
||||
&& solutionContainerSystem.TryGetDrainableSolution(targetEntity.Uid, out var targetSolution)
|
||||
&& solutionContainerSystem.TryGetSolution(Owner, SolutionName, out var container))
|
||||
{
|
||||
var trans = ReagentUnit.Min(container.EmptyVolume, targetSolution.DrainAvailable);
|
||||
if (trans > 0)
|
||||
var transfer = ReagentUnit.Min(container.AvailableVolume, targetSolution.DrainAvailable);
|
||||
if (transfer > 0)
|
||||
{
|
||||
var drained = targetSolution.Drain(trans);
|
||||
container.TryAddSolution(drained);
|
||||
var drained = solutionContainerSystem.Drain(targetEntity.Uid, targetSolution, transfer);
|
||||
solutionContainerSystem.TryAddSolution(Owner.Uid, container, drained);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _refillSound.GetSound(), Owner);
|
||||
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("fire-extinguisher-component-after-interact-refilled-message",("owner", Owner)));
|
||||
eventArgs.Target.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("fire-extinguisher-component-after-interact-refilled-message", ("owner", Owner)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user