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;
|
2021-12-03 15:35:57 +01:00
|
|
|
|
using Content.Server.Decals;
|
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;
|
2021-12-03 11:43:22 +01:00
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
2020-10-13 13:40:05 +02:00
|
|
|
|
using Robust.Shared.Map;
|
2021-12-03 15:35:57 +01:00
|
|
|
|
using Robust.Shared.Maths;
|
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-12-03 15:53:09 +01:00
|
|
|
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, 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-12-05 18:09:01 +01:00
|
|
|
|
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(entity);
|
2020-10-13 13:40:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-03 15:35:57 +01:00
|
|
|
|
var decalSystem = EntitySystem.Get<DecalSystem>();
|
|
|
|
|
|
foreach (var uid in decalSystem.GetDecalsInRange(tile.GridIndex, tile.GridIndices+new Vector2(0.5f, 0.5f), validDelegate: x => x.Cleanable))
|
|
|
|
|
|
{
|
|
|
|
|
|
decalSystem.RemoveDecal(tile.GridIndex, uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-13 13:40:05 +02:00
|
|
|
|
return amount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|