Fix foam artifacts (#17332)

This commit is contained in:
Nemanja
2023-06-15 07:26:10 -04:00
committed by GitHub
parent bc3f42d822
commit d86effe630
3 changed files with 18 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry.Reagent; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
@@ -6,7 +7,7 @@ namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
/// <summary> /// <summary>
/// Generates foam from the artifact when activated /// Generates foam from the artifact when activated
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent, Access(typeof(FoamArtifactSystem))]
public sealed class FoamArtifactComponent : Component public sealed class FoamArtifactComponent : Component
{ {
/// <summary> /// <summary>
@@ -19,36 +20,30 @@ public sealed class FoamArtifactComponent : Component
/// <summary> /// <summary>
/// The foam reagent /// The foam reagent
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField("selectedReagent"), ViewVariables(VVAccess.ReadWrite)]
public string? SelectedReagent; public string? SelectedReagent;
/// <summary> /// <summary>
/// How long does the foam last? /// How long does the foam last?
/// </summary> /// </summary>
[DataField("duration")] [DataField("duration"), ViewVariables(VVAccess.ReadWrite)]
public float Duration = 10; public float Duration = 10;
/// <summary> /// <summary>
/// How much reagent is in the foam? /// How much reagent is in the foam?
/// </summary> /// </summary>
[DataField("reagentAmount")] [DataField("reagentAmount"), ViewVariables(VVAccess.ReadWrite)]
public float ReagentAmount = 100; public float ReagentAmount = 200;
/// <summary> /// <summary>
/// Minimum radius of foam spawned /// Minimum radius of foam spawned
/// </summary> /// </summary>
[DataField("minFoamAmount")] [DataField("minFoamAmount"), ViewVariables(VVAccess.ReadWrite)]
public int MinFoamAmount = 2; public int MinFoamAmount = 15;
/// <summary> /// <summary>
/// Maximum radius of foam spawned /// Maximum radius of foam spawned
/// </summary> /// </summary>
[DataField("maxFoamAmount")] [DataField("maxFoamAmount"), ViewVariables(VVAccess.ReadWrite)]
public int MaxFoamAmount = 6; public int MaxFoamAmount = 20;
/// <summary>
/// How long it takes for each tile of foam to spawn
/// </summary>
[DataField("spreadDuration")]
public float SpreadDuration = 1;
} }

View File

@@ -1,11 +1,9 @@
using System.Linq; using System.Linq;
using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.ReactionEffects;
using Content.Server.Fluids.EntitySystems; using Content.Server.Fluids.EntitySystems;
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events; using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
@@ -13,6 +11,7 @@ namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
public sealed class FoamArtifactSystem : EntitySystem public sealed class FoamArtifactSystem : EntitySystem
{ {
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SmokeSystem _smoke = default!;
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize() public override void Initialize()
@@ -36,12 +35,11 @@ public sealed class FoamArtifactSystem : EntitySystem
var sol = new Solution(); var sol = new Solution();
var xform = Transform(uid); var xform = Transform(uid);
sol.AddReagent(component.SelectedReagent, component.ReagentAmount * var range = (int) MathF.Round(MathHelper.Lerp(component.MinFoamAmount, component.MaxFoamAmount, _random.NextFloat(0, 1f)));
(component.MinFoamAmount + sol.AddReagent(component.SelectedReagent, component.ReagentAmount);
(component.MaxFoamAmount - component.MinFoamAmount) * _random.NextFloat()));
var foamEnt = Spawn("Foam", xform.Coordinates); var foamEnt = Spawn("Foam", xform.Coordinates);
var smoke = EnsureComp<SmokeComponent>(foamEnt); var smoke = EnsureComp<SmokeComponent>(foamEnt);
EntityManager.System<SmokeSystem>().Start(foamEnt, smoke, sol, 20f); smoke.SpreadAmount = range * 4;
_smoke.Start(foamEnt, smoke, sol, component.Duration);
} }
} }

View File

@@ -302,8 +302,6 @@
effectHint: artifact-effect-hint-biochemical effectHint: artifact-effect-hint-biochemical
components: components:
- type: FoamArtifact - type: FoamArtifact
spreadDuration: 0.5
duration: 5
reagents: reagents:
- Dermaline - Dermaline
- Arithrazine - Arithrazine
@@ -433,8 +431,8 @@
effectHint: artifact-effect-hint-biochemical effectHint: artifact-effect-hint-biochemical
components: components:
- type: FoamArtifact - type: FoamArtifact
spreadDuration: 0.5 minFoamAmount: 20
duration: 5 maxFoamAmount: 30
reagents: reagents:
- Tritium - Tritium
- Plasma - Plasma