Remove obsolete code from Food, Drink and Respirator systems. (#30560)

* Remove obsolete code from Food, Drink and Respirator systems

* remove obsolete comment
This commit is contained in:
Mervill
2024-08-02 00:30:45 -07:00
committed by GitHub
parent ac4086f984
commit af75258601
4 changed files with 34 additions and 63 deletions

View File

@@ -1,6 +1,6 @@
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.EntitySystems;
using Content.Server.Inventory;
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
@@ -53,7 +53,7 @@ public sealed class FoodSystem : EntitySystem
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly StomachSystem _stomach = default!;
@@ -121,7 +121,7 @@ public sealed class FoodSystem : EntitySystem
if (!_solutionContainer.TryGetSolution(food, foodComp.Solution, out _, out var foodSolution))
return (false, false);
if (!_body.TryGetBodyOrganComponents<StomachComponent>(target, out var stomachs, body))
if (!_body.TryGetBodyOrganEntityComps<StomachComponent>((target, body), out var stomachs))
return (false, false);
// Check for special digestibles
@@ -182,12 +182,12 @@ public sealed class FoodSystem : EntitySystem
user, target);
// logging
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(user):user} is forcing {ToPrettyString(target):target} to eat {ToPrettyString(food):food} {SolutionContainerSystem.ToPrettyString(foodSolution)}");
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(user):user} is forcing {ToPrettyString(target):target} to eat {ToPrettyString(food):food} {SharedSolutionContainerSystem.ToPrettyString(foodSolution)}");
}
else
{
// log voluntary eating
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is eating {ToPrettyString(food):food} {SolutionContainerSystem.ToPrettyString(foodSolution)}");
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is eating {ToPrettyString(food):food} {SharedSolutionContainerSystem.ToPrettyString(foodSolution)}");
}
var doAfterArgs = new DoAfterArgs(EntityManager,
@@ -220,7 +220,7 @@ public sealed class FoodSystem : EntitySystem
if (!TryComp<BodyComponent>(args.Target.Value, out var body))
return;
if (!_body.TryGetBodyOrganComponents<StomachComponent>(args.Target.Value, out var stomachs, body))
if (!_body.TryGetBodyOrganEntityComps<StomachComponent>((args.Target.Value, body), out var stomachs))
return;
if (args.Used is null || !_solutionContainer.TryGetSolution(args.Used.Value, args.Solution, out var soln, out var solution))
@@ -244,23 +244,22 @@ public sealed class FoodSystem : EntitySystem
var split = _solutionContainer.SplitSolution(soln.Value, transferAmount);
//TODO: Get the stomach UID somehow without nabbing owner
// Get the stomach with the highest available solution volume
var highestAvailable = FixedPoint2.Zero;
StomachComponent? stomachToUse = null;
foreach (var (stomach, _) in stomachs)
Entity<StomachComponent>? stomachToUse = null;
foreach (var ent in stomachs)
{
var owner = stomach.Owner;
if (!_stomach.CanTransferSolution(owner, split, stomach))
var owner = ent.Owner;
if (!_stomach.CanTransferSolution(owner, split, ent.Comp1))
continue;
if (!_solutionContainer.ResolveSolution(owner, StomachSystem.DefaultSolutionName, ref stomach.Solution, out var stomachSol))
if (!_solutionContainer.ResolveSolution(owner, StomachSystem.DefaultSolutionName, ref ent.Comp1.Solution, out var stomachSol))
continue;
if (stomachSol.AvailableVolume <= highestAvailable)
continue;
stomachToUse = stomach;
stomachToUse = ent;
highestAvailable = stomachSol.AvailableVolume;
}
@@ -273,7 +272,7 @@ public sealed class FoodSystem : EntitySystem
}
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
_stomach.TryTransferSolution(stomachToUse.Owner, split, stomachToUse);
_stomach.TryTransferSolution(stomachToUse!.Value.Owner, split, stomachToUse);
var flavors = args.FlavorMessage;
@@ -365,7 +364,7 @@ public sealed class FoodSystem : EntitySystem
!ev.CanInteract ||
!ev.CanAccess ||
!TryComp<BodyComponent>(ev.User, out var body) ||
!_body.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs, body))
!_body.TryGetBodyOrganEntityComps<StomachComponent>((ev.User, body), out var stomachs))
return;
// have to kill mouse before eating it
@@ -399,7 +398,7 @@ public sealed class FoodSystem : EntitySystem
if (!Resolve(food, ref foodComp, false))
return false;
if (!_body.TryGetBodyOrganComponents<StomachComponent>(uid, out var stomachs))
if (!_body.TryGetBodyOrganEntityComps<StomachComponent>(uid, out var stomachs))
return false;
return IsDigestibleBy(food, foodComp, stomachs);
@@ -409,7 +408,7 @@ public sealed class FoodSystem : EntitySystem
/// Returns true if <paramref name="stomachs"/> has a <see cref="StomachComponent.SpecialDigestible"/> that whitelists
/// this <paramref name="food"/> (or if they even have enough stomachs in the first place).
/// </summary>
private bool IsDigestibleBy(EntityUid food, FoodComponent component, List<(StomachComponent, OrganComponent)> stomachs)
private bool IsDigestibleBy(EntityUid food, FoodComponent component, List<Entity<StomachComponent, OrganComponent>> stomachs)
{
var digestible = true;
@@ -418,13 +417,13 @@ public sealed class FoodSystem : EntitySystem
return false;
// Run through the mobs' stomachs
foreach (var (comp, _) in stomachs)
foreach (var ent in stomachs)
{
// Find a stomach with a SpecialDigestible
if (comp.SpecialDigestible == null)
if (ent.Comp1.SpecialDigestible == null)
continue;
// Check if the food is in the whitelist
if (_whitelistSystem.IsWhitelistPass(comp.SpecialDigestible, food))
if (_whitelistSystem.IsWhitelistPass(ent.Comp1.SpecialDigestible, food))
return true;
// They can only eat whitelist food and the food isn't in the whitelist. It's not edible.
return false;