Adds new different reaction types. (#2114)
* Adds new different reaction types. - Adds touch, injection and ingestion reactions for entities. - Adds tile reactions. - Removes GasSprayerComponent in favor of SprayComponent. - Gives fire extinguishers a safety. - Gives spray puffs a sprite. - Improved spray and fire extinguisher in general. - Fire extinguisher now ACTUALLY puts out fires. Amazing, eh? - Fire extinguisher sprays three 'clouds' at once. - Spraying flammable chemicals at fire makes them worse. Whoops! - Gives spray and fire extinguisher their classic sounds. - Most chemicals now don't make puddles. Too bad! - Space lube now makes a very slippery puddle. Honk. - Spraying water (or using a fire extinguisher) on existing puddles makes them bigger. * Fix solution tests * food base now has solution container with noexamine caps
This commit is contained in:
committed by
GitHub
parent
37d6ca556f
commit
69059eac80
@@ -1,6 +1,9 @@
|
||||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems.TileLookup;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
@@ -125,5 +128,78 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
puddle = solution.SpillAt(coordinates, prototype, sound);
|
||||
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 (entity.TryGetComponent(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)
|
||||
{
|
||||
if (solution.TotalVolume <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
||||
|
||||
var gridId = tileRef.GridIndex;
|
||||
|
||||
// If space return early, let that spill go out into the void
|
||||
if (tileRef.Tile.IsEmpty)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
PuddleComponent? puddle = null;
|
||||
|
||||
// Get normalized co-ordinate for spill location and spill it in the centre
|
||||
// TODO: Does SnapGrid or something else already do this?
|
||||
var spillTileMapGrid = mapManager.GetGrid(gridId);
|
||||
var spillGridCoords = spillTileMapGrid.GridTileToLocal(tileRef.GridIndices);
|
||||
|
||||
var spilt = false;
|
||||
|
||||
foreach (var spillEntity in entityManager.GetEntitiesAt(spillTileMapGrid.ParentMapId, spillGridCoords.Position))
|
||||
{
|
||||
if (!spillEntity.TryGetComponent(out PuddleComponent? puddleComponent))
|
||||
continue;
|
||||
|
||||
if (!overflow && puddleComponent.WouldOverflow(solution))
|
||||
return null;
|
||||
|
||||
if (!puddleComponent.TryAddSolution(solution, sound))
|
||||
continue;
|
||||
|
||||
puddle = puddleComponent;
|
||||
spilt = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Did we add to an existing puddle
|
||||
if (spilt)
|
||||
{
|
||||
return puddle;
|
||||
}
|
||||
|
||||
var puddleEnt = serverEntityManager.SpawnEntity(prototype, spillGridCoords);
|
||||
puddle = puddleEnt.GetComponent<PuddleComponent>();
|
||||
|
||||
puddle.TryAddSolution(solution, sound);
|
||||
|
||||
return puddle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user