Refactor Resolve and IEntity in SolutionContainerSystem (#5083)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Ygg01
2021-11-02 02:03:23 +01:00
committed by GitHub
parent a13e23528c
commit fc5fa67a56
30 changed files with 141 additions and 170 deletions

View File

@@ -41,7 +41,7 @@ namespace Content.IntegrationTests.Tests.Chemistry
beaker = entityManager.SpawnEntity("BluespaceBeaker", MapCoordinates.Nullspace); beaker = entityManager.SpawnEntity("BluespaceBeaker", MapCoordinates.Nullspace);
Assert.That(EntitySystem.Get<SolutionContainerSystem>() Assert.That(EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(beaker, "beaker", out component)); .TryGetSolution(beaker.Uid, "beaker", out component));
foreach (var (id, reactant) in reactionPrototype.Reactants) foreach (var (id, reactant) in reactionPrototype.Reactants)
{ {
Assert.That(EntitySystem.Get<SolutionContainerSystem>() Assert.That(EntitySystem.Get<SolutionContainerSystem>()

View File

@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
if (target == null if (target == null
|| target.Deleted || target.Deleted
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, DrinkComponent.DefaultSolutionName, out var drink)) || !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Uid, DrinkComponent.DefaultSolutionName, out var drink))
{ {
return 0.0f; return 0.0f;
} }

View File

@@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
var target = context.GetState<TargetEntityState>().GetValue(); var target = context.GetState<TargetEntityState>().GetValue();
if (target == null || target.Deleted || !target.TryGetComponent<FoodComponent>(out var foodComp) || if (target == null || target.Deleted || !target.TryGetComponent<FoodComponent>(out var foodComp) ||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, foodComp.SolutionName, out var food)) !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target.Uid, foodComp.SolutionName, out var food))
{ {
return 0.0f; return 0.0f;
} }

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Administration.UI
public override EuiStateBase GetNewState() public override EuiStateBase GetNewState()
{ {
if (EntitySystem.Get<SolutionContainerSystem>() if (EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(_target, "default", out var container)) .TryGetSolution(_target.Uid, "default", out var container))
{ {
return new AdminAddReagentEuiState return new AdminAddReagentEuiState
{ {
@@ -68,7 +68,7 @@ namespace Content.Server.Administration.UI
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>(); var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
if (_target.TryGetComponent(out InjectableSolutionComponent? injectable) if (_target.TryGetComponent(out InjectableSolutionComponent? injectable)
&& solutionsSys.TryGetSolution(_target, injectable.Name, out var targetSolution)) && solutionsSys.TryGetSolution(_target.Uid, injectable.Name, out var targetSolution))
{ {
var solution = new Solution(id, amount); var solution = new Solution(id, amount);
solutionsSys.Inject(_target.Uid, targetSolution, solution); solutionsSys.Inject(_target.Uid, targetSolution, solution);
@@ -76,7 +76,7 @@ namespace Content.Server.Administration.UI
else else
{ {
//TODO decide how to find the solution //TODO decide how to find the solution
if (solutionsSys.TryGetSolution(_target, "default", out var solution)) if (solutionsSys.TryGetSolution(_target.Uid, "default", out var solution))
{ {
solutionsSys.TryAddReagent(_target.Uid,solution, id, amount, out _); solutionsSys.TryAddReagent(_target.Uid,solution, id, amount, out _);
} }

View File

@@ -89,7 +89,7 @@ namespace Content.Server.Body.Behavior
{ {
get get
{ {
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, DefaultSolutionName, out var solution); EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, DefaultSolutionName, out var solution);
return solution; return solution;
} }
} }
@@ -134,7 +134,7 @@ namespace Content.Server.Body.Behavior
{ {
base.Startup(); base.Startup();
var solution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, DefaultSolutionName); var solution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, DefaultSolutionName);
solution.MaxVolume = InitialMaxVolume; solution.MaxVolume = InitialMaxVolume;
} }

View File

@@ -44,7 +44,7 @@ namespace Content.Server.Body.Circulatory
{ {
base.Initialize(); base.Initialize();
_internalSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, DefaultSolutionName); _internalSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, DefaultSolutionName);
if (_internalSolution != null) if (_internalSolution != null)
{ {
_internalSolution.MaxVolume = _initialMaxVolume; _internalSolution.MaxVolume = _initialMaxVolume;

View File

@@ -28,7 +28,7 @@ namespace Content.Server.Body.Metabolism
private void OnMetabolizerInit(EntityUid uid, MetabolizerComponent component, ComponentInit args) private void OnMetabolizerInit(EntityUid uid, MetabolizerComponent component, ComponentInit args)
{ {
_solutionContainerSystem.EnsureSolution(EntityManager.GetEntity(uid), component.SolutionName); _solutionContainerSystem.EnsureSolution(uid, component.SolutionName);
} }
public override void Update(float frameTime) public override void Update(float frameTime)
@@ -63,7 +63,7 @@ namespace Content.Server.Body.Metabolism
if (body != null) if (body != null)
{ {
if (body.Owner.HasComponent<BloodstreamComponent>() if (body.Owner.HasComponent<BloodstreamComponent>()
&& solutionsSys.TryGetSolution(body.Owner, comp.SolutionName, out solution) && solutionsSys.TryGetSolution(body.Owner.Uid, comp.SolutionName, out solution)
&& solution.CurrentVolume >= ReagentUnit.Zero) && solution.CurrentVolume >= ReagentUnit.Zero)
{ {
reagentList = solution.Contents; reagentList = solution.Contents;

View File

@@ -547,7 +547,7 @@ namespace Content.Server.Botany.Components
public void UpdateReagents() public void UpdateReagents()
{ {
var solutionSystem = EntitySystem.Get<SolutionContainerSystem>(); var solutionSystem = EntitySystem.Get<SolutionContainerSystem>();
if (!solutionSystem.TryGetSolution(Owner, SoilSolutionName, out var solution)) if (!solutionSystem.TryGetSolution(Owner.Uid, SoilSolutionName, out var solution))
return; return;
if (solution.TotalVolume <= 0 || MutationLevel >= 25) if (solution.TotalVolume <= 0 || MutationLevel >= 25)
@@ -725,7 +725,7 @@ namespace Content.Server.Botany.Components
var solutionSystem = EntitySystem.Get<SolutionContainerSystem>(); var solutionSystem = EntitySystem.Get<SolutionContainerSystem>();
if (solutionSystem.TryGetDrainableSolution(usingItem.Uid, out var solution) if (solutionSystem.TryGetDrainableSolution(usingItem.Uid, out var solution)
&& solutionSystem.TryGetSolution(Owner, SoilSolutionName, out var targetSolution)) && solutionSystem.TryGetSolution(Owner.Uid, SoilSolutionName, out var targetSolution))
{ {
var amount = ReagentUnit.New(5); var amount = ReagentUnit.New(5);
var sprayed = false; var sprayed = false;
@@ -812,7 +812,7 @@ namespace Content.Server.Botany.Components
("usingItem", usingItem), ("usingItem", usingItem),
("owner", Owner))); ("owner", Owner)));
if (solutionSystem.TryGetSolution(usingItem, produce.SolutionName, out var solution2)) if (solutionSystem.TryGetSolution(usingItem.Uid, produce.SolutionName, out var solution2))
{ {
// This deliberately discards overfill. // This deliberately discards overfill.
solutionSystem.TryAddSolution(usingItem.Uid, solution2, solutionSystem.TryAddSolution(usingItem.Uid, solution2,

View File

@@ -40,7 +40,7 @@ namespace Content.Server.Botany.Components
sprite.LayerSetState(0, Seed.PlantIconState); sprite.LayerSetState(0, Seed.PlantIconState);
} }
var solutionContainer = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName); var solutionContainer = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, SolutionName);
if (solutionContainer == null) if (solutionContainer == null)
{ {
Logger.Warning($"No solution container found in {nameof(ProduceComponent)}."); Logger.Warning($"No solution container found in {nameof(ProduceComponent)}.");

View File

@@ -49,7 +49,7 @@ namespace Content.Server.Chemistry.Components
private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
[ViewVariables] [ViewVariables]
private Solution BufferSolution => _bufferSolution ??= EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName); private Solution BufferSolution => _bufferSolution ??= EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, SolutionName);
private Solution? _bufferSolution; private Solution? _bufferSolution;
@@ -76,7 +76,7 @@ namespace Content.Server.Chemistry.Components
BeakerContainer = BeakerContainer =
ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-reagentContainerContainer"); ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-reagentContainerContainer");
_bufferSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName); _bufferSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, SolutionName);
UpdateUserInterface(); UpdateUserInterface();
} }
@@ -181,7 +181,7 @@ namespace Content.Server.Chemistry.Components
{ {
var beaker = BeakerContainer.ContainedEntity; var beaker = BeakerContainer.ContainedEntity;
if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) ||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var beakerSolution)) !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker.Uid, fits.Solution, out var beakerSolution))
{ {
return new ChemMasterBoundUserInterfaceState(Powered, false, ReagentUnit.New(0), ReagentUnit.New(0), return new ChemMasterBoundUserInterfaceState(Powered, false, ReagentUnit.New(0), ReagentUnit.New(0),
"", Owner.Name, new List<Solution.ReagentQuantity>(), BufferSolution.Contents, _bufferModeTransfer, "", Owner.Name, new List<Solution.ReagentQuantity>(), BufferSolution.Contents, _bufferModeTransfer,
@@ -230,7 +230,7 @@ namespace Content.Server.Chemistry.Components
var beaker = BeakerContainer.ContainedEntity; var beaker = BeakerContainer.ContainedEntity;
if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) ||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var beakerSolution)) !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker.Uid, fits.Solution, out var beakerSolution))
return; return;
if (isBuffer) if (isBuffer)
@@ -307,7 +307,7 @@ namespace Content.Server.Chemistry.Components
var bottle = Owner.EntityManager.SpawnEntity("ChemistryEmptyBottle01", Owner.Transform.Coordinates); var bottle = Owner.EntityManager.SpawnEntity("ChemistryEmptyBottle01", Owner.Transform.Coordinates);
var bufferSolution = BufferSolution.SplitSolution(actualVolume); var bufferSolution = BufferSolution.SplitSolution(actualVolume);
var bottleSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(bottle, "drink"); var bottleSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(bottle.Uid, "drink");
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(bottle.Uid, bottleSolution, bufferSolution); EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(bottle.Uid, bottleSolution, bufferSolution);
@@ -341,7 +341,7 @@ namespace Content.Server.Chemistry.Components
var bufferSolution = BufferSolution.SplitSolution(actualVolume); var bufferSolution = BufferSolution.SplitSolution(actualVolume);
var pillSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(pill, "food"); var pillSolution = EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(pill.Uid, "food");
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(pill.Uid, pillSolution, bufferSolution); EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(pill.Uid, pillSolution, bufferSolution);
//Try to give them the bottle //Try to give them the bottle

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.Components
protected override void UpdateVisuals() protected override void UpdateVisuals()
{ {
if (Owner.TryGetComponent(out AppearanceComponent? appearance) && if (Owner.TryGetComponent(out AppearanceComponent? appearance) &&
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
appearance.SetData(FoamVisuals.Color, solution.Color.WithAlpha(0.80f)); appearance.SetData(FoamVisuals.Color, solution.Color.WithAlpha(0.80f));
} }
@@ -31,7 +31,7 @@ namespace Content.Server.Chemistry.Components
protected override void ReactWithEntity(IEntity entity, double solutionFraction) protected override void ReactWithEntity(IEntity entity, double solutionFraction)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
return; return;
if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream)) if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream))

View File

@@ -57,7 +57,7 @@ namespace Content.Server.Chemistry.Components
} }
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>(); var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
solutionsSys.TryGetSolution(Owner, SolutionName, out var hypoSpraySolution); solutionsSys.TryGetSolution(Owner.Uid, SolutionName, out var hypoSpraySolution);
if (hypoSpraySolution == null || hypoSpraySolution.CurrentVolume == 0) if (hypoSpraySolution == null || hypoSpraySolution.CurrentVolume == 0)
{ {
@@ -124,7 +124,7 @@ namespace Content.Server.Chemistry.Components
public override ComponentState GetComponentState(ICommonSession player) public override ComponentState GetComponentState(ICommonSession player)
{ {
var solutionSys = Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>(); var solutionSys = Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
return solutionSys.TryGetSolution(Owner, SolutionName, out var solution) return solutionSys.TryGetSolution(Owner.Uid, SolutionName, out var solution)
? new HyposprayComponentState(solution.CurrentVolume, solution.MaxVolume) ? new HyposprayComponentState(solution.CurrentVolume, solution.MaxVolume)
: new HyposprayComponentState(ReagentUnit.Zero, ReagentUnit.Zero); : new HyposprayComponentState(ReagentUnit.Zero, ReagentUnit.Zero);
} }

View File

@@ -146,7 +146,7 @@ namespace Content.Server.Chemistry.Components
} }
else if (ToggleState == InjectorToggleMode.Draw) else if (ToggleState == InjectorToggleMode.Draw)
{ {
if (solutionsSys.TryGetDrawableSolution(targetEntity, out var drawableSolution)) if (solutionsSys.TryGetDrawableSolution(targetEntity.Uid, out var drawableSolution))
{ {
TryDraw(targetEntity, drawableSolution, eventArgs.User); TryDraw(targetEntity, drawableSolution, eventArgs.User);
} }
@@ -175,7 +175,7 @@ namespace Content.Server.Chemistry.Components
private void TryInjectIntoBloodstream(BloodstreamComponent targetBloodstream, IEntity user) private void TryInjectIntoBloodstream(BloodstreamComponent targetBloodstream, IEntity user)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>() if (!EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(user, SharedBloodstreamComponent.DefaultSolutionName, out var bloodstream) .TryGetSolution(user.Uid, SharedBloodstreamComponent.DefaultSolutionName, out var bloodstream)
|| bloodstream.CurrentVolume == 0) || bloodstream.CurrentVolume == 0)
return; return;
@@ -216,7 +216,7 @@ namespace Content.Server.Chemistry.Components
private void TryInject(IEntity targetEntity, Solution targetSolution, IEntity user, bool asRefill) private void TryInject(IEntity targetEntity, Solution targetSolution, IEntity user, bool asRefill)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution)
|| solution.CurrentVolume == 0) || solution.CurrentVolume == 0)
{ {
return; return;
@@ -259,7 +259,7 @@ namespace Content.Server.Chemistry.Components
private void AfterInject() private void AfterInject()
{ {
// Automatically set syringe to draw after completely draining it. // Automatically set syringe to draw after completely draining it.
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution)
&& solution.CurrentVolume == 0) && solution.CurrentVolume == 0)
{ {
ToggleState = InjectorToggleMode.Draw; ToggleState = InjectorToggleMode.Draw;
@@ -269,7 +269,7 @@ namespace Content.Server.Chemistry.Components
private void AfterDraw() private void AfterDraw()
{ {
// Automatically set syringe to inject after completely filling it. // Automatically set syringe to inject after completely filling it.
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution)
&& solution.AvailableVolume == 0) && solution.AvailableVolume == 0)
{ {
ToggleState = InjectorToggleMode.Inject; ToggleState = InjectorToggleMode.Inject;
@@ -278,7 +278,7 @@ namespace Content.Server.Chemistry.Components
private void TryDraw(IEntity targetEntity, Solution targetSolution, IEntity user) private void TryDraw(IEntity targetEntity, Solution targetSolution, IEntity user)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution)
|| solution.AvailableVolume == 0) || solution.AvailableVolume == 0)
{ {
return; return;
@@ -315,7 +315,7 @@ namespace Content.Server.Chemistry.Components
public override ComponentState GetComponentState(ICommonSession player) public override ComponentState GetComponentState(ICommonSession player)
{ {
Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>() Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
.TryGetSolution(Owner, SolutionName, out var solution); .TryGetSolution(Owner.Uid, SolutionName, out var solution);
var currentVolume = solution?.CurrentVolume ?? ReagentUnit.Zero; var currentVolume = solution?.CurrentVolume ?? ReagentUnit.Zero;
var maxVolume = solution?.MaxVolume ?? ReagentUnit.Zero; var maxVolume = solution?.MaxVolume ?? ReagentUnit.Zero;

View File

@@ -60,7 +60,7 @@ namespace Content.Server.Chemistry.Components
{ {
get get
{ {
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution); EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution);
return solution; return solution;
} }
} }
@@ -232,7 +232,7 @@ namespace Content.Server.Chemistry.Components
{ {
var beaker = BeakerContainer.ContainedEntity; var beaker = BeakerContainer.ContainedEntity;
if (beaker == null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || if (beaker == null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) ||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var solution)) !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker.Uid, fits.Solution, out var solution))
{ {
return new ReagentDispenserBoundUserInterfaceState(Powered, false, ReagentUnit.New(0), return new ReagentDispenserBoundUserInterfaceState(Powered, false, ReagentUnit.New(0),
ReagentUnit.New(0), ReagentUnit.New(0),
@@ -280,7 +280,7 @@ namespace Content.Server.Chemistry.Components
{ {
if (!HasBeaker || !BeakerContainer.ContainedEntity!.TryGetComponent(out FitsInDispenserComponent? fits) || if (!HasBeaker || !BeakerContainer.ContainedEntity!.TryGetComponent(out FitsInDispenserComponent? fits) ||
!EntitySystem.Get<SolutionContainerSystem>() !EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(BeakerContainer.ContainedEntity, fits.Solution, out var solution)) .TryGetSolution(BeakerContainer.ContainedEntity.Uid, fits.Solution, out var solution))
return; return;
EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(BeakerContainer.ContainedEntity!.Uid, solution); EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(BeakerContainer.ContainedEntity!.Uid, solution);
@@ -298,7 +298,7 @@ namespace Content.Server.Chemistry.Components
if (BeakerContainer.ContainedEntity is not {} contained || !contained.TryGetComponent(out FitsInDispenserComponent? fits) if (BeakerContainer.ContainedEntity is not {} contained || !contained.TryGetComponent(out FitsInDispenserComponent? fits)
|| !EntitySystem.Get<SolutionContainerSystem>() || !EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(BeakerContainer.ContainedEntity, fits.Solution, out var solution)) return; .TryGetSolution(BeakerContainer.ContainedEntity.Uid, fits.Solution, out var solution)) return;
EntitySystem.Get<SolutionContainerSystem>() EntitySystem.Get<SolutionContainerSystem>()
.TryAddReagent(BeakerContainer.ContainedEntity.Uid, solution, Inventory[dispenseIndex].ID, _dispenseAmount, out _); .TryAddReagent(BeakerContainer.ContainedEntity.Uid, solution, Inventory[dispenseIndex].ID, _dispenseAmount, out _);

View File

@@ -19,7 +19,7 @@ namespace Content.Server.Chemistry.Components
protected override void UpdateVisuals() protected override void UpdateVisuals()
{ {
if (Owner.TryGetComponent(out AppearanceComponent? appearance) && if (Owner.TryGetComponent(out AppearanceComponent? appearance) &&
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
appearance.SetData(SmokeVisuals.Color, solution.Color); appearance.SetData(SmokeVisuals.Color, solution.Color);
} }
@@ -27,7 +27,7 @@ namespace Content.Server.Chemistry.Components
protected override void ReactWithEntity(IEntity entity, double solutionFraction) protected override void ReactWithEntity(IEntity entity, double solutionFraction)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
return; return;
if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream)) if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream))

View File

@@ -85,7 +85,7 @@ namespace Content.Server.Chemistry.Components
return; return;
} }
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
effectComponent.TryAddSolution(solution.Clone()); effectComponent.TryAddSolution(solution.Clone());
} }
@@ -122,7 +122,7 @@ namespace Content.Server.Chemistry.Components
/// with the other area effects from the inception.</param> /// with the other area effects from the inception.</param>
public void React(float averageExposures) public void React(float averageExposures)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
return; return;
var chemistry = EntitySystem.Get<ChemistrySystem>(); var chemistry = EntitySystem.Get<ChemistrySystem>();
@@ -160,7 +160,7 @@ namespace Content.Server.Chemistry.Components
if (solution.TotalVolume == 0) if (solution.TotalVolume == 0)
return; return;
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solutionArea)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solutionArea))
return; return;
var addSolution = var addSolution =

