mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-13 04:11:13 +03:00
* Restarting files from scratch * reduce file count, more progress * Additional partial work * update 1 * update 2 * TODO execution * fix * Update PlantGrowthComponent.cs * fix 1 * growth correction * PlantGrowthComponent * update 99 * last update * oops * Update vegan-meatball.yml * Data loss * ToxinsComponent * Default components * minor fix * PlantTraitsComponent * fix error * fix error 2 * Copy growth components * last update within this PR * AutoHarvestGrowth remote * Viable * fix * Fix growth rate * Improvements to the YAML * merge update * fix * code cleanup * TODO * fix * oops * oops 2 * more TODO * fix names * fix names oops * Harvest bug fixes * fix tests * refactor: cleanup after mering master * Update ConsumeExudeGasGrowthSystem.cs * refactor: make this piece of happiness and ponies work * review * oops * fix <summary> * Separation of plant components into PlantComponent and PlantTraitsComponent and cleaning * EnsureUniqueSeed * refactor: change Resolve to TryComp where appropriate * refactor: review comments - try get for components, clenaups * refactor: minor yaml cleanups * fixing trifles * botany-rework-part-3 * API and mutations * minor fixes * Update WeedPestGrowthSystem.cs * Update plants.yml * PlantChemicals * YAMLLinter * review and some lost code * YAMLLinter part 2 * plants.yml * Aaaa tests * seedId * clone plant component * Update clone.yml * refactor: remove suppress possible null reference exception * refactor: changed HasPlantAlive to TryGetAlivePlant, minor cleanup * Separation of tray and plant * oops * PlantingPlant * a little more cleaning * oops 2 * botany-rework-part-4 * predict and API * Field OldAgeDamage * oops * YMAL * YMAL 2 * YMAAAAAL * Update PlantToxinsSystem.cs * review * Update randomMutations.yml * minor fix design * Updates the plants visuals not every frame * bug fixes * some fixes * bugfix and renames * Dirty * Replace ComponentRegistry * unnecessary API * fix merge * build * build 2 * Review by AJCM * del PlantDataComponent and fix harvest * fix all * final review * Update PlantTrayVisualizerSystem.cs * fix merge * Update PlantTraitsComponent.cs * Traits LocId fix * Update SpawnEntitiesBehavior.cs * aaaaaaaaa * fix all part 2 * PlantDataComponent revert * aoao * fix all part 3 * Update PlantTraitsComponent.cs * Update clone.yml * Reviews --------- Co-authored-by: PraxisMapper <praxismapper@gmail.com> Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
94 lines
3.9 KiB
C#
94 lines
3.9 KiB
C#
using JetBrains.Annotations;
|
|
using Content.Shared.Botany.Components;
|
|
using Content.Shared.Botany.Events;
|
|
|
|
namespace Content.Shared.Botany.Systems;
|
|
|
|
/// <summary>
|
|
/// Applies atmospheric temperature and pressure effects to plants during growth ticks.
|
|
/// Uses current tile gas mixture to penalize or clear warnings based on tolerances.
|
|
/// </summary>
|
|
public abstract partial class SharedPlantAtmosphericSystem : EntitySystem
|
|
{
|
|
[Dependency] private BotanySystem _botany = default!;
|
|
[Dependency] private PlantMutationSystem _mutation = default!;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnCrossPollinate(Entity<PlantAtmosphericComponent> ent, ref PlantCrossPollinateEvent args)
|
|
{
|
|
if (!_botany.TryGetPlantComponent<PlantAtmosphericComponent>(args.PollenData, args.PollenProtoId, out var pollenData))
|
|
return;
|
|
|
|
_mutation.CrossFloat(ent, ref ent.Comp.LowHeatTolerance, pollenData.LowHeatTolerance);
|
|
_mutation.CrossFloat(ent, ref ent.Comp.HighHeatTolerance, pollenData.HighHeatTolerance);
|
|
_mutation.CrossFloat(ent, ref ent.Comp.LowPressureTolerance, pollenData.LowPressureTolerance);
|
|
_mutation.CrossFloat(ent, ref ent.Comp.HighPressureTolerance, pollenData.HighPressureTolerance);
|
|
Dirty(ent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adjusts minimum temperature tolerance for plant growth.
|
|
/// Ensures low temperature is not greater than high.
|
|
/// </summary>
|
|
public void AdjustLowHeatTolerance(Entity<PlantAtmosphericComponent?> ent, float amount)
|
|
{
|
|
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
|
return;
|
|
|
|
ent.Comp.LowHeatTolerance = MathF.Max(0f, ent.Comp.LowHeatTolerance + amount);
|
|
if (ent.Comp.LowHeatTolerance > ent.Comp.HighHeatTolerance)
|
|
ent.Comp.HighHeatTolerance = ent.Comp.LowHeatTolerance;
|
|
|
|
DirtyFields(ent, null, nameof(ent.Comp.LowHeatTolerance), nameof(ent.Comp.HighHeatTolerance));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adjusts maximum temperature tolerance for plant growth.
|
|
/// Ensures low temperature is not less than high.
|
|
/// </summary>
|
|
public void AdjustHighHeatTolerance(Entity<PlantAtmosphericComponent?> ent, float amount)
|
|
{
|
|
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
|
return;
|
|
|
|
ent.Comp.HighHeatTolerance = MathF.Max(0f, ent.Comp.HighHeatTolerance + amount);
|
|
if (ent.Comp.HighHeatTolerance < ent.Comp.LowHeatTolerance)
|
|
ent.Comp.LowHeatTolerance = ent.Comp.HighHeatTolerance;
|
|
|
|
DirtyFields(ent, null, nameof(ent.Comp.HighHeatTolerance), nameof(ent.Comp.LowHeatTolerance));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adjusts minimum pressure tolerance for plant growth.
|
|
/// Ensures pressure low is not greater than high.
|
|
/// </summary>
|
|
[PublicAPI]
|
|
public void AdjustLowPressureTolerance(Entity<PlantAtmosphericComponent?> ent, float amount)
|
|
{
|
|
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
|
return;
|
|
|
|
ent.Comp.LowPressureTolerance = MathF.Max(0f, ent.Comp.LowPressureTolerance + amount);
|
|
if (ent.Comp.LowPressureTolerance > ent.Comp.HighPressureTolerance)
|
|
ent.Comp.HighPressureTolerance = ent.Comp.LowPressureTolerance;
|
|
|
|
DirtyFields(ent, null, nameof(ent.Comp.LowPressureTolerance), nameof(ent.Comp.HighPressureTolerance));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adjusts maximum pressure tolerance for plant growth.
|
|
/// Ensures pressure high is not less than low.
|
|
/// </summary>
|
|
[PublicAPI]
|
|
public void AdjustHighPressureTolerance(Entity<PlantAtmosphericComponent?> ent, float amount)
|
|
{
|
|
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
|
return;
|
|
|
|
ent.Comp.HighPressureTolerance = MathF.Max(0f, ent.Comp.HighPressureTolerance + amount);
|
|
if (ent.Comp.HighPressureTolerance < ent.Comp.LowPressureTolerance)
|
|
ent.Comp.LowPressureTolerance = ent.Comp.HighPressureTolerance;
|
|
|
|
DirtyFields(ent, null, nameof(ent.Comp.HighPressureTolerance), nameof(ent.Comp.LowPressureTolerance));
|
|
}
|
|
}
|