Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Shitmed] Increase Brain Eating Time & Show Brain Eating Popup #1563

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Content.Server/Nutrition/Components/FoodComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public sealed partial class FoodComponent : Component
[DataField]
public float ForceFeedDelay = 3;

/// <summary>
/// Shitmed Change: Whether to show a popup to everyone in range when attempting to eat this food, and upon successful eating.
/// </summary>
[DataField]
public bool PopupOnEat;

/// <summary>
/// For mobs that are food, requires killing them before eating.
/// </summary>
Expand Down
41 changes: 38 additions & 3 deletions Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Popups; // Shitmed Change
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player; // Shitmed Change
using Robust.Shared.Utility;
using System.Linq;
using Content.Shared.CCVar;
Expand Down Expand Up @@ -164,10 +166,14 @@ private void OnFeedFood(Entity<FoodComponent> entity, ref AfterInteractEvent arg
return (false, true);
}

// Shitmed Change
EntityUid? userName = null;

var forceFeed = user != target;
if (forceFeed)
{
var userName = Identity.Entity(user, EntityManager);
// Shitmed Change
userName = Identity.Entity(user, EntityManager);
_popup.PopupEntity(
Loc.GetString("food-system-force-feed", ("user", userName)),
user,
Expand Down Expand Up @@ -204,7 +210,25 @@ private void OnFeedFood(Entity<FoodComponent> entity, ref AfterInteractEvent arg
NeedHand = forceFeed
};

_doAfter.TryStartDoAfter(doAfterArgs);
// Shitmed Change - track success of doafter to prevent popup on doafter cancel
var doAfterSuccess = _doAfter.TryStartDoAfter(doAfterArgs);

// Shitmed Change
if (foodComp.PopupOnEat && doAfterSuccess)
{
userName ??= Identity.Entity(user, EntityManager);
var foodName = Identity.Entity(food, EntityManager);
_popup.PopupPredicted(
!forceFeed
? Loc.GetString("food-system-eat-broadcasted", ("user", userName), ("food", foodName))
: Loc.GetString("food-system-force-feed-broadcasted", ("user", userName), ("target", Identity.Entity(target, EntityManager)), ("food", foodName)),
user, target, PopupType.SmallCaution);

if (!forceFeed)
_popup.PopupEntity(Loc.GetString("food-system-eat-broadcasted-self", ("user", userName), ("food", foodName)),
user, target, PopupType.SmallCaution);
}

return (true, true);
}

Expand Down Expand Up @@ -277,17 +301,28 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
{
var targetName = Identity.Entity(args.Target.Value, EntityManager);
var userName = Identity.Entity(args.User, EntityManager);
_popup.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName), ("flavors", flavors)), entity.Owner, entity.Owner);
_popup.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName), ("flavors", flavors)), args.Target.Value, args.Target.Value);

_popup.PopupEntity(Loc.GetString("food-system-force-feed-success-user", ("target", targetName)), args.User, args.User);

// Shitmed change
if (entity.Comp.PopupOnEat)
_popup.PopupEntity(Loc.GetString("food-system-force-feed-broadcasted-success", ("user", userName), ("target", targetName), ("food", Identity.Entity(entity.Owner, EntityManager))),
args.User, Filter.Pvs(args.User, entityManager: EntityManager).RemovePlayersByAttachedEntity([args.User, args.Target.Value]),
true, PopupType.MediumCaution);

// log successful force feed
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(entity.Owner):user} forced {ToPrettyString(args.User):target} to eat {ToPrettyString(entity.Owner):food}");
}
else
{
_popup.PopupEntity(Loc.GetString(entity.Comp.EatMessage, ("food", entity.Owner), ("flavors", flavors)), args.User, args.User);

// Shitmed change
if (entity.Comp.PopupOnEat)
_popup.PopupPredicted(Loc.GetString("food-system-eat-broadcasted-success", ("user", Identity.Entity(args.User, EntityManager)), ("food", Identity.Entity(entity.Owner, EntityManager))),
args.User, args.User, PopupType.MediumCaution);

// log successful voluntary eating
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} ate {ToPrettyString(entity.Owner):food}");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## System

food-system-eat-broadcasted = {CAPITALIZE(THE($user))} is trying to eat {THE($food)}!
food-system-eat-broadcasted-self = You start trying to eat {THE($food)}!
food-system-force-feed-broadcasted = {CAPITALIZE(THE($user))} is trying to feed {THE($target)} {THE($food)}!
food-system-force-feed-broadcasted-success = {CAPITALIZE(THE($user))} forced {THE($target)} to eat {THE($food)}!
food-system-eat-broadcasted-success = {CAPITALIZE(THE($user))} ate {THE($food)}!
4 changes: 4 additions & 0 deletions Resources/Prototypes/Body/Organs/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
state: brain
- type: Organ # Shitmed
slotId: brain
- type: Food # Shitmed Change
delay: 5
forceFeedDelay: 6
popupOnEat: true
- type: Brain # Shitmed
- type: SolutionContainerManager
solutions:
Expand Down
6 changes: 5 additions & 1 deletion Resources/Prototypes/Body/Organs/human.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
state: brain
- type: Organ
slotId: brain # Shitmed Change
- type: Food # Shitmed Change
delay: 5
forceFeedDelay: 6
popupOnEat: true
- type: Input
context: "ghost"
- type: Brain
Expand Down Expand Up @@ -73,7 +77,7 @@
entries:
Burger: Brain
Taco: Brain

- type: entity
id: OrganHumanEyes
parent: BaseHumanOrgan
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/_Shitmed/Body/Organs/Animal/animal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
state: brain
- type: Organ
slotId: brain
- type: Food
delay: 5
forceFeedDelay: 6
popupOnEat: true
- type: Input
context: "ghost"
- type: Brain
Expand Down
Loading