View File

@@ -8,133 +8,124 @@ namespace Content.Server.Chemistry.EntitySystems
{ {
public partial class SolutionContainerSystem public partial class SolutionContainerSystem
{ {
public void Refill(EntityUid targetUid, Solution targetSolution, Solution addedSolution) public void Refill(EntityUid targetUid, Solution targetSolution, Solution addedSolution,
RefillableSolutionComponent? refillableSolution = null)
{ {
if (!EntityManager.HasComponent<RefillableSolutionComponent>(targetUid)) if (!Resolve(targetUid, ref refillableSolution, false))
return; return;
TryAddSolution(targetUid, targetSolution, addedSolution); TryAddSolution(targetUid, targetSolution, addedSolution);
} }
public void Inject(EntityUid targetUid, Solution targetSolution, Solution addedSolution) public void Inject(EntityUid targetUid, Solution targetSolution, Solution addedSolution,
InjectableSolutionComponent? injectableSolution = null)
{ {
if (!EntityManager.HasComponent<InjectableSolutionComponent>(targetUid)) if (!Resolve(targetUid, ref injectableSolution, false))
return; return;
TryAddSolution(targetUid, targetSolution, addedSolution); TryAddSolution(targetUid, targetSolution, addedSolution);
} }
public Solution Draw(EntityUid targetUid, Solution solution, ReagentUnit amount) public Solution Draw(EntityUid targetUid, Solution solution, ReagentUnit amount,
DrawableSolutionComponent? drawableSolution = null)
{ {
if (!EntityManager.HasComponent<DrawableSolutionComponent>(targetUid)) if (!Resolve(targetUid, ref drawableSolution, false))
{
return new Solution(); return new Solution();
}
return SplitSolution(targetUid, solution, amount); return SplitSolution(targetUid, solution, amount);
} }
public Solution Drain(EntityUid targetUid, Solution targetSolution, ReagentUnit amount) public Solution Drain(EntityUid targetUid, Solution targetSolution, ReagentUnit amount,
DrainableSolutionComponent? drainableSolution = null)
{ {
if (!EntityManager.HasComponent<DrainableSolutionComponent>(targetUid)) if (!Resolve(targetUid, ref drainableSolution, false))
{
return new Solution(); return new Solution();
}
return SplitSolution(targetUid, targetSolution, amount); return SplitSolution(targetUid, targetSolution, amount);
} }
public bool TryGetInjectableSolution(EntityUid targetUid, public bool TryGetInjectableSolution(EntityUid targetUid,
[NotNullWhen(true)] out Solution? solution) [NotNullWhen(true)] out Solution? solution,
InjectableSolutionComponent? injectable = null,
SolutionContainerManagerComponent? manager = null
)
{ {
if (EntityManager.TryGetComponent(targetUid, out InjectableSolutionComponent? injectable) && if (!Resolve(targetUid, ref manager, ref injectable, false)
EntityManager.TryGetComponent(targetUid, out SolutionContainerManagerComponent? manager) && || !manager.Solutions.TryGetValue(injectable.Solution, out solution))
manager.Solutions.TryGetValue(injectable.Solution, out solution))
{ {
return true; solution = null;
return false;
} }
solution = null; return true;
return false;
} }
public bool TryGetRefillableSolution(EntityUid targetUid, public bool TryGetRefillableSolution(EntityUid targetUid,
[NotNullWhen(true)] out Solution? solution) [NotNullWhen(true)] out Solution? solution,
SolutionContainerManagerComponent? solutionManager = null,
RefillableSolutionComponent? refillable = null)
{ {
if (EntityManager.TryGetComponent(targetUid, out RefillableSolutionComponent? refillable) && if (!Resolve(targetUid, ref solutionManager, ref refillable, false)
EntityManager.TryGetComponent(targetUid, out SolutionContainerManagerComponent? manager) && || !solutionManager.Solutions.TryGetValue(refillable.Solution, out var refillableSolution))
manager.Solutions.TryGetValue(refillable.Solution, out var refillableSolution))
{ {
solution = refillableSolution; solution = null;
return true; return false;
} }
solution = null; solution = refillableSolution;
return false; return true;
} }
public bool TryGetDrainableSolution(EntityUid targetUid, public bool TryGetDrainableSolution(EntityUid uid,
[NotNullWhen(true)] out Solution? solution) [NotNullWhen(true)] out Solution? solution,
DrainableSolutionComponent? drainable = null,
SolutionContainerManagerComponent? manager = null)
{ {
if (EntityManager.TryGetComponent(targetUid,out DrainableSolutionComponent? drainable) && if (!Resolve(uid, ref drainable, ref manager, false)
EntityManager.TryGetComponent(targetUid,out SolutionContainerManagerComponent? manager) && || !manager.Solutions.TryGetValue(drainable.Solution, out solution))
manager.Solutions.TryGetValue(drainable.Solution, out solution))
{ {
return true; solution = null;
return false;
} }
solution = null; return true;
return false;
} }
public bool TryGetDrawableSolution(IEntity owner, public bool TryGetDrawableSolution(EntityUid uid,
[NotNullWhen(true)] out Solution? solution) [NotNullWhen(true)] out Solution? solution,
DrawableSolutionComponent? drawable = null,
SolutionContainerManagerComponent? manager = null)
{ {
if (owner.TryGetComponent(out DrawableSolutionComponent? drawable) && if (!Resolve(uid, ref drawable, ref manager, false)
owner.TryGetComponent(out SolutionContainerManagerComponent? manager) && || !manager.Solutions.TryGetValue(drawable.Solution, out solution))
manager.Solutions.TryGetValue(drawable.Solution, out solution))
{ {
return true; solution = null;
return false;
} }
solution = null; return true;
return false;
}
public ReagentUnit DrainAvailable(IEntity? owner)
{
if (owner == null || !TryGetDrainableSolution(owner.Uid, out var solution))
return ReagentUnit.Zero;
return solution.CurrentVolume;
} }
public ReagentUnit DrainAvailable(EntityUid uid) public ReagentUnit DrainAvailable(EntityUid uid)
{ {
if (!TryGetDrainableSolution(uid, out var solution)) return !TryGetDrainableSolution(uid, out var solution)
return ReagentUnit.Zero; ? ReagentUnit.Zero
: solution.CurrentVolume;
return solution.CurrentVolume;
}
public bool HasFitsInDispenser(IEntity owner)
{
return !owner.Deleted && owner.HasComponent<FitsInDispenserComponent>();
} }
public bool TryGetFitsInDispenser(EntityUid owner, public bool TryGetFitsInDispenser(EntityUid owner,
[NotNullWhen(true)] out Solution? solution) [NotNullWhen(true)] out Solution? solution,
FitsInDispenserComponent? dispenserFits = null,
SolutionContainerManagerComponent? solutionManager = null)
{ {
if (EntityManager.TryGetEntity(owner, out var ownerEntity) && if (!Resolve(owner, ref dispenserFits, ref solutionManager, false)
ownerEntity.TryGetComponent(out FitsInDispenserComponent? dispenserFits) && || !solutionManager.Solutions.TryGetValue(dispenserFits.Solution, out solution))
ownerEntity.TryGetComponent(out SolutionContainerManagerComponent? manager) &&
manager.Solutions.TryGetValue(dispenserFits.Solution, out solution))
{ {
return true; solution = null;
return false;
} }
solution = null; return true;
return false;
} }
} }
} }

