Merge branch 'master' into 2021-12-03-remove-IEntity-komm-süsser-todd

# Conflicts:
#	Content.Client/Crayon/CrayonDecalVisualizer.cs
#	Content.Client/Tabletop/TabletopSystem.cs
#	Content.IntegrationTests/Tests/InventoryHelpersTest.cs
#	Content.Server/AI/EntitySystems/AiSystem.cs
#	Content.Server/AI/Utility/AiLogic/UtilityAI.cs
#	Content.Server/AME/AMENodeGroup.cs
#	Content.Server/Administration/AdminVerbSystem.cs
#	Content.Server/Body/Systems/RespiratorSystem.cs
#	Content.Server/Chemistry/Components/InjectorComponent.cs
#	Content.Server/Chemistry/TileReactions/CleanTileReaction.cs
#	Content.Server/Chemistry/TileReactions/SpillTileReaction.cs
#	Content.Server/Crayon/CrayonComponent.cs
#	Content.Server/Doors/Components/ServerDoorComponent.cs
#	Content.Server/Explosion/EntitySystems/TriggerSystem.cs
#	Content.Server/Fluids/Components/MopComponent.cs
#	Content.Server/Fluids/Components/SpillExtensions.cs
#	Content.Server/Fluids/EntitySystems/PuddleSystem.cs
#	Content.Server/Instruments/InstrumentSystem.cs
#	Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
#	Content.Server/Nutrition/EntitySystems/FoodSystem.cs
#	Content.Server/PneumaticCannon/PneumaticCannonSystem.cs
#	Content.Server/Storage/Components/EntityStorageComponent.cs
#	Content.Server/Storage/Components/StorageFillComponent.cs
#	Content.Server/Stunnable/StunbatonSystem.cs
#	Content.Server/Throwing/ThrowHelper.cs
#	Content.Server/Weapon/Ranged/Barrels/BarrelSystem.cs
#	Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs
#	Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs
#	Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs
#	Content.Shared/Damage/Components/DamageableComponent.cs
#	Content.Shared/Damage/Systems/DamageableSystem.cs
#	Content.Shared/MobState/Components/MobStateComponent.cs
#	Content.Shared/Slippery/SharedSlipperySystem.cs
This commit is contained in:
Vera Aguilera Puerto
2021-12-07 17:48:49 +01:00
171 changed files with 8579 additions and 6088 deletions

View File

