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,10 +1,10 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Chemistry.Solution;
|
||||
using Content.Shared.Chemistry.Solution.Components;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -13,7 +13,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
|
||||
namespace Content.Server.Administration.Verbs
|
||||
{
|
||||
[GlobalVerb]
|
||||
@@ -34,9 +33,8 @@ namespace Content.Server.Administration.Verbs
|
||||
{
|
||||
// ISolutionInteractionsComponent doesn't exactly have an interface for "admin tries to refill this", so...
|
||||
// Still have a path for SolutionContainerComponent in case it doesn't allow direct refilling.
|
||||
if (!target.HasComponent<SolutionContainerComponent>()
|
||||
&& !(target.TryGetComponent(out ISolutionInteractionsComponent? interactions)
|
||||
&& interactions.CanInject))
|
||||
if (!(target.HasComponent<SolutionContainerManagerComponent>()
|
||||
&& target.HasComponent<InjectableSolutionComponent>()))
|
||||
{
|
||||
data.Visibility = VerbVisibility.Invisible;
|
||||
return;
|
||||
@@ -87,7 +85,8 @@ namespace Content.Server.Administration.Verbs
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
if (_target.TryGetComponent(out SolutionContainerComponent? container))
|
||||
if (EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(_target, "default", out var container))
|
||||
{
|
||||
return new AdminAddReagentEuiState
|
||||
{
|
||||
@@ -96,16 +95,6 @@ namespace Content.Server.Administration.Verbs
|
||||
};
|
||||
}
|
||||
|
||||
if (_target.TryGetComponent(out ISolutionInteractionsComponent? interactions))
|
||||
{
|
||||
return new AdminAddReagentEuiState
|
||||
{
|
||||
// We don't exactly have an absolute total volume so good enough.
|
||||
CurVolume = ReagentUnit.Zero,
|
||||
MaxVolume = interactions.InjectSpaceAvailable
|
||||
};
|
||||
}
|
||||
|
||||
return new AdminAddReagentEuiState
|
||||
{
|
||||
CurVolume = ReagentUnit.Zero,
|
||||
@@ -131,15 +120,21 @@ namespace Content.Server.Administration.Verbs
|
||||
|
||||
var id = doAdd.ReagentId;
|
||||
var amount = doAdd.Amount;
|
||||
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
|
||||
|
||||
if (_target.TryGetComponent(out SolutionContainerComponent? container))
|
||||
{
|
||||
container.TryAddReagent(id, amount, out _);
|
||||
}
|
||||
else if (_target.TryGetComponent(out ISolutionInteractionsComponent? interactions))
|
||||
if (_target.TryGetComponent(out InjectableSolutionComponent? injectable)
|
||||
&& solutionsSys.TryGetSolution(_target, injectable.Name, out var targetSolution))
|
||||
{
|
||||
var solution = new Solution(id, amount);
|
||||
interactions.Inject(solution);
|
||||
solutionsSys.Inject(_target.Uid, targetSolution, solution);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO decide how to find the solution
|
||||
if (solutionsSys.TryGetSolution(_target, "default", out var solution))
|
||||
{
|
||||
solutionsSys.TryAddReagent(_target.Uid,solution, id, amount, out _);
|
||||
}
|
||||
}
|
||||
|
||||
StateDirty();
|
||||
|
||||
Reference in New Issue
Block a user