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:
Ygg01
2021-09-06 15:49:44 +02:00
committed by GitHub
parent b8911d58ac
commit c209e3f29b
166 changed files with 4268 additions and 3278 deletions

View File

@@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Coordinates.Helpers;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Solution;
using Content.Shared.Chemistry.Solution.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -23,7 +23,8 @@ namespace Content.Server.Fluids.Components
/// <param name="prototype">The prototype to use.</param>
/// <param name="sound">Play the spill sound.</param>
/// <returns>The puddle if one was created, null otherwise.</returns>
public static PuddleComponent? SpillAt(this Solution solution, IEntity entity, string prototype, bool sound = true)
public static PuddleComponent? SpillAt(this Solution solution, IEntity entity, string prototype,
bool sound = true)
{
return solution.SpillAt(entity.Transform.Coordinates, prototype, sound);
}
@@ -39,7 +40,8 @@ namespace Content.Server.Fluids.Components
/// <param name="puddle">The puddle if one was created, null otherwise.</param>
/// <param name="sound">Play the spill sound.</param>
/// <returns>True if a puddle was created, false otherwise.</returns>
public static bool TrySpillAt(this Solution solution, IEntity entity, string prototype, [NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true)
public static bool TrySpillAt(this Solution solution, IEntity entity, string prototype,
[NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true)
{
puddle = solution.SpillAt(entity, prototype, sound);
return puddle != null;
@@ -53,14 +55,16 @@ namespace Content.Server.Fluids.Components
/// <param name="prototype">The prototype to use.</param>
/// <param name="sound">Whether or not to play the spill sound.</param>
/// <returns>The puddle if one was created, null otherwise.</returns>
public static PuddleComponent? SpillAt(this Solution solution, EntityCoordinates coordinates, string prototype, bool overflow = true, bool sound = true)
public static PuddleComponent? SpillAt(this Solution solution, EntityCoordinates coordinates, string prototype,
bool overflow = true, bool sound = true)
{
if (solution.TotalVolume == 0) return null;
var mapManager = IoCManager.Resolve<IMapManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!mapManager.TryGetGrid(coordinates.GetGridId(entityManager), out var mapGrid)) return null; // Let's not spill to space.
if (!mapManager.TryGetGrid(coordinates.GetGridId(entityManager), out var mapGrid))
return null; // Let's not spill to space.
return SpillAt(mapGrid.GetTileRef(coordinates), solution, prototype, overflow, sound);
}
@@ -74,13 +78,15 @@ namespace Content.Server.Fluids.Components
/// <param name="puddle">The puddle if one was created, null otherwise.</param>
/// <param name="sound">Play the spill sound.</param>
/// <returns>True if a puddle was created, false otherwise.</returns>
public static bool TrySpillAt(this Solution solution, EntityCoordinates coordinates, string prototype, [NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true)
public static bool TrySpillAt(this Solution solution, EntityCoordinates coordinates, string prototype,
[NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true)
{
puddle = solution.SpillAt(coordinates, prototype, sound);
return puddle != null;
}
public static bool TryGetPuddle(this TileRef tileRef, GridTileLookupSystem? gridTileLookupSystem, [NotNullWhen(true)] out PuddleComponent? puddle)
public static bool TryGetPuddle(this TileRef tileRef, GridTileLookupSystem? gridTileLookupSystem,
[NotNullWhen(true)] out PuddleComponent? puddle)
{
foreach (var entity in tileRef.GetEntitiesInTileFast(gridTileLookupSystem))
{
@@ -95,7 +101,8 @@ namespace Content.Server.Fluids.Components
return false;
}
public static PuddleComponent? SpillAt(this TileRef tileRef, Solution solution, string prototype, bool overflow = true, bool sound = true)
public static PuddleComponent? SpillAt(this TileRef tileRef, Solution solution, string prototype,
bool overflow = true, bool sound = true)
{
if (solution.TotalVolume <= 0) return null;
@@ -116,15 +123,18 @@ namespace Content.Server.Fluids.Components
PuddleComponent? puddle = null;
var spilt = false;
var spillEntities = IoCManager.Resolve<IEntityLookup>().GetEntitiesIntersecting(mapGrid.ParentMapId, spillGridCoords.Position).ToArray();
var spillEntities = IoCManager.Resolve<IEntityLookup>()
.GetEntitiesIntersecting(mapGrid.ParentMapId, spillGridCoords.Position).ToArray();
foreach (var spillEntity in spillEntities)
{
if (spillEntity.TryGetComponent(out ISolutionInteractionsComponent? solutionContainerComponent) &&
solutionContainerComponent.CanRefill)
if (EntitySystem.Get<SolutionContainerSystem>()
.TryGetRefillableSolution(spillEntity.Uid, out var solutionContainerComponent))
{
solutionContainerComponent.Refill(
solution.SplitSolution(ReagentUnit.Min(solutionContainerComponent.RefillSpaceAvailable, solutionContainerComponent.MaxSpillRefill))
);
EntitySystem.Get<SolutionContainerSystem>().Refill(spillEntity.Uid, solutionContainerComponent,
solution.SplitSolution(ReagentUnit.Min(
solutionContainerComponent.AvailableVolume,
solutionContainerComponent.MaxSpillRefill))
);
}
}