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:
Víctor Aguilera Puerto
2020-09-21 17:51:07 +02:00
committed by GitHub
parent 37d6ca556f
commit 69059eac80
51 changed files with 1006 additions and 471 deletions

View File

@@ -2,7 +2,10 @@
using System.Collections.Generic;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.Chemistry;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
@@ -13,8 +16,6 @@ namespace Content.Shared.Chemistry
[Prototype("reagent")]
public class ReagentPrototype : IPrototype, IIndexedPrototype
{
private const float CelsiusToKelvin = 273.15f;
[Dependency] private readonly IModuleManager _moduleManager = default!;
private string _id;
@@ -24,6 +25,7 @@ namespace Content.Shared.Chemistry
private Color _substanceColor;
private List<IMetabolizable> _metabolism;
private string _spritePath;
private List<ITileReaction> _tileReactions;
public string ID => _id;
public string Name => _name;
@@ -33,6 +35,7 @@ namespace Content.Shared.Chemistry
//List of metabolism effects this reagent has, should really only be used server-side.
public List<IMetabolizable> Metabolism => _metabolism;
public List<ITileReaction> TileReactions => _tileReactions;
public string SpriteReplacementPath => _spritePath;
public ReagentPrototype()
@@ -54,10 +57,12 @@ namespace Content.Shared.Chemistry
if (_moduleManager.IsServerModule)
{
serializer.DataField(ref _metabolism, "metabolism", new List<IMetabolizable> { new DefaultMetabolizable() });
serializer.DataField(ref _tileReactions, "tileReactions", new List<ITileReaction> { });
}
else
{
_metabolism = new List<IMetabolizable> { new DefaultMetabolizable() };
_tileReactions = new List<ITileReaction>();
}
}
@@ -78,5 +83,55 @@ namespace Content.Shared.Chemistry
return SubstanceColor;
}
public ReagentUnit ReactionEntity(IEntity entity, ReactionMethod method, ReagentUnit reactVolume)
{
var removed = ReagentUnit.Zero;
foreach (var react in entity.GetAllComponents<IReagentReaction>())
{
switch (method)
{
case ReactionMethod.Touch:
removed += react.ReagentReactTouch(this, reactVolume);
break;
case ReactionMethod.Ingestion:
removed += react.ReagentReactIngestion(this, reactVolume);
break;
case ReactionMethod.Injection:
removed += react.ReagentReactInjection(this, reactVolume);
break;
}
if (removed > reactVolume)
throw new Exception("Removed more than we have!");
if (removed == reactVolume)
break;
}
return removed;
}
public ReagentUnit ReactionTile(TileRef tile, ReagentUnit reactVolume)
{
var removed = ReagentUnit.Zero;
if (tile.Tile.IsEmpty)
return removed;
foreach (var reaction in _tileReactions)
{
removed += reaction.TileReact(tile, this, reactVolume - removed);
if (removed > reactVolume)
throw new Exception("Removed more than we have!");
if (removed == reactVolume)
break;
}
return removed;
}
}
}