using Content.Server.Fluids.EntitySystems;
using Content.Server.Forensics.Components;
using Content.Server.Popups;
+using Content.Shared.Chemistry.Components;
using Content.Shared.DoAfter;
using Content.Shared.Forensics;
using Content.Shared.Interaction;
SubscribeLocalEvent<DnaComponent, BeingGibbedEvent>(OnBeingGibbed);
SubscribeLocalEvent<ForensicsComponent, MeleeHitEvent>(OnMeleeHit);
+ SubscribeLocalEvent<ForensicsComponent, GotRehydratedEvent>(OnRehydrated);
SubscribeLocalEvent<CleansForensicsComponent, AfterInteractEvent>(OnAfterInteract, after: new[] { typeof(AbsorbentSystem) });
SubscribeLocalEvent<ForensicsComponent, CleanForensicsDoAfterEvent>(OnCleanForensicsDoAfter);
SubscribeLocalEvent<DnaComponent, TransferDnaEvent>(OnTransferDnaEvent);
}
}
+ private void OnRehydrated(Entity<ForensicsComponent> ent, ref GotRehydratedEvent args)
+ {
+ CopyForensicsFrom(ent.Comp, args.Target);
+ }
+
+ /// <summary>
+ /// Copy forensic information from a source entity to a destination.
+ /// Existing forensic information on the target is still kept.
+ /// </summary>
+ public void CopyForensicsFrom(ForensicsComponent src, EntityUid target)
+ {
+ var dest = EnsureComp<ForensicsComponent>(target);
+ foreach (var dna in src.DNAs)
+ {
+ dest.DNAs.Add(dna);
+ }
+
+ foreach (var fiber in src.Fibers)
+ {
+ dest.Fibers.Add(fiber);
+ }
+
+ foreach (var print in src.Fingerprints)
+ {
+ dest.Fingerprints.Add(print);
+ }
+ }
+
private void OnAfterInteract(EntityUid uid, CleansForensicsComponent component, AfterInteractEvent args)
{
if (args.Handled)
-using Content.Server.Chemistry.Components;
using Content.Server.Friends.Components;
using Content.Server.NPC.Components;
using Content.Server.NPC.Systems;
+using Content.Shared.Chemistry.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
-using Content.Server.Chemistry.EntitySystems;
+using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
-namespace Content.Server.Chemistry.Components;
+namespace Content.Shared.Chemistry.Components;
/// <summary>
/// Basically, monkey cubes.
/// <summary>
/// The reagent that must be present to count as hydrated.
/// </summary>
- [DataField("catalyst", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>)), ViewVariables(VVAccess.ReadWrite)]
- public string CatalystPrototype = "Water";
+ [DataField("catalyst")]
+ public ProtoId<ReagentPrototype> CatalystPrototype = "Water";
/// <summary>
/// The minimum amount of catalyst that must be present to be hydrated.
/// </summary>
- [DataField("catalystMinimum"), ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public FixedPoint2 CatalystMinimum = FixedPoint2.Zero;
/// <summary>
/// The entity to create when hydrated.
/// </summary>
- [DataField("possibleSpawns"), ViewVariables(VVAccess.ReadWrite)]
- public List<string> PossibleSpawns = new();
+ [DataField(required: true)]
+ public List<EntProtoId> PossibleSpawns = new();
}
/// <summary>
-using Content.Server.Chemistry.Components;
-using Content.Server.Chemistry.Containers.EntitySystems;
-using Content.Shared.Chemistry.EntitySystems;
+using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using Content.Shared.Popups;
using Robust.Shared.Random;
-namespace Content.Server.Chemistry.EntitySystems;
+namespace Content.Shared.Chemistry.EntitySystems;
public sealed class RehydratableSystem : EntitySystem
{
- [Dependency] private readonly SharedPopupSystem _popups = default!;
- [Dependency] private readonly SolutionContainerSystem _solutions = default!;
[Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly SharedSolutionContainerSystem _solutions = default!;
+ [Dependency] private readonly SharedTransformSystem _xform = default!;
public override void Initialize()
{
SubscribeLocalEvent<RehydratableComponent, SolutionContainerChangedEvent>(OnSolutionChange);
}
- private void OnSolutionChange(Entity<RehydratableComponent> entity, ref SolutionContainerChangedEvent args)
+ private void OnSolutionChange(Entity<RehydratableComponent> ent, ref SolutionContainerChangedEvent args)
{
- var quantity = _solutions.GetTotalPrototypeQuantity(entity, entity.Comp.CatalystPrototype);
- if (quantity != FixedPoint2.Zero && quantity >= entity.Comp.CatalystMinimum)
+ var quantity = _solutions.GetTotalPrototypeQuantity(ent, ent.Comp.CatalystPrototype);
+ if (quantity != FixedPoint2.Zero && quantity >= ent.Comp.CatalystMinimum)
{
- Expand(entity);
+ Expand(ent);
}
}
// Try not to make this public if you can help it.
- private void Expand(Entity<RehydratableComponent> entity)
+ private void Expand(Entity<RehydratableComponent> ent)
{
- var (uid, comp) = entity;
-
- _popups.PopupEntity(Loc.GetString("rehydratable-component-expands-message", ("owner", uid)), uid);
+ var (uid, comp) = ent;
var randomMob = _random.Pick(comp.PossibleSpawns);
var target = Spawn(randomMob, Transform(uid).Coordinates);
+ _popup.PopupEntity(Loc.GetString("rehydratable-component-expands-message", ("owner", uid)), target);
- Transform(target).AttachToGridOrMap();
+ _xform.AttachToGridOrMap(target);
var ev = new GotRehydratedEvent(target);
RaiseLocalEvent(uid, ref ev);