Skip to content

Commit

Permalink
Clamp plantholder values.
Browse files Browse the repository at this point in the history
  • Loading branch information
PraxisMapper committed Sep 19, 2024
1 parent e68cb5a commit 40bf2e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Content.Server/Botany/Systems/PlantHolderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public void Update(EntityUid uid, PlantHolderComponent? component = null)
chance = 0.01f;

if (_random.Prob(chance))
component.WeedLevel += 1 + HydroponicsSpeedMultiplier * component.WeedCoefficient;
component.WeedLevel = Math.Clamp(component.WeedLevel + (1 + HydroponicsSpeedMultiplier * component.WeedCoefficient), 0, 10);

if (component.DrawWarnings)
component.UpdateSpriteAfterUpdate = true;
Expand All @@ -378,7 +378,7 @@ public void Update(EntityUid uid, PlantHolderComponent? component = null)
// Can only happen when there's a live seed planted.
if (_random.Prob(0.01f))
{
component.PestLevel += 0.5f * HydroponicsSpeedMultiplier;
component.PestLevel = Math.Clamp(component.PestLevel + 0.5f * HydroponicsSpeedMultiplier, 0, 10);
if (component.DrawWarnings)
component.UpdateSpriteAfterUpdate = true;
}
Expand Down Expand Up @@ -408,20 +408,20 @@ public void AdjustNutrient(EntityUid uid, float amount, PlantHolderComponent? co
if (!Resolve(uid, ref component))
return;

component.NutritionLevel += amount;
component.NutritionLevel = Math.Clamp(component.NutritionLevel + amount, 0, 100);
}

public void AdjustWater(EntityUid uid, float amount, PlantHolderComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

component.WaterLevel += amount;
component.WaterLevel = Math.Clamp(component.WaterLevel + amount, 0, 100);

// Water dilutes toxins.
if (amount > 0)
{
component.Toxins -= amount * 4f;
component.Toxins = Math.Clamp(component.Toxins - amount * 4f, 0, 100);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Botany/Systems/PlantSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public void Die(EntityUid uid, PlantComponent? plant = null)
{
holder.ImproperHeat = false;
holder.ImproperPressure = false;
holder.WeedLevel += 1 * HydroponicsSpeedMultiplier;
holder.WeedLevel = Math.Clamp(holder.WeedLevel + (1 * HydroponicsSpeedMultiplier), 0f, 10f);
holder.PestLevel = 0;
_plantHolder.UpdateSprite(plant.PlantHolderUid, holder);
}
Expand Down

0 comments on commit 40bf2e4

Please sign in to comment.