88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
|
|
using Content.Server.Botany.Components;
|
||
|
|
using Content.Shared.Atmos;
|
||
|
|
using Content.Shared.EntityEffects;
|
||
|
|
using Robust.Shared.Prototypes;
|
||
|
|
using Robust.Shared.Random;
|
||
|
|
using System.Linq;
|
||
|
|
|
||
|
|
namespace Content.Server.EntityEffects.Effects;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// changes the gases that a plant or produce create.
|
||
|
|
/// </summary>
|
||
|
|
public sealed partial class PlantMutateExudeGasses : EntityEffect
|
||
|
|
{
|
||
|
|
[DataField]
|
||
|
|
public float MinValue = 0.01f;
|
||
|
|
|
||
|
|
[DataField]
|
||
|
|
public float MaxValue = 0.5f;
|
||
|
|
|
||
|
|
public override void Effect(EntityEffectBaseArgs args)
|
||
|
|
{
|
||
|
|
var plantholder = args.EntityManager.GetComponent<PlantHolderComponent>(args.TargetEntity);
|
||
|
|
|
||
|
|
if (plantholder.Seed == null)
|
||
|
|
return;
|
||
|
|
|
||
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
||
|
|
var gasses = plantholder.Seed.ExudeGasses;
|
||
|
|
|
||
|
|
// Add a random amount of a random gas to this gas dictionary
|
||
|
|
float amount = random.NextFloat(MinValue, MaxValue);
|
||
|
|
Gas gas = random.Pick(Enum.GetValues(typeof(Gas)).Cast<Gas>().ToList());
|
||
|
|
if (gasses.ContainsKey(gas))
|
||
|
|
{
|
||
|
|
gasses[gas] += amount;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
gasses.Add(gas, amount);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||
|
|
{
|
||
|
|
return "TODO";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// changes the gases that a plant or produce consumes.
|
||
|
|
/// </summary>
|
||
|
|
public sealed partial class PlantMutateConsumeGasses : EntityEffect
|
||
|
|
{
|
||
|
|
[DataField]
|
||
|
|
public float MinValue = 0.01f;
|
||
|
|
|
||
|
|
[DataField]
|
||
|
|
public float MaxValue = 0.5f;
|
||
|
|
public override void Effect(EntityEffectBaseArgs args)
|
||
|
|
{
|
||
|
|
var plantholder = args.EntityManager.GetComponent<PlantHolderComponent>(args.TargetEntity);
|
||
|
|
|
||
|
|
if (plantholder.Seed == null)
|
||
|
|
return;
|
||
|
|
|
||
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
||
|
|
var gasses = plantholder.Seed.ConsumeGasses;
|
||
|
|
|
||
|
|
// Add a random amount of a random gas to this gas dictionary
|
||
|
|
float amount = random.NextFloat(MinValue, MaxValue);
|
||
|
|
Gas gas = random.Pick(Enum.GetValues(typeof(Gas)).Cast<Gas>().ToList());
|
||
|
|
if (gasses.ContainsKey(gas))
|
||
|
|
{
|
||
|
|
gasses[gas] += amount;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
gasses.Add(gas, amount);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||
|
|
{
|
||
|
|
return "TODO";
|
||
|
|
}
|
||
|
|
}
|