if (ent.Comp.SuffocationCycles >= ent.Comp.SuffocationCycleThreshold)
{
// TODO: This is not going work with multiple different lungs, if that ever becomes a possibility
- var organs = _bodySystem.GetBodyOrganComponents<LungComponent>(ent);
- foreach (var (comp, _) in organs)
+ var organs = _bodySystem.GetBodyOrganEntityComps<LungComponent>((ent, null));
+ foreach (var entity in organs)
{
- _alertsSystem.ShowAlert(ent, comp.Alert);
+ _alertsSystem.ShowAlert(entity.Owner, entity.Comp1.Alert);
}
}
_adminLogger.Add(LogType.Asphyxiation, $"{ToPrettyString(ent):entity} stopped suffocating");
// TODO: This is not going work with multiple different lungs, if that ever becomes a possibility
- var organs = _bodySystem.GetBodyOrganComponents<LungComponent>(ent);
- foreach (var (comp, _) in organs)
+ var organs = _bodySystem.GetBodyOrganEntityComps<LungComponent>((ent, null));
+ foreach (var entity in organs)
{
- _alertsSystem.ClearAlert(ent, comp.Alert);
+ _alertsSystem.ClearAlert(entity.Owner, entity.Comp1.Alert);
}
_damageableSys.TryChangeDamage(ent, ent.Comp.DamageRecovery);
if (transferAmount <= 0)
return;
- if (!_body.TryGetBodyOrganComponents<StomachComponent>(args.Target.Value, out var stomachs, body))
+ if (!_body.TryGetBodyOrganEntityComps<StomachComponent>((args.Target.Value, body), out var stomachs))
{
_popup.PopupEntity(Loc.GetString(forceDrink ? "drink-component-try-use-drink-cannot-drink-other" : "drink-component-try-use-drink-had-enough"), args.Target.Value, args.User);
return;
}
- var firstStomach = stomachs.FirstOrNull(stomach => _stomach.CanTransferSolution(stomach.Comp.Owner, drained, stomach.Comp));
+ var firstStomach = stomachs.FirstOrNull(stomach => _stomach.CanTransferSolution(stomach.Owner, drained, stomach.Comp1));
//All stomachs are full or can't handle whatever solution we have.
if (firstStomach == null)
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-2f));
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
- //TODO: Grab the stomach UIDs somehow without using Owner
- _stomach.TryTransferSolution(firstStomach.Value.Comp.Owner, drained, firstStomach.Value.Comp);
+ _stomach.TryTransferSolution(firstStomach.Value.Owner, drained, firstStomach.Value.Comp1);
_forensics.TransferDna(entity, args.Target.Value);
!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;
// Make sure the solution exists
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;
[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!;
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
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,
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))
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;
}
}
_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;
!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
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);
/// 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;
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;
return false;
}
- /// <summary>
- /// Returns a list of ValueTuples of <see cref="T"/> and OrganComponent on each organ
- /// in the given body.
- /// </summary>
- /// <param name="uid">The body entity id to check on.</param>
- /// <param name="body">The body to check for organs on.</param>
- /// <typeparam name="T">The component to check for.</typeparam>
- public List<(T Comp, OrganComponent Organ)> GetBodyOrganComponents<T>(
- EntityUid uid,
- BodyComponent? body = null)
- where T : IComponent
- {
- if (!Resolve(uid, ref body))
- return new List<(T Comp, OrganComponent Organ)>();
-
- var query = GetEntityQuery<T>();
- var list = new List<(T Comp, OrganComponent Organ)>(3);
- foreach (var organ in GetBodyOrgans(uid, body))
- {
- if (query.TryGetComponent(organ.Id, out var comp))
- list.Add((comp, organ.Component));
- }
-
- return list;
- }
-
/// <summary>
/// Returns a list of Entity<<see cref="T"/>, <see cref="OrganComponent"/>>
/// for each organ of the body
/// <param name="body">The body to check for organs on.</param>
/// <typeparam name="T">The component to check for.</typeparam>
/// <returns>Whether any were found.</returns>
- public bool TryGetBodyOrganComponents<T>(
- EntityUid uid,
- [NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
- BodyComponent? body = null)
+ public bool TryGetBodyOrganEntityComps<T>(
+ Entity<BodyComponent?> entity,
+ [NotNullWhen(true)] out List<Entity<T, OrganComponent>>? comps)
where T : IComponent
{
- if (!Resolve(uid, ref body))
+ if (!Resolve(entity.Owner, ref entity.Comp))
{
comps = null;
return false;
}
- comps = GetBodyOrganComponents<T>(uid, body);
+ comps = GetBodyOrganEntityComps<T>(entity);
if (comps.Count != 0)
return true;