Skip to content

Commit

Permalink
CVar Food/Drink AutoEating (Simple-Station#571)
Browse files Browse the repository at this point in the history
<details><summary><h1>Media</h1></summary>
<p>


https://github.com/user-attachments/assets/1276c50a-b50b-45a9-a69f-17bca32c736c

</p>
</details>

---

# Changelog

:cl:
- tweak: You no longer eat food like a starving wolf or something
  • Loading branch information
DEATHB4DEFEAT authored Jul 20, 2024
1 parent 9260f45 commit da20e7f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Server.Popups;
using Content.Shared.Administration.Logs;
using Content.Shared.Body.Components;
using Content.Shared.CCVar;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
Expand All @@ -29,6 +30,7 @@
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand Down Expand Up @@ -56,6 +58,7 @@ public sealed class DrinkSystem : EntitySystem
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly StomachSystem _stomach = default!;
[Dependency] private readonly ForensicsSystem _forensics = default!;
[Dependency] private readonly IConfigurationManager _config = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -399,7 +402,7 @@ private void OnDoAfter(Entity<DrinkComponent> entity, ref ConsumeDoAfterEvent ar

_forensics.TransferDna(entity, args.Target.Value);

if (!forceDrink && solution.Volume > 0)
if (_config.GetCVar(CCVars.GameAutoEatDrinks) && !forceDrink && solution.Volume > 0)
args.Repeat = true;
}

Expand Down
5 changes: 4 additions & 1 deletion Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Utility;
using System.Linq;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;

namespace Content.Server.Nutrition.EntitySystems;

Expand All @@ -55,6 +57,7 @@ public sealed class FoodSystem : EntitySystem
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly StomachSystem _stomach = default!;
[Dependency] private readonly UtensilSystem _utensil = default!;
[Dependency] private readonly IConfigurationManager _config = default!;

public const float MaxFeedDistance = 1.0f;

Expand Down Expand Up @@ -287,7 +290,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
_utensil.TryBreak(utensil, args.User);
}

args.Repeat = !forceFeed;
args.Repeat = _config.GetCVar(CCVars.GameAutoEatFood) && !forceFeed;

if (TryComp<StackComponent>(entity, out var stack))
{
Expand Down
13 changes: 13 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,19 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<int> GameLoadoutsPoints =
CVarDef.Create("game.loadouts_points", 14, CVar.REPLICATED);


/// <summary>
/// Whether to repeat eating doafters after completion
/// </summary>
public static readonly CVarDef<bool> GameAutoEatFood =
CVarDef.Create("game.auto_eat_food", false, CVar.REPLICATED);

/// <summary>
/// Whether to repeat drinking doafters after completion
/// </summary>
public static readonly CVarDef<bool> GameAutoEatDrinks =
CVarDef.Create("game.auto_eat_drinks", false, CVar.REPLICATED);

#if EXCEPTION_TOLERANCE
/// <summary>
/// Amount of times round start must fail before the server is shut down.
Expand Down

0 comments on commit da20e7f

Please sign in to comment.