View File

@@ -65,7 +65,8 @@ namespace Content.Server.Chemistry.EntitySystems
private void OnExamineSolution(EntityUid uid, ExaminableSolutionComponent examinableComponent, private void OnExamineSolution(EntityUid uid, ExaminableSolutionComponent examinableComponent,
ExaminedEvent args) ExaminedEvent args)
{ {
if (!args.Examined.TryGetComponent(out SolutionContainerManagerComponent? solutionsManager) SolutionContainerManagerComponent? solutionsManager = null;
if (!Resolve(args.Examined.Uid, ref solutionsManager)
|| !solutionsManager.Solutions.TryGetValue(examinableComponent.Solution, out var solutionHolder)) || !solutionsManager.Solutions.TryGetValue(examinableComponent.Solution, out var solutionHolder))
return; return;
@@ -96,15 +97,15 @@ namespace Content.Server.Chemistry.EntitySystems
("desc", Loc.GetString(proto.PhysicalDescription)))); ("desc", Loc.GetString(proto.PhysicalDescription))));
} }
private void UpdateAppearance(EntityUid uid, Solution solution) private void UpdateAppearance(EntityUid uid, Solution solution,
SharedAppearanceComponent? appearanceComponent = null)
{ {
if (!EntityManager.TryGetEntity(uid, out var solutionEntity) if (!EntityManager.EntityExists(uid)
|| solutionEntity.Deleted || !Resolve(uid, ref appearanceComponent, false))
|| !solutionEntity.TryGetComponent<SharedAppearanceComponent>(out var appearance))
return; return;
var filledVolumeFraction = solution.CurrentVolume.Float() / solution.MaxVolume.Float(); var filledVolumeFraction = solution.CurrentVolume.Float() / solution.MaxVolume.Float();
appearance.SetData(SolutionContainerVisuals.VisualState, new SolutionContainerVisualState(solution.Color, filledVolumeFraction)); appearanceComponent.SetData(SolutionContainerVisuals.VisualState, new SolutionContainerVisualState(solution.Color, filledVolumeFraction));
} }
/// <summary> /// <summary>
@@ -143,9 +144,9 @@ namespace Content.Server.Chemistry.EntitySystems
UpdateChemicals(uid, solutionHolder); UpdateChemicals(uid, solutionHolder);
} }
public void RemoveAllSolution(EntityUid uid) public void RemoveAllSolution(EntityUid uid, SolutionContainerManagerComponent? solutionContainerManager = null)
{ {
if (!EntityManager.TryGetComponent(uid, out SolutionContainerManagerComponent? solutionContainerManager)) if (!Resolve(uid, ref solutionContainerManager))
return; return;
foreach (var solution in solutionContainerManager.Solutions.Values) foreach (var solution in solutionContainerManager.Solutions.Values)
@@ -210,19 +211,9 @@ namespace Content.Server.Chemistry.EntitySystems
return true; return true;
} }
public bool TryGetSolution(IEntity? target, string name, public bool TryGetSolution(EntityUid uid, string name,
[NotNullWhen(true)] out Solution? solution, SolutionContainerManagerComponent? solutionsMgr = null) [NotNullWhen(true)] out Solution? solution,
{ SolutionContainerManagerComponent? solutionsMgr = null)
if (target == null || target.Deleted)
{
solution = null;
return false;
}
return TryGetSolution(target.Uid, name, out solution, solutionsMgr);
}
public bool TryGetSolution(EntityUid uid, string name, [NotNullWhen(true)] out Solution? solution, SolutionContainerManagerComponent? solutionsMgr = null)
{ {
if (!Resolve(uid, ref solutionsMgr)) if (!Resolve(uid, ref solutionsMgr))
{ {
@@ -233,17 +224,6 @@ namespace Content.Server.Chemistry.EntitySystems
return solutionsMgr.Solutions.TryGetValue(name, out solution); return solutionsMgr.Solutions.TryGetValue(name, out solution);
} }
/// <summary>
/// Will ensure a solution is added to given entity even if it's missing solutionContainerManager
/// </summary>
/// <param name="owner">Entity to which to add solution</param>
/// <param name="name">name for the solution</param>
/// <returns>solution</returns>
public Solution EnsureSolution(IEntity owner, string name)
{
return EnsureSolution(owner.Uid, name);
}
/// <summary> /// <summary>
/// Will ensure a solution is added to given entity even if it's missing solutionContainerManager /// Will ensure a solution is added to given entity even if it's missing solutionContainerManager
/// </summary> /// </summary>

View File

@@ -65,7 +65,7 @@ namespace Content.Server.Chemistry.EntitySystems
return false; return false;
} }
if (!_solutionContainerSystem.TryGetSolution(vapor.Owner, SharedVaporComponent.SolutionName, if (!_solutionContainerSystem.TryGetSolution(vapor.Owner.Uid, SharedVaporComponent.SolutionName,
out var vaporSolution)) out var vaporSolution))
{ {
return false; return false;

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.ReagentEntityReactions
{ {
// TODO see if this is correct // TODO see if this is correct
if (!EntitySystem.Get<SolutionContainerSystem>() if (!EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(entity, _solution, out var solutionContainer) .TryGetSolution(entity.Uid, _solution, out var solutionContainer)
|| (_reagents.Count > 0 && !_reagents.Contains(reagent.ID))) return; || (_reagents.Count > 0 && !_reagents.Contains(reagent.ID))) return;
if (EntitySystem.Get<SolutionContainerSystem>() if (EntitySystem.Get<SolutionContainerSystem>()

View File

@@ -29,19 +29,19 @@ namespace Content.Server.Fluids.Components
public ReagentUnit MaxVolume public ReagentUnit MaxVolume
{ {
get => get =>
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution)
? solution.MaxVolume ? solution.MaxVolume
: ReagentUnit.Zero; : ReagentUnit.Zero;
set set
{ {
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
solution.MaxVolume = value; solution.MaxVolume = value;
} }
} }
} }
public ReagentUnit CurrentVolume => EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) public ReagentUnit CurrentVolume => EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution)
? solution.CurrentVolume ? solution.CurrentVolume
: ReagentUnit.Zero; : ReagentUnit.Zero;
@@ -52,7 +52,7 @@ namespace Content.Server.Fluids.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{ {
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>(); var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
if (!solutionsSys.TryGetSolution(Owner, SolutionName, out var contents) || if (!solutionsSys.TryGetSolution(Owner.Uid, SolutionName, out var contents) ||
_currentlyUsing.Contains(eventArgs.Using.Uid) || _currentlyUsing.Contains(eventArgs.Using.Uid) ||
!eventArgs.Using.TryGetComponent(out MopComponent? mopComponent) || !eventArgs.Using.TryGetComponent(out MopComponent? mopComponent) ||
mopComponent.Mopping) mopComponent.Mopping)

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Fluids.Components
{ {
get get
{ {
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution); EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution);
return solution; return solution;
} }
} }
@@ -81,7 +81,7 @@ namespace Content.Server.Fluids.Components
* will spill some of the mop's solution onto the puddle which will evaporate eventually. * will spill some of the mop's solution onto the puddle which will evaporate eventually.
*/ */
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var contents ) || if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var contents ) ||
Mopping || Mopping ||
!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
{ {
@@ -156,7 +156,7 @@ namespace Content.Server.Fluids.Components
} }
else else
{ {
if (solutionSystem.TryGetSolution(eventArgs.Target, puddleComponent.SolutionName, out var puddleSolution)) if (solutionSystem.TryGetSolution(eventArgs.Target.Uid, puddleComponent.SolutionName, out var puddleSolution))
solutionSystem.SplitSolution(eventArgs.Target.Uid, puddleSolution, transferAmount); solutionSystem.SplitSolution(eventArgs.Target.Uid, puddleSolution, transferAmount);
} }

