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:
@@ -4,9 +4,9 @@ using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Cooldown;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Fluids;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Notification.Managers;
|
||||
@@ -30,6 +30,7 @@ namespace Content.Server.Fluids.Components
|
||||
internal sealed class SprayComponent : SharedSprayComponent, IAfterInteract, IUse, IActivate, IDropped
|
||||
{
|
||||
public const float SprayDistance = 3f;
|
||||
public const string SolutionName = "spray";
|
||||
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
@@ -82,14 +83,19 @@ namespace Content.Server.Fluids.Components
|
||||
[DataField("safetySound")]
|
||||
public SoundSpecifier SafetySound { get; } = new SoundPathSpecifier("/Audio/Machines/button.ogg");
|
||||
|
||||
public ReagentUnit CurrentVolume => Owner.GetComponentOrNull<SolutionContainerComponent>()?.CurrentVolume ?? ReagentUnit.Zero;
|
||||
|
||||
public ReagentUnit CurrentVolume {
|
||||
get
|
||||
{
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution);
|
||||
return solution?.CurrentVolume ?? ReagentUnit.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Owner.EnsureComponentWarn(out SolutionContainerComponent _);
|
||||
|
||||
if (_hasSafety)
|
||||
{
|
||||
SetSafety(Owner, _safety);
|
||||
@@ -124,7 +130,7 @@ namespace Content.Server.Fluids.Components
|
||||
if (eventArgs.ClickLocation.GetGridId(entManager) != playerPos.GetGridId(entManager))
|
||||
return true;
|
||||
|
||||
if (!Owner.TryGetComponent(out SolutionContainerComponent? contents))
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var contents))
|
||||
return true;
|
||||
|
||||
var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized;
|
||||
@@ -148,7 +154,7 @@ namespace Content.Server.Fluids.Components
|
||||
if (target.TryDistance(Owner.EntityManager, playerPos, out var distance) && distance > SprayDistance)
|
||||
target = eventArgs.User.Transform.Coordinates.Offset(diffNorm * SprayDistance);
|
||||
|
||||
var solution = contents.SplitSolution(_transferAmount);
|
||||
var solution = EntitySystem.Get<SolutionContainerSystem>().SplitSolution(Owner.Uid, contents, _transferAmount);
|
||||
|
||||
if (solution.TotalVolume <= ReagentUnit.Zero)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user