using Content.Server.Fluids.EntitySystems; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; /// /// This handles /// public sealed class ChemicalPuddleArtifactSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly ArtifactSystem _artifact = default!; [Dependency] private readonly PuddleSystem _puddle = default!; /// /// The key for the node data entry containing /// the chemicals that the puddle is made of. /// public const string NodeDataChemicalList = "nodeDataChemicalList"; /// public override void Initialize() { SubscribeLocalEvent(OnActivated); } private void OnActivated(EntityUid uid, ChemicalPuddleArtifactComponent component, ArtifactActivatedEvent args) { if (!TryComp(uid, out var artifact)) return; if (!_artifact.TryGetNodeData(uid, NodeDataChemicalList, out List? chemicalList, artifact)) { chemicalList = new(); for (var i = 0; i < component.ChemAmount; i++) { var chemProto = _random.Pick(component.PossibleChemicals); chemicalList.Add(chemProto); } _artifact.SetNodeData(uid, NodeDataChemicalList, chemicalList, artifact); } var amountPerChem = component.ChemicalSolution.MaxVolume / component.ChemAmount; foreach (var reagent in chemicalList) { component.ChemicalSolution.AddReagent(reagent, amountPerChem); } _puddle.TrySpillAt(uid, component.ChemicalSolution, out _); } }