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,69 +0,0 @@
|
||||
using Content.Server.GameObjects.Components.Chemistry;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.Interfaces;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.Atmos
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class GasSprayerComponent : Component, IAfterInteract
|
||||
{
|
||||
[Dependency] private readonly IServerEntityManager _serverEntityManager = default!;
|
||||
|
||||
//TODO: create a function that can create a gas based on a solution mix
|
||||
public override string Name => "GasSprayer";
|
||||
|
||||
private string _spraySound;
|
||||
private string _sprayType;
|
||||
private string _fuelType;
|
||||
private string _fuelName;
|
||||
private int _fuelCost;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _spraySound, "spraySound", string.Empty);
|
||||
serializer.DataField(ref _sprayType, "sprayType", string.Empty);
|
||||
serializer.DataField(ref _fuelType, "fuelType", string.Empty);
|
||||
serializer.DataField(ref _fuelName, "fuelName", "fuel");
|
||||
serializer.DataField(ref _fuelCost, "fuelCost", 50);
|
||||
}
|
||||
|
||||
public void AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out SolutionContainerComponent tank))
|
||||
return;
|
||||
|
||||
if (tank.Solution.GetReagentQuantity(_fuelType) == 0)
|
||||
{
|
||||
Owner.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("{0:theName} is out of {1}!", Owner, _fuelName));
|
||||
}
|
||||
else
|
||||
{
|
||||
tank.TryRemoveReagent(_fuelType, ReagentUnit.New(_fuelCost));
|
||||
|
||||
var playerPos = eventArgs.User.Transform.Coordinates;
|
||||
var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized;
|
||||
playerPos.Offset(direction/2);
|
||||
|
||||
var spray = _serverEntityManager.SpawnEntity(_sprayType, playerPos);
|
||||
spray.GetComponent<AppearanceComponent>()
|
||||
.SetData(ExtinguisherVisuals.Rotation, direction.ToAngle().Degrees);
|
||||
spray.GetComponent<GasVaporComponent>().StartMove(direction, 5);
|
||||
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_spraySound, Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
using Content.Server.Atmos.Reactions;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Atmos
|
||||
{
|
||||
[RegisterComponent]
|
||||
class GasVaporComponent : Component, ICollideBehavior, IGasMixtureHolder
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public override string Name => "GasVapor";
|
||||
|
||||
[ViewVariables] public GasMixture Air { get; set; }
|
||||
|
||||
private bool _running;
|
||||
private Vector2 _direction;
|
||||
private float _velocity;
|
||||
private float _disspateTimer = 0;
|
||||
private float _dissipationInterval;
|
||||
private Gas _gas;
|
||||
private float _gasVolume;
|
||||
private float _gasTemperature;
|
||||
private float _gasAmount;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
Air = new GasMixture(_gasVolume){Temperature = _gasTemperature};
|
||||
Air.SetMoles(_gas,_gasAmount);
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _dissipationInterval, "dissipationInterval", 1);
|
||||
serializer.DataField(ref _gas, "gas", Gas.WaterVapor);
|
||||
serializer.DataField(ref _gasVolume, "gasVolume", 200);
|
||||
serializer.DataField(ref _gasTemperature, "gasTemperature", Atmospherics.T20C);
|
||||
serializer.DataField(ref _gasAmount, "gasAmount", 20);
|
||||
}
|
||||
|
||||
public void StartMove(Vector2 dir, float velocity)
|
||||
{
|
||||
_running = true;
|
||||
_direction = dir;
|
||||
_velocity = velocity;
|
||||
|
||||
if (Owner.TryGetComponent(out ICollidableComponent collidable))
|
||||
{
|
||||
var controller = collidable.EnsureController<GasVaporController>();
|
||||
controller.Move(_direction, _velocity);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(float frameTime)
|
||||
{
|
||||
if (!_running)
|
||||
return;
|
||||
|
||||
if (Owner.TryGetComponent(out ICollidableComponent collidable))
|
||||
{
|
||||
var worldBounds = collidable.WorldAABB;
|
||||
var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID);
|
||||
|
||||
var tiles = mapGrid.GetTilesIntersecting(worldBounds);
|
||||
|
||||
foreach (var tile in tiles)
|
||||
{
|
||||
var pos = tile.GridIndices.ToEntityCoordinates(_mapManager, tile.GridIndex);
|
||||
var atmos = pos.GetTileAtmosphere(_entityManager);
|
||||
|
||||
if (atmos?.Air == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (atmos.Air.React(this) != ReactionResult.NoReaction)
|
||||
{
|
||||
Owner.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_disspateTimer += frameTime;
|
||||
if (_disspateTimer > _dissipationInterval)
|
||||
{
|
||||
Air.SetMoles(_gas, Air.TotalMoles/2 );
|
||||
}
|
||||
|
||||
if (Air.TotalMoles < 1)
|
||||
{
|
||||
Owner.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
void ICollideBehavior.CollideWith(IEntity collidedWith)
|
||||
{
|
||||
// Check for collision with a impassable object (e.g. wall) and stop
|
||||
if (collidedWith.TryGetComponent(out ICollidableComponent collidable) &&
|
||||
(collidable.CollisionLayer & (int) CollisionGroup.Impassable) != 0 &&
|
||||
collidable.Hard &&
|
||||
Owner.TryGetComponent(out ICollidableComponent coll))
|
||||
{
|
||||
var controller = coll.EnsureController<GasVaporController>();
|
||||
controller.Stop();
|
||||
Owner.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user