Another batch of DoAfter fixes (#14351)
This commit is contained in:
@@ -217,7 +217,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
|
||||
private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, EntityUid item)
|
||||
{
|
||||
if (!EntityManager.HasComponent<BodyComponent>(target) || drink.ForceDrink)
|
||||
if (!EntityManager.HasComponent<BodyComponent>(target) || drink.Drinking)
|
||||
return false;
|
||||
|
||||
if (!drink.Opened)
|
||||
@@ -241,6 +241,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
if (!_interactionSystem.InRangeUnobstructed(user, item, popup: true))
|
||||
return true;
|
||||
|
||||
drink.Drinking = true;
|
||||
drink.ForceDrink = user != target;
|
||||
|
||||
if (drink.ForceDrink)
|
||||
@@ -286,11 +287,10 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
/// </summary>
|
||||
private void OnDoAfter(EntityUid uid, DrinkComponent component, DoAfterEvent<DrinkData> args)
|
||||
{
|
||||
//Special cancel if they're force feeding someone.
|
||||
//Allows self to drink multiple times but prevents force feeding drinks to others rapidly.
|
||||
if (args.Cancelled && component.ForceDrink)
|
||||
if (args.Cancelled)
|
||||
{
|
||||
component.ForceDrink = false;
|
||||
component.Drinking = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -374,6 +374,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
//TODO: Grab the stomach UIDs somehow without using Owner
|
||||
_stomachSystem.TryTransferSolution(firstStomach.Value.Comp.Owner, drained, firstStomach.Value.Comp);
|
||||
|
||||
component.Drinking = false;
|
||||
component.ForceDrink = false;
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user