using Content.Server.Fluids.EntitySystems; using Content.Server.Xenoarchaeology.Artifact.XAE.Components; using Content.Shared.Chemistry.Reagent; using Content.Shared.Xenoarchaeology.Artifact; using Content.Shared.Xenoarchaeology.Artifact.XAE; using Robust.Shared.Prototypes; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.Artifact.XAE; /// /// System for xeno artifact effect that creates puddle of chemical reagents under artifact. /// public sealed class XAECreatePuddleSystem: BaseXAESystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly PuddleSystem _puddle = default!; [Dependency] private readonly MetaDataSystem _metaData= default!; [Dependency] private readonly IPrototypeManager _prototypeManager= default!; /// public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnInit); } private void OnInit(EntityUid uid, XAECreatePuddleComponent component, MapInitEvent _) { if (component.PossibleChemicals == null || component.PossibleChemicals.Count == 0) return; if (component.SelectedChemicals == null) { var chemicalList = new List>(); var chemAmount = component.ChemAmount.Next(_random); for (var i = 0; i < chemAmount; i++) { var chemProto = _random.Pick(component.PossibleChemicals); chemicalList.Add(chemProto); } component.SelectedChemicals = chemicalList; } if (component.ReplaceDescription) { var reagentNames = new HashSet(); foreach (var chemProtoId in component.SelectedChemicals) { var reagent = _prototypeManager.Index(chemProtoId); reagentNames.Add(reagent.LocalizedName); } var reagentNamesStr = string.Join(", ", reagentNames); var newEntityDescription = Loc.GetString("xenoarch-effect-puddle", ("reagent", reagentNamesStr)); _metaData.SetEntityDescription(uid, newEntityDescription); } } /// protected override void OnActivated(Entity ent, ref XenoArtifactNodeActivatedEvent args) { var component = ent.Comp; if (component.SelectedChemicals == null) return; var amountPerChem = component.ChemicalSolution.MaxVolume / component.SelectedChemicals.Count; foreach (var reagent in component.SelectedChemicals) { component.ChemicalSolution.AddReagent(reagent, amountPerChem); } _puddle.TrySpillAt(ent, component.ChemicalSolution, out _); } }