2021-03-05 01:08:38 +01:00
|
|
|
|
using System.Linq;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Server.Cleanable;
|
|
|
|
|
|
using Content.Server.Coordinates.Helpers;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
using Content.Shared.Chemistry;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Chemistry.Reaction;
|
|
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-11-03 16:48:03 -07:00
|
|
|
|
using Content.Shared.FixedPoint;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
using Robust.Shared.Map;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Chemistry.TileReactions
|
|
|
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataDefinition]
|
2020-10-13 13:40:05 +02:00
|
|
|
|
public class CleanTileReaction : ITileReaction
|
|
|
|
|
|
{
|
2021-11-25 00:06:13 -06:00
|
|
|
|
|
|
|
|
|
|
[DataField("cleanAmountMultiplier")]
|
|
|
|
|
|
public float CleanAmountMultiplier { get; private set; } = 1.0f;
|
|
|
|
|
|
|
2021-11-03 16:48:03 -07:00
|
|
|
|
FixedPoint2 ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume)
|
2020-10-13 13:40:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
var entities = tile.GetEntitiesInTileFast().ToArray();
|
2021-11-03 16:48:03 -07:00
|
|
|
|
var amount = FixedPoint2.Zero;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
foreach (var entity in entities)
|
|
|
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
|
if (entity.TryGetComponent(out CleanableComponent? cleanable))
|
2020-10-13 13:40:05 +02:00
|
|
|
|
{
|
2021-11-25 00:06:13 -06:00
|
|
|
|
var next = (amount + cleanable.CleanAmount) * CleanAmountMultiplier;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
// Nothing left?
|
|
|
|
|
|
if (reactVolume < next)
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
amount = next;
|
2021-05-26 18:43:12 +02:00
|
|
|
|
entity.QueueDelete();
|
2020-10-13 13:40:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return amount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|