Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request space-wizards#1342 from Elijahrane/cherrypick20230309
Browse files Browse the repository at this point in the history
Round 4 of Doafter fixes (space-wizards#14476)
  • Loading branch information
Elijahrane authored Mar 9, 2023
2 parents d3f1422 + 6577463 commit 89a7bcb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions Content.Server/Fluids/EntitySystems/MoppingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<AbsorbentComponent, ComponentInit>(OnAbsorbentInit);
SubscribeLocalEvent<AbsorbentComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<AbsorbentComponent, SolutionChangedEvent>(OnAbsorbentSolutionChange);
SubscribeLocalEvent<AbsorbentComponent, DoAfterEvent<AbsorbantData>>(OnDoAfter);
}

Expand Down
11 changes: 5 additions & 6 deletions Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, En
var doAfterEventArgs = new DoAfterEventArgs(user, drink.ForceDrink ? drink.ForceFeedDelay : drink.Delay,
target: target, used: item)
{
RaiseOnTarget = drink.ForceDrink,
RaiseOnUser = !drink.ForceDrink,
RaiseOnTarget = user != target,
RaiseOnUser = false,
BreakOnUserMove = drink.ForceDrink,
BreakOnDamage = true,
BreakOnStun = true,
Expand All @@ -295,17 +295,17 @@ private void OnDoAfter(EntityUid uid, DrinkComponent component, DoAfterEvent<Dri
return;
}

if (args.Handled || args.Cancelled || component.Deleted)
if (args.Handled || component.Deleted)
return;

if (!TryComp<BodyComponent>(args.Args.Target, out var body))
return;

component.Drinking = false;

var transferAmount = FixedPoint2.Min(component.TransferAmount, args.AdditionalData.DrinkSolution.Volume);
var drained = _solutionContainerSystem.Drain(uid, args.AdditionalData.DrinkSolution, transferAmount);

//var forceDrink = args.Args.Target.Value != args.Args.User;

if (!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(args.Args.Target.Value, out var stomachs, body))
{
_popupSystem.PopupEntity(component.ForceDrink ? Loc.GetString("drink-component-try-use-drink-cannot-drink-other") : Loc.GetString("drink-component-try-use-drink-had-enough"), args.Args.Target.Value, args.Args.User);
Expand Down Expand Up @@ -375,7 +375,6 @@ private void OnDoAfter(EntityUid uid, DrinkComponent component, DoAfterEvent<Dri
//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;
}
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public bool TryFeed(EntityUid user, EntityUid target, EntityUid food, FoodCompon
var doAfterEventArgs = new DoAfterEventArgs(user, foodComp.ForceFeed ? foodComp.ForceFeedDelay : foodComp.Delay, target: target, used: food)
{
RaiseOnTarget = foodComp.ForceFeed,
RaiseOnUser = !foodComp.ForceFeed,
RaiseOnUser = false, //causes a crash if mice eat if true
BreakOnUserMove = foodComp.ForceFeed,
BreakOnDamage = true,
BreakOnStun = true,
Expand All @@ -160,7 +160,7 @@ private void OnDoAfter(EntityUid uid, FoodComponent component, DoAfterEvent<Food
return;
}

if (args.Cancelled || args.Handled || component.Deleted || args.Args.Target == null)
if (args.Handled || component.Deleted || args.Args.Target == null)
return;

if (!TryComp<BodyComponent>(args.Args.Target.Value, out var body))
Expand Down Expand Up @@ -202,6 +202,7 @@ private void OnDoAfter(EntityUid uid, FoodComponent component, DoAfterEvent<Food

// log successful force feed
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(uid):user} forced {ToPrettyString(args.Args.User):target} to eat {ToPrettyString(uid):food}");
component.ForceFeed = false;
}
else
{
Expand Down

0 comments on commit 89a7bcb

Please sign in to comment.