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

View File

@@ -1,11 +1,9 @@
using System.Linq;
using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.ReactionEffects;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Chemistry.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Random;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
@@ -13,6 +11,7 @@ namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
public sealed class FoamArtifactSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SmokeSystem _smoke = default!;
/// <inheritdoc/>
public override void Initialize()
@@ -36,12 +35,11 @@ public sealed class FoamArtifactSystem : EntitySystem
var sol = new Solution();
var xform = Transform(uid);
sol.AddReagent(component.SelectedReagent, component.ReagentAmount *
(component.MinFoamAmount +
(component.MaxFoamAmount - component.MinFoamAmount) * _random.NextFloat()));
var range = (int) MathF.Round(MathHelper.Lerp(component.MinFoamAmount, component.MaxFoamAmount, _random.NextFloat(0, 1f)));
sol.AddReagent(component.SelectedReagent, component.ReagentAmount);
var foamEnt = Spawn("Foam", xform.Coordinates);
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
components:
- type: FoamArtifact
spreadDuration: 0.5
duration: 5
reagents:
- Dermaline
- Arithrazine
@@ -433,8 +431,8 @@
effectHint: artifact-effect-hint-biochemical
components:
- type: FoamArtifact
spreadDuration: 0.5
duration: 5
minFoamAmount: 20
maxFoamAmount: 30
reagents:
- Tritium
- Plasma