View File

@@ -16,7 +16,7 @@ namespace Content.Server.Fluids.Components
void IDropped.Dropped(DroppedEventArgs eventArgs) void IDropped.Dropped(DroppedEventArgs eventArgs)
{ {
if (!eventArgs.Intentional if (!eventArgs.Intentional
&& EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solutionComponent)) && EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solutionComponent))
{ {
EntitySystem.Get<SolutionContainerSystem>() EntitySystem.Get<SolutionContainerSystem>()
.Drain(Owner.Uid, solutionComponent, solutionComponent.DrainAvailable) .Drain(Owner.Uid, solutionComponent, solutionComponent.DrainAvailable)

View File

@@ -78,7 +78,7 @@ namespace Content.Server.Fluids.Components
public ReagentUnit CurrentVolume { public ReagentUnit CurrentVolume {
get get
{ {
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution); EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution);
return solution?.CurrentVolume ?? ReagentUnit.Zero; return solution?.CurrentVolume ?? ReagentUnit.Zero;
} }
} }
@@ -105,7 +105,7 @@ namespace Content.Server.Fluids.Components
if (eventArgs.ClickLocation.GetGridId(entManager) != playerPos.GetGridId(entManager)) if (eventArgs.ClickLocation.GetGridId(entManager) != playerPos.GetGridId(entManager))
return true; return true;
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var contents)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var contents))
return true; return true;
var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized; var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized;

