From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Wed, 15 Feb 2023 19:06:45 +0000 (-0500) Subject: artifact soups (#14067) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=4adfec95484ffbad394a37b246fb77f82e0da278;p=space-station-14.git artifact soups (#14067) --- diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs index 261c64b9a8..b0a12c9509 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs @@ -229,9 +229,9 @@ public sealed partial class ArtifactSystem : EntitySystem /// /// /// - public bool TryGetNodeData(EntityUid uid, string key, [NotNullWhen(true)] out T data, ArtifactComponent? component = null) + public bool TryGetNodeData(EntityUid uid, string key, [NotNullWhen(true)] out T? data, ArtifactComponent? component = null) { - data = default!; + data = default; if (!Resolve(uid, ref component)) return false; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChemicalPuddleArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChemicalPuddleArtifactComponent.cs new file mode 100644 index 0000000000..fb05b425b4 --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/ChemicalPuddleArtifactComponent.cs @@ -0,0 +1,40 @@ +using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.Reagent; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; + +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; + +/// +/// This is used for an artifact that creates a puddle of +/// random chemicals upon being triggered. +/// +[RegisterComponent, Access(typeof(ChemicalPuddleArtifactSystem))] +public sealed class ChemicalPuddleArtifactComponent : Component +{ + /// + /// The prototype id of the puddle + /// + [DataField("puddlePrototype", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] + public string PuddlePrototype = "PuddleSmear"; + + /// + /// The solution where all the chemicals are stored + /// + [DataField("chemicalSolution", required: true), ViewVariables(VVAccess.ReadWrite)] + public Solution ChemicalSolution = default!; + + /// + /// The different chemicals that can be spawned by this effect + /// + [DataField("possibleChemicals", required: true, customTypeSerializer: typeof(PrototypeIdListSerializer))] + public List PossibleChemicals = default!; + + /// + /// The number of chemicals in the puddle + /// + [DataField("chemAmount")] + public int ChemAmount = 3; +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChemicalPuddleArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChemicalPuddleArtifactSystem.cs new file mode 100644 index 0000000000..96729ca49f --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ChemicalPuddleArtifactSystem.cs @@ -0,0 +1,54 @@ +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 SpillableSystem _spillable = default!; + + /// + /// The key for the node data entry containing + /// the chemicals that the puddle is made of. + /// + public const string NodeDataChemicalList = "nodeDataSpawnAmount"; + + /// + 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); + } + + _spillable.SpillAt(uid, component.ChemicalSolution, component.PuddlePrototype); + } +} diff --git a/Resources/Prototypes/XenoArch/Effects/normal_effects.yml b/Resources/Prototypes/XenoArch/Effects/normal_effects.yml index e3a18cfbb6..e68e75fb0a 100644 --- a/Resources/Prototypes/XenoArch/Effects/normal_effects.yml +++ b/Resources/Prototypes/XenoArch/Effects/normal_effects.yml @@ -122,6 +122,38 @@ spawns: - id: FoodBanana +- type: artifactEffect + id: EffectChemicalPuddle + targetDepth: 1 + effectHint: artifact-effect-hint-biochemical + components: + - type: ChemicalPuddleArtifact + chemicalSolution: + maxVol: 500 + canReact: false + possibleChemicals: + - Aluminium + - Carbon + - Chlorine + - Copper + - Ethanol + - Fluorine + - Sugar + - Hydrogen + - Iodine + - Iron + - Lithium + - Mercury + - Nitrogen + - Oxygen + - Phosphorus + - Potassium + - Radium + - Silicon + - Sodium + - Water + - Sulfur + - type: artifactEffect id: EffectCold targetDepth: 1 @@ -275,11 +307,37 @@ reagents: - Dermaline - Arithrazine - - Spaceacillin + - Bicaridine + - Inaprovaline + - Kelotane + - Dexalin + - Omnizine + +- type: artifactEffect + id: EffectChemicalPuddleRare + targetDepth: 2 + effectHint: artifact-effect-hint-biochemical + components: + - type: ChemicalPuddleArtifact + chemicalSolution: + maxVol: 500 + canReact: false + possibleChemicals: + - Dermaline + - Arithrazine + - Bicaridine - Inaprovaline - Kelotane - Dexalin - Omnizine + - Napalm + - Toxin + - Epinephrine + - Cognizine + - Ultravasculine + - Desoxyephedrine + - Pax + - Siderlac - type: artifactEffect id: EffectHealAll