6
2025-08-05 10:00:54 +03:00

120 lines
3.2 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;
// Frontier: List of gasses
Gas[] gasList =
{
Gas.Oxygen,
Gas.Nitrogen,
Gas.CarbonDioxide,
Gas.NitrousOxide,
Gas.Ammonia,
Gas.Plasma,
Gas.WaterVapor,
//Gas.Tritium,
//Gas.Frezon,
};
// End Frontier: List of gasses
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()); // Frontier
Gas gas = random.Pick(gasList); // Frontier
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;
// Frontier: List of gasses
Gas[] gasList =
{
Gas.Oxygen,
Gas.Nitrogen,
Gas.CarbonDioxide,
Gas.NitrousOxide,
Gas.Ammonia,
Gas.Plasma,
Gas.WaterVapor,
//Gas.Tritium,
//Gas.Frezon,
};
// End Frontier: List of gasses
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()); // Frontier
Gas gas = random.Pick(gasList); // Frontier
if (gasses.ContainsKey(gas))
{
gasses[gas] += amount;
}
else
{
gasses.Add(gas, amount);
}
}
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return "TODO";
}
}