Another batch of DoAfter fixes (#14351)

This commit is contained in:
keronshb
2023-03-05 00:26:03 -05:00
committed by GitHub
parent 417569fe2e
commit eff088189d
11 changed files with 124 additions and 42 deletions

View File

@@ -86,8 +86,8 @@ namespace Content.Server.Nutrition.EntitySystems
if (food == user || EntityManager.TryGetComponent<MobStateComponent>(food, out var mobState) && _mobStateSystem.IsAlive(food, mobState)) // Suppresses eating alive mobs
return false;
// Target can't be fed or they're already forcefeeding
if (!EntityManager.HasComponent<BodyComponent>(target) || foodComp.ForceFeed)
// Target can't be fed or they're already eating
if (!EntityManager.HasComponent<BodyComponent>(target) || foodComp.Eating)
return false;
if (!_solutionContainerSystem.TryGetSolution(food, foodComp.SolutionName, out var foodSolution))
@@ -111,6 +111,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (!_interactionSystem.InRangeUnobstructed(user, food, popup: true))
return true;
foodComp.Eating = true;
foodComp.ForceFeed = user != target;
if (foodComp.ForceFeed)
@@ -152,8 +153,9 @@ namespace Content.Server.Nutrition.EntitySystems
private void OnDoAfter(EntityUid uid, FoodComponent component, DoAfterEvent<FoodData> args)
{
//Prevents the target from being force fed food but allows the user to chow down
if (args.Cancelled && component.ForceFeed)
if (args.Cancelled)
{
component.Eating = false;
component.ForceFeed = false;
return;
}
@@ -167,6 +169,8 @@ namespace Content.Server.Nutrition.EntitySystems
if (!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(args.Args.Target.Value, out var stomachs, body))
return;
component.Eating = false;
var transferAmount = component.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) component.TransferAmount, args.AdditionalData.FoodSolution.Volume) : args.AdditionalData.FoodSolution.Volume;
var split = _solutionContainerSystem.SplitSolution(uid, args.AdditionalData.FoodSolution, transferAmount);