* Added the ability for blood to track DNA using ReagentData; Forensic Scanner now accounts for solution DNA, non-DNA holders have "Unknown DNA" * Removes touch DNA for puddles, adds DNA to vomit * DNA now leaves traces in containers and those marked without don't show DNA on scan (except for puddles), gibbed parts have DNA * Fix stupid metamorphic glass bug grrr * Removed SpillableComponent since DnaSubstanceTraceComponent is used instead * Removes data field from maps, adds DNA tracking for some missed items * Give default value, fix missing values. * Fixes recipe bug * Review changes * Make the Data list into a nullable type * Revert map changes * Move gibbed unknown DNA to forensicssystem
74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
using Content.Shared.Chemistry.Reaction;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Maps;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
using System.Numerics;
|
|
|
|
namespace Content.Server.Chemistry.TileReactions;
|
|
|
|
[DataDefinition]
|
|
public sealed partial class CreateEntityTileReaction : ITileReaction
|
|
{
|
|
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
public string Entity = default!;
|
|
|
|
[DataField]
|
|
public FixedPoint2 Usage = FixedPoint2.New(1);
|
|
|
|
/// <summary>
|
|
/// How many of the whitelisted entity can fit on one tile?
|
|
/// </summary>
|
|
[DataField]
|
|
public int MaxOnTile = 1;
|
|
|
|
/// <summary>
|
|
/// The whitelist to use when determining what counts as "max entities on a tile".0
|
|
/// </summary>
|
|
[DataField("maxOnTileWhitelist")]
|
|
public EntityWhitelist? Whitelist;
|
|
|
|
[DataField]
|
|
public float RandomOffsetMax = 0.0f;
|
|
|
|
public FixedPoint2 TileReact(TileRef tile,
|
|
ReagentPrototype reagent,
|
|
FixedPoint2 reactVolume,
|
|
IEntityManager entityManager,
|
|
List<ReagentData>? data)
|
|
{
|
|
if (reactVolume >= Usage)
|
|
{
|
|
if (Whitelist != null)
|
|
{
|
|
int acc = 0;
|
|
foreach (var ent in tile.GetEntitiesInTile())
|
|
{
|
|
var whitelistSystem = entityManager.System<EntityWhitelistSystem>();
|
|
if (whitelistSystem.IsWhitelistPass(Whitelist, ent))
|
|
acc += 1;
|
|
|
|
if (acc >= MaxOnTile)
|
|
return FixedPoint2.Zero;
|
|
}
|
|
}
|
|
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
|
var xoffs = random.NextFloat(-RandomOffsetMax, RandomOffsetMax);
|
|
var yoffs = random.NextFloat(-RandomOffsetMax, RandomOffsetMax);
|
|
|
|
var center = entityManager.System<TurfSystem>().GetTileCenter(tile);
|
|
var pos = center.Offset(new Vector2(xoffs, yoffs));
|
|
entityManager.SpawnEntity(Entity, pos);
|
|
|
|
return Usage;
|
|
}
|
|
|
|
return FixedPoint2.Zero;
|
|
}
|
|
}
|