public const float HydroponicsSpeedMultiplier = 1f;
public const float HydroponicsConsumptionMultiplier = 2f;
+ public readonly FixedPoint2 PlantMetabolismRate = FixedPoint2.New(1);
private static readonly ProtoId<TagPrototype> HoeTag = "Hoe";
private static readonly ProtoId<TagPrototype> PlantSampleTakerTag = "PlantSampleTaker";
if (solution.Volume > 0 && component.MutationLevel < 25)
{
- foreach (var entry in component.SoilSolution.Value.Comp.Solution.Contents)
+ // Don't apply any effects to a non-unique seed ever! Remove this when botany code is sane...
+ EnsureUniqueSeed(uid, component);
+ foreach (var entry in solution.Contents)
{
+ if (entry.Quantity < PlantMetabolismRate)
+ continue;
+
var reagentProto = _prototype.Index<ReagentPrototype>(entry.Reagent.Prototype);
- _entityEffects.ApplyEffects(uid, reagentProto.PlantMetabolisms.ToArray(), entry.Quantity.Float());
+ _entityEffects.ApplyEffects(uid, reagentProto.PlantMetabolisms.ToArray(), entry.Quantity);
}
- _solutionContainerSystem.RemoveEachReagent(component.SoilSolution.Value, FixedPoint2.New(1));
+ _solutionContainerSystem.RemoveEachReagent(component.SoilSolution.Value, PlantMetabolismRate);
}
CheckLevelSanity(uid, component);
public sealed partial class PlantAdjustPotencyEntityEffectSystem : EntityEffectSystem<PlantHolderComponent, PlantAdjustPotency>
{
- [Dependency] private readonly PlantHolderSystem _plantHolder = default!;
protected override void Effect(Entity<PlantHolderComponent> entity, ref EntityEffectEvent<PlantAdjustPotency> args)
{
if (entity.Comp.Seed == null || entity.Comp.Dead)
return;
- _plantHolder.EnsureUniqueSeed(entity, entity.Comp);
entity.Comp.Seed.Potency = Math.Max(entity.Comp.Seed.Potency + args.Effect.Amount, 1);
}
}
public sealed partial class PlantDestroySeedsEntityEffectSystem : EntityEffectSystem<PlantHolderComponent, PlantDestroySeeds>
{
- [Dependency] private readonly PlantHolderSystem _plantHolder = default!;
[Dependency] private readonly PopupSystem _popup = default!;
protected override void Effect(Entity<PlantHolderComponent> entity, ref EntityEffectEvent<PlantDestroySeeds> args)
if (entity.Comp.Seed.Seedless)
return;
- _plantHolder.EnsureUniqueSeed(entity, entity.Comp);
_popup.PopupEntity(
Loc.GetString("botany-plant-seedsdestroyed"),
entity,
public sealed partial class PlantDiethylamineEntityEffectSystem : EntityEffectSystem<PlantHolderComponent, PlantDiethylamine>
{
[Dependency] private readonly IRobustRandom _random = default!;
- [Dependency] private readonly PlantHolderSystem _plantHolder = default!;
protected override void Effect(Entity<PlantHolderComponent> entity, ref EntityEffectEvent<PlantDiethylamine> args)
{
if (_random.Prob(0.1f))
{
- _plantHolder.EnsureUniqueSeed(entity, entity);
entity.Comp.Seed!.Lifespan++;
}
if (_random.Prob(0.1f))
{
- _plantHolder.EnsureUniqueSeed(entity, entity);
entity.Comp.Seed!.Endurance++;
}
}
public sealed partial class PlantRestoreSeedsEntityEffectSystem : EntityEffectSystem<PlantHolderComponent, PlantRestoreSeeds>
{
- [Dependency] private readonly PlantHolderSystem _plantHolder = default!;
[Dependency] private readonly PopupSystem _popup = default!;
protected override void Effect(Entity<PlantHolderComponent> entity, ref EntityEffectEvent<PlantRestoreSeeds> args)
if (!entity.Comp.Seed.Seedless)
return;
- _plantHolder.EnsureUniqueSeed(entity, entity.Comp);
_popup.PopupEntity(Loc.GetString("botany-plant-seedsrestored"), entity);
entity.Comp.Seed.Seedless = false;
}
public sealed partial class RobustHarvestEntityEffectSystem : EntityEffectSystem<PlantHolderComponent, RobustHarvest>
{
[Dependency] private readonly IRobustRandom _random = default!;
- [Dependency] private readonly PlantHolderSystem _plantHolder = default!;
protected override void Effect(Entity<PlantHolderComponent> entity, ref EntityEffectEvent<RobustHarvest> args)
{
if (entity.Comp.Seed.Potency < args.Effect.PotencyLimit)
{
- _plantHolder.EnsureUniqueSeed(entity, entity.Comp);
entity.Comp.Seed.Potency = Math.Min(entity.Comp.Seed.Potency + args.Effect.PotencyIncrease, args.Effect.PotencyLimit);
if (entity.Comp.Seed.Potency > args.Effect.PotencySeedlessThreshold)
else if (entity.Comp.Seed.Yield > 1 && _random.Prob(0.1f))
{
// Too much of a good thing reduces yield
- _plantHolder.EnsureUniqueSeed(entity, entity.Comp);
entity.Comp.Seed.Yield--;
}
}
_adminLogger.Add(LogType.ChemicalReaction, reaction.Impact,
$"Chemical reaction {reaction.ID:reaction} occurred with strength {unitReactions:strength} on entity {ToPrettyString(soln):metabolizer} at Pos:{(posFound ? $"{gridPos:coordinates}" : "[Grid or Map not Found]")}");
- _entityEffects.ApplyEffects(soln, reaction.Effects, unitReactions.Float());
+ _entityEffects.ApplyEffects(soln, reaction.Effects, unitReactions);
// Someday, some brave soul will thread through an optional actor
// argument in from every call of OnReaction up, all just to pass
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.EntityConditions;
+using Content.Shared.FixedPoint;
using Content.Shared.Random.Helpers;
using Robust.Shared.Random;
using Robust.Shared.Timing;
}
}
+ /// <inheritdoc cref="ApplyEffects(EntityUid,EntityEffect[],float,EntityUid?)"/>
+ public void ApplyEffects(EntityUid target, EntityEffect[] effects, FixedPoint2 scale, EntityUid? user = null)
+ {
+ ApplyEffects(target, effects, scale.Float());
+ }
+
/// <summary>
/// Applies a list of entity effects to a target entity.
/// </summary>