View File

@@ -69,7 +69,7 @@ namespace Content.Server.Kitchen.Components
private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
private bool HasContents => EntitySystem.Get<SolutionContainerSystem>() private bool HasContents => EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(Owner, SolutionName, out var solution) && .TryGetSolution(Owner.Uid, SolutionName, out var solution) &&
(solution.Contents.Count > 0 || _storage.ContainedEntities.Count > 0); (solution.Contents.Count > 0 || _storage.ContainedEntities.Count > 0);
private bool _uiDirty = true; private bool _uiDirty = true;
@@ -92,7 +92,7 @@ namespace Content.Server.Kitchen.Components
_currentCookTimerTime = _cookTimeDefault; _currentCookTimerTime = _cookTimeDefault;
EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName); EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, SolutionName);
_storage = ContainerHelpers.EnsureContainer<Container>(Owner, "microwave_entity_container", _storage = ContainerHelpers.EnsureContainer<Container>(Owner, "microwave_entity_container",
out _); out _);
@@ -182,7 +182,7 @@ namespace Content.Server.Kitchen.Components
} }
if (_uiDirty && EntitySystem.Get<SolutionContainerSystem>() if (_uiDirty && EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(Owner, SolutionName, out var solution)) .TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState
( (
@@ -257,7 +257,7 @@ namespace Content.Server.Kitchen.Components
return false; return false;
} }
if (!solutionsSystem.TryGetSolution(Owner, SolutionName, out var solution)) if (!solutionsSystem.TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
return false; return false;
} }
@@ -388,7 +388,7 @@ namespace Content.Server.Kitchen.Components
private void VaporizeReagents() private void VaporizeReagents()
{ {
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(Owner.Uid, solution); EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(Owner.Uid, solution);
} }
@@ -396,7 +396,7 @@ namespace Content.Server.Kitchen.Components
private void VaporizeReagentQuantity(Solution.ReagentQuantity reagentQuantity) private void VaporizeReagentQuantity(Solution.ReagentQuantity reagentQuantity)
{ {
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
EntitySystem.Get<SolutionContainerSystem>() EntitySystem.Get<SolutionContainerSystem>()
.TryRemoveReagent(Owner.Uid, solution, reagentQuantity.ReagentId, reagentQuantity.Quantity); .TryRemoveReagent(Owner.Uid, solution, reagentQuantity.ReagentId, reagentQuantity.Quantity);
@@ -432,7 +432,7 @@ namespace Content.Server.Kitchen.Components
private void SubtractContents(FoodRecipePrototype recipe) private void SubtractContents(FoodRecipePrototype recipe)
{ {
var solutionUid = Owner.Uid; var solutionUid = Owner.Uid;
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
return; return;
} }
@@ -472,7 +472,7 @@ namespace Content.Server.Kitchen.Components
return MicrowaveSuccessState.RecipeFail; return MicrowaveSuccessState.RecipeFail;
} }
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
return MicrowaveSuccessState.RecipeFail; return MicrowaveSuccessState.RecipeFail;
} }