@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
@@ -89,6 +90,7 @@ namespace Content.Server.Fluids.Components
* will spill some of the mop's solution onto the puddle which will evaporate eventually.
*/
var solutionSystem = EntitySystem.Get<SolutionContainerSystem>();
var spillableSystem = EntitySystem.Get<SpillableSystem>();
if (!solutionSystem.TryGetSolution(Owner, SolutionName, out var contents ) ||
Mopping ||
@@ -106,8 +108,8 @@ namespace Content.Server.Fluids.Components
if (eventArgs.Target is not {Valid: true} target)
{
// Drop the liquid on the mop on to the ground
solutionSystem.SplitSolution(Owner, contents, FixedPoint2.Min(ResidueAmount, CurrentVolume))
.SpillAt(eventArgs.ClickLocation, "PuddleSmear");
var solution = solutionSystem.SplitSolution(Owner, contents, FixedPoint2.Min(ResidueAmount, CurrentVolume));
spillableSystem.SpillAt(solution, eventArgs.ClickLocation, "PuddleSmear");
return true;
}
@@ -147,9 +149,9 @@ namespace Content.Server.Fluids.Components
// After cleaning the puddle, make a new puddle with solution from the mop as a "wet floor". Then evaporate it slowly.
// we do this WITHOUT adding to the existing puddle. Otherwise we have might have water puddles with the vomit sprite.
solutionSystem.SplitSolution(Owner, contents, transferAmount)
.SplitSolution(ResidueAmount)
.SpillAt(eventArgs.ClickLocation, "PuddleSmear", combine: false);
var splitSolution = solutionSystem.SplitSolution(Owner, contents, transferAmount)
.SplitSolution(ResidueAmount);
spillableSystem.SpillAt(splitSolution, eventArgs.ClickLocation, "PuddleSmear", combine: false);
}
else
{

View File

@@ -1,184 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Coordinates.Helpers;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Server.Fluids.Components
{
// TODO: Kill these with fire
public static class SpillExtensions
{
/// <summary>
/// Spills the specified solution at the entity's location if possible.
/// </summary>
/// <param name="entity">
/// The entity to use as a location to spill the solution at.
/// </param>
/// <param name="solution">Initial solution for the prototype.</param>
/// <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>
/// <param name="combine">Whether to attempt to merge with existing puddles</param>
public static PuddleComponent? SpillAt(this Solution solution, EntityUid entity, string prototype,
bool sound = true, bool combine = true)
{
return solution.SpillAt(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates, prototype, sound, combine: combine);
}
/// <summary>
/// Spills the specified solution at the entity's location if possible.
/// </summary>
/// <param name="entity">
/// The entity to use as a location to spill the solution at.
/// </param>
/// <param name="solution">Initial solution for the prototype.</param>
/// <param name="prototype">The prototype to use.</param>
/// <param name="puddle">The puddle if one was created, null otherwise.</param>
/// <param name="sound">Play the spill sound.</param>
/// <param name="combine">Whether to attempt to merge with existing puddles</param>
/// <returns>True if a puddle was created, false otherwise.</returns>
public static bool TrySpillAt(this Solution solution, EntityUid entity, string prototype,
[NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true, bool combine = true)
{
puddle = solution.SpillAt(entity, prototype, sound, combine: combine);
return puddle != null;
}
/// <summary>
/// Spills solution at the specified grid coordinates.
/// </summary>
/// <param name="solution">Initial solution for the prototype.</param>
/// <param name="coordinates">The coordinates to spill the solution at.</param>
/// <param name="prototype">The prototype to use.</param>
/// <param name="sound">Whether or not to play the spill sound.</param>
/// <param name="combine">Whether to attempt to merge with existing puddles</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, bool combine = 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.
return SpillAt(mapGrid.GetTileRef(coordinates), solution, prototype, overflow, sound, combine: combine);
}
/// <summary>
/// Spills the specified solution at the entity's location if possible.
/// </summary>
/// <param name="coordinates">The coordinates to spill the solution at.</param>
/// <param name="solution">Initial solution for the prototype.</param>
/// <param name="prototype">The prototype to use.</param>
/// <param name="puddle">The puddle if one was created, null otherwise.</param>
/// <param name="sound">Play the spill sound.</param>
/// <param name="combine">Whether to attempt to merge with existing puddles</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, bool combine = true)
{
puddle = solution.SpillAt(coordinates, prototype, sound, combine: combine);
return puddle != null;
}
public static bool TryGetPuddle(this TileRef tileRef, GridTileLookupSystem? gridTileLookupSystem,
[NotNullWhen(true)] out PuddleComponent? puddle)
{
foreach (var entity in tileRef.GetEntitiesInTileFast(gridTileLookupSystem))
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out PuddleComponent? p))
{
puddle = p;
return true;
}
}
puddle = null;
return false;
}
public static PuddleComponent? SpillAt(this TileRef tileRef, Solution solution, string prototype,
bool overflow = true, bool sound = true, bool noTileReact = false, bool combine = true)
{
if (solution.TotalVolume <= 0) return null;
// If space return early, let that spill go out into the void
if (tileRef.Tile.IsEmpty) return null;
var mapManager = IoCManager.Resolve<IMapManager>();
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
var gridId = tileRef.GridIndex;
if (!mapManager.TryGetGrid(gridId, out var mapGrid)) return null; // Let's not spill to invalid grids.
if (!noTileReact)
{
// First, do all tile reactions
foreach (var reagent in solution.Contents.ToArray())
{
var proto = prototypeManager.Index<ReagentPrototype>(reagent.ReagentId);
proto.ReactionTile(tileRef, reagent.Quantity);
}
}
// Tile reactions used up everything.
if (solution.CurrentVolume == FixedPoint2.Zero)
return null;
// Get normalized co-ordinate for spill location and spill it in the centre
// TODO: Does SnapGrid or something else already do this?
var spillGridCoords = mapGrid.GridTileToWorld(tileRef.GridIndices);
var spillEntities = IoCManager.Resolve<IEntityLookup>()
.GetEntitiesIntersecting(mapGrid.ParentMapId, spillGridCoords.Position).ToArray();
foreach (var spillEntity in spillEntities)
{
if (EntitySystem.Get<SolutionContainerSystem>()
.TryGetRefillableSolution(spillEntity, out var solutionContainerComponent))
{
EntitySystem.Get<SolutionContainerSystem>().Refill(spillEntity, solutionContainerComponent,
solution.SplitSolution(FixedPoint2.Min(
solutionContainerComponent.AvailableVolume,
solutionContainerComponent.MaxSpillRefill))
);
}
}
var puddleSystem = EntitySystem.Get<PuddleSystem>();
if (combine)
{
foreach (var spillEntity in spillEntities)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(spillEntity, out PuddleComponent? puddleComponent)) continue;
if (!overflow && puddleSystem.WouldOverflow(puddleComponent.Owner, solution, puddleComponent)) return null;
if (!puddleSystem.TryAddSolution(puddleComponent.Owner, solution, sound)) continue;
return puddleComponent;
}
}
var puddleEnt = serverEntityManager.SpawnEntity(prototype, spillGridCoords);
var newPuddleComponent = IoCManager.Resolve<IEntityManager>().GetComponent<PuddleComponent>(puddleEnt);
puddleSystem.TryAddSolution(newPuddleComponent.Owner, solution, sound);
return newPuddleComponent;
}
}
}