PlantholderComponent ECS (#12871)

This commit is contained in:
Nemanja
2022-12-18 13:12:28 -05:00
committed by GitHub
parent 7ba3f0b14a
commit 195bf86fe2
12 changed files with 720 additions and 680 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry.Reagent;
using Content.Server.Botany.Systems;
using Content.Shared.Chemistry.Reagent;
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
{
@@ -9,8 +10,10 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
return;
var plantHolder = args.EntityManager.System<PlantHolderSystem>();
plantHolderComp.Health += Amount;
plantHolderComp.CheckHealth();
plantHolder.CheckHealth(args.SolutionEntity, plantHolderComp);
}
}
}

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry.Reagent;
using Content.Server.Botany.Systems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
@@ -11,8 +12,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false))
return;
plantHolderComp.AdjustNutrient(Amount);
return;
var plantHolder = args.EntityManager.System<PlantHolderSystem>();
plantHolder.AdjustNutrient(args.SolutionEntity, Amount, plantHolderComp);
}
}
}

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry.Reagent;
using Content.Server.Botany.Systems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
@@ -11,7 +12,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false))
return;
plantHolderComp.AdjustWater(Amount);
var plantHolder = args.EntityManager.System<PlantHolderSystem>();
plantHolder.AdjustWater(args.SolutionEntity, Amount, plantHolderComp);
}
}
}

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry.Reagent;
using Content.Server.Botany.Systems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
@@ -11,7 +12,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
return;
plantHolderComp.AffectGrowth((int) Amount);
var plantHolder = args.EntityManager.System<PlantHolderSystem>();
plantHolder.AffectGrowth(args.SolutionEntity, (int) Amount, plantHolderComp);
}
}
}

View File

@@ -1,4 +1,5 @@
using Content.Server.Botany.Components;
using Content.Server.Botany.Systems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
using Robust.Shared.Random;
@@ -16,17 +17,20 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
plantHolderComp.Seed.Immutable)
return;
var plantHolder = args.EntityManager.System<PlantHolderSystem>();
var random = IoCManager.Resolve<IRobustRandom>();
if (random.Prob(0.1f))
{
plantHolderComp.EnsureUniqueSeed();
plantHolder.EnsureUniqueSeed(args.SolutionEntity, plantHolderComp);
plantHolderComp.Seed.Lifespan++;
}
if (random.Prob(0.1f))
{
plantHolderComp.EnsureUniqueSeed();
plantHolder.EnsureUniqueSeed(args.SolutionEntity, plantHolderComp);
plantHolderComp.Seed.Endurance++;
}
}

View File

@@ -1,4 +1,5 @@
using Content.Server.Botany.Components;
using Content.Server.Botany.Systems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
using Robust.Shared.Random;
@@ -25,11 +26,13 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
plantHolderComp.Seed.Immutable)
return;
var plantHolder = args.EntityManager.System<PlantHolderSystem>();
var random = IoCManager.Resolve<IRobustRandom>();
if (plantHolderComp.Seed.Potency < PotencyLimit)
{
plantHolderComp.EnsureUniqueSeed();
plantHolder.EnsureUniqueSeed(args.SolutionEntity, plantHolderComp);
plantHolderComp.Seed.Potency = Math.Min(plantHolderComp.Seed.Potency + PotencyIncrease, PotencyLimit);
if (plantHolderComp.Seed.Potency > PotencySeedlessThreshold)
@@ -40,7 +43,7 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
else if (plantHolderComp.Seed.Yield > 1 && random.Prob(0.1f))
{
// Too much of a good thing reduces yield
plantHolderComp.EnsureUniqueSeed();
plantHolder.EnsureUniqueSeed(args.SolutionEntity, plantHolderComp);
plantHolderComp.Seed.Yield--;
}
}