removes componentdependencies (#6160)

This commit is contained in:
Paul Ritter
2022-01-15 03:26:37 +01:00
committed by GitHub
parent 46405ec165
commit 9e1607722d
33 changed files with 257 additions and 274 deletions

View File

@@ -46,7 +46,6 @@ namespace Content.Server.Botany.Components
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[ComponentDependency] private readonly AppearanceComponent? _appearanceComponent = default!;
public override string Name => "PlantHolder";
@@ -583,50 +582,50 @@ namespace Content.Server.Botany.Components
{
_updateSpriteAfterUpdate = false;
if (_appearanceComponent == null)
if (!_entMan.TryGetComponent<AppearanceComponent>(Owner, out var appearanceComponent))
return;
if (Seed != null)
{
if (DrawWarnings)
_appearanceComponent.SetData(PlantHolderVisuals.HealthLight, Health <= (Seed.Endurance / 2f));
appearanceComponent.SetData(PlantHolderVisuals.HealthLight, Health <= (Seed.Endurance / 2f));
if (Dead)
{
_appearanceComponent.SetData(PlantHolderVisuals.Plant,
appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, "dead"));
}
else if (Harvest)
{
_appearanceComponent.SetData(PlantHolderVisuals.Plant,
appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, "harvest"));
}
else if (Age < Seed.Maturation)
{
var growthStage = Math.Max(1, (int) ((Age * Seed.GrowthStages) / Seed.Maturation));
_appearanceComponent.SetData(PlantHolderVisuals.Plant,
appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, $"stage-{growthStage}"));
_lastProduce = Age;
}
else
{
_appearanceComponent.SetData(PlantHolderVisuals.Plant,
appearanceComponent.SetData(PlantHolderVisuals.Plant,
new SpriteSpecifier.Rsi(Seed.PlantRsi, $"stage-{Seed.GrowthStages}"));
}
}
else
{
_appearanceComponent.SetData(PlantHolderVisuals.Plant, SpriteSpecifier.Invalid);
_appearanceComponent.SetData(PlantHolderVisuals.HealthLight, false);
appearanceComponent.SetData(PlantHolderVisuals.Plant, SpriteSpecifier.Invalid);
appearanceComponent.SetData(PlantHolderVisuals.HealthLight, false);
}
if (!DrawWarnings) return;
_appearanceComponent.SetData(PlantHolderVisuals.WaterLight, WaterLevel <= 10);
_appearanceComponent.SetData(PlantHolderVisuals.NutritionLight, NutritionLevel <= 2);
_appearanceComponent.SetData(PlantHolderVisuals.AlertLight,
appearanceComponent.SetData(PlantHolderVisuals.WaterLight, WaterLevel <= 10);
appearanceComponent.SetData(PlantHolderVisuals.NutritionLight, NutritionLevel <= 2);
appearanceComponent.SetData(PlantHolderVisuals.AlertLight,
WeedLevel >= 5 || PestLevel >= 5 || Toxins >= 40 || ImproperHeat || ImproperLight || ImproperPressure ||
_missingGas > 0);
_appearanceComponent.SetData(PlantHolderVisuals.HarvestLight, Harvest);
appearanceComponent.SetData(PlantHolderVisuals.HarvestLight, Harvest);
}
public void CheckForDivergence(bool modified)
@@ -735,10 +734,10 @@ namespace Content.Server.Botany.Components
var targetEntity = Owner;
var solutionEntity = usingItem;
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
AudioHelpers.WithVariation(0.125f));
var split = solutionSystem.Drain(solutionEntity, solution, amount);

View File

@@ -12,8 +12,6 @@ namespace Content.Server.Botany.Components
[RegisterComponent]
public class SeedExtractorComponent : Component, IInteractUsing
{
[ComponentDependency] private readonly ApcPowerReceiverComponent? _powerReceiver = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!;
@@ -25,7 +23,7 @@ namespace Content.Server.Botany.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
if (!_powerReceiver?.Powered ?? false)
if (!_entMan.TryGetComponent<ApcPowerReceiverComponent>(Owner, out var powerReceiverComponent) || !powerReceiverComponent.Powered)
return false;
if (_entMan.TryGetComponent(eventArgs.Using, out ProduceComponent? produce) && produce.Seed != null)