Fixes mouse self-eating (#5622)

This commit is contained in:
FoLoKe
2021-11-30 13:45:33 +03:00
committed by GitHub
parent da73e271c6
commit 6f455346b2
2 changed files with 13 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.MobState.Components;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -115,6 +116,10 @@ namespace Content.Server.Nutrition.EntitySystems
if (!Resolve(uid, ref component))
return false;
if (uid == userUid || //Suppresses self-eating
EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive()) // Suppresses eating alive mobs
return false;
if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var solution))
return false;
@@ -201,16 +206,20 @@ namespace Content.Server.Nutrition.EntitySystems
private void AddEatVerb(EntityUid uid, FoodComponent component, GetInteractionVerbsEvent ev)
{
if (!ev.CanInteract ||
if (uid == ev.UserUid ||
!ev.CanInteract ||
!ev.CanAccess ||
!EntityManager.TryGetComponent(ev.User.Uid, out SharedBodyComponent? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(ev.User.Uid, out var stomachs, body))
!EntityManager.TryGetComponent(ev.UserUid, out SharedBodyComponent? body) ||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(ev.UserUid, out var stomachs, body))
return;
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
return;
Verb verb = new();
verb.Act = () =>
{
TryUseFood(uid, ev.User.Uid, component);
TryUseFood(uid, ev.UserUid, component);
};
verb.Text = Loc.GetString("food-system-verb-eat");