View File

@@ -308,7 +308,7 @@ namespace Content.Server.Kitchen.EntitySystems
{ {
if (!item.TryGetComponent(out ExtractableComponent? extract) if (!item.TryGetComponent(out ExtractableComponent? extract)
|| extract.GrindableSolution == null || extract.GrindableSolution == null
|| !_solutionsSystem.TryGetSolution(item, extract.GrindableSolution, out var solution)) continue; || !_solutionsSystem.TryGetSolution(item.Uid, extract.GrindableSolution, out var solution)) continue;
var juiceEvent = new ExtractableScalingEvent(); // default of scalar is always 1.0 var juiceEvent = new ExtractableScalingEvent(); // default of scalar is always 1.0
RaiseLocalEvent(item.Uid, juiceEvent, false); RaiseLocalEvent(item.Uid, juiceEvent, false);

View File

@@ -55,7 +55,7 @@ namespace Content.Server.Nutrition.Components
{ {
get get
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
return 0; return 0;
} }
@@ -101,7 +101,7 @@ namespace Content.Server.Nutrition.Components
public bool TryUseFood(IEntity? user, IEntity? target, UtensilComponent? utensilUsed = null) public bool TryUseFood(IEntity? user, IEntity? target, UtensilComponent? utensilUsed = null)
{ {
var solutionContainerSys = EntitySystem.Get<SolutionContainerSystem>(); var solutionContainerSys = EntitySystem.Get<SolutionContainerSystem>();
if (!solutionContainerSys.TryGetSolution(Owner, SolutionName, out var solution)) if (!solutionContainerSys.TryGetSolution(Owner.Uid, SolutionName, out var solution))
{ {
return false; return false;
} }

View File

@@ -48,7 +48,7 @@ namespace Content.Server.Nutrition.Components
Count = _totalCount; Count = _totalCount;
var foodComp = Owner.EnsureComponent<FoodComponent>(); var foodComp = Owner.EnsureComponent<FoodComponent>();
Owner.EnsureComponent<SolutionContainerManagerComponent>(); Owner.EnsureComponent<SolutionContainerManagerComponent>();
EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, foodComp.SolutionName); EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner.Uid, foodComp.SolutionName);
} }
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
@@ -60,7 +60,7 @@ namespace Content.Server.Nutrition.Components
var scs = EntitySystem.Get<SolutionContainerSystem>(); var scs = EntitySystem.Get<SolutionContainerSystem>();
if (!Owner.TryGetComponent<FoodComponent>(out var foodComp) || !scs.TryGetSolution(Owner, foodComp.SolutionName, out var solution)) if (!Owner.TryGetComponent<FoodComponent>(out var foodComp) || !scs.TryGetSolution(Owner.Uid, foodComp.SolutionName, out var solution))
{ {
return false; return false;
} }
@@ -80,7 +80,7 @@ namespace Content.Server.Nutrition.Components
// It might be an idea to remove the removal of Nutriment & clear the food // It might be an idea to remove the removal of Nutriment & clear the food
lostSolution.RemoveReagent("Nutriment", lostSolution.GetReagentQuantity("Nutriment")); lostSolution.RemoveReagent("Nutriment", lostSolution.GetReagentQuantity("Nutriment"));
// 3. Dump whatever we can into the slice // 3. Dump whatever we can into the slice
if (itemToSpawn.TryGetComponent<FoodComponent>(out var itsFoodComp) && scs.TryGetSolution(itemToSpawn, itsFoodComp.SolutionName, out var itsSolution)) if (itemToSpawn.TryGetComponent<FoodComponent>(out var itsFoodComp) && scs.TryGetSolution(itemToSpawn.Uid, itsFoodComp.SolutionName, out var itsSolution))
{ {
var lostSolutionPart = lostSolution.SplitSolution(itsSolution.AvailableVolume); var lostSolutionPart = lostSolution.SplitSolution(itsSolution.AvailableVolume);
scs.TryAddSolution(itemToSpawn.Uid, itsSolution, lostSolutionPart); scs.TryAddSolution(itemToSpawn.Uid, itsSolution, lostSolutionPart);

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Nutrition.EntitySystems
{ {
SoundSystem.Play(Filter.Pvs(creamPie.Owner), creamPie.Sound.GetSound(), creamPie.Owner, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(creamPie.Owner), creamPie.Sound.GetSound(), creamPie.Owner, AudioHelpers.WithVariation(0.125f));
if (creamPie.Owner.TryGetComponent<FoodComponent>(out var foodComp) && _solutionsSystem.TryGetSolution(creamPie.Owner, foodComp.SolutionName, out var solution)) if (creamPie.Owner.TryGetComponent<FoodComponent>(out var foodComp) && _solutionsSystem.TryGetSolution(creamPie.Owner.Uid, foodComp.SolutionName, out var solution))
{ {
solution.SpillAt(creamPie.Owner, "PuddleSmear", false); solution.SpillAt(creamPie.Owner, "PuddleSmear", false);
} }

View File

@@ -34,7 +34,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
private void TransferSolution(BarrelFiredMessage barrelFired) private void TransferSolution(BarrelFiredMessage barrelFired)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var ammoSolution)) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner.Uid, SolutionName, out var ammoSolution))
return; return;
var projectiles = barrelFired.FiredProjectiles; var projectiles = barrelFired.FiredProjectiles;
@@ -44,7 +44,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components
foreach (var projectile in projectiles) foreach (var projectile in projectiles)
{ {
if (EntitySystem.Get<SolutionContainerSystem>() if (EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(projectile, SolutionName, out var projectileSolutionContainer)) .TryGetSolution(projectile.Uid, SolutionName, out var projectileSolutionContainer))
{ {
projectileSolutionContainers.Add((projectile.Uid, projectileSolutionContainer)); projectileSolutionContainers.Add((projectile.Uid, projectileSolutionContainer));
} }