Skip to content

Commit

Permalink
feat(traits): add new trait Voracious
Browse files Browse the repository at this point in the history
  • Loading branch information
angelofallars committed Aug 4, 2024
1 parent 62045ff commit a3263b6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Throwing;
using Content.Shared.Traits.Assorted.Components;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
Expand Down Expand Up @@ -279,9 +280,13 @@ private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, En

var flavors = _flavorProfile.GetLocalizedFlavorsMessage(user, drinkSolution);

var drinkDelay = drink.Delay;
if (TryComp<ConsumeDelayModifierComponent>(target, out var delayModifier))
drinkDelay *= delayModifier.DrinkDelayMultiplier;

var doAfterEventArgs = new DoAfterArgs(EntityManager,
user,
forceDrink ? drink.ForceFeedDelay : drink.Delay,
forceDrink ? drink.ForceFeedDelay : drinkDelay,
new ConsumeDoAfterEvent(drink.Solution, flavors),
eventTarget: item,
target: target,
Expand Down
7 changes: 6 additions & 1 deletion Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Traits.Assorted.Components;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
Expand Down Expand Up @@ -176,9 +177,13 @@ private void OnFeedFood(Entity<FoodComponent> entity, ref AfterInteractEvent arg
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is eating {ToPrettyString(food):food} {SolutionContainerSystem.ToPrettyString(foodSolution)}");
}

var foodDelay = foodComp.Delay;
if (TryComp<ConsumeDelayModifierComponent>(target, out var delayModifier))
foodDelay *= delayModifier.FoodDelayMultiplier;

var doAfterArgs = new DoAfterArgs(EntityManager,
user,
forceFeed ? foodComp.ForceFeedDelay : foodComp.Delay,
forceFeed ? foodComp.ForceFeedDelay : foodDelay,
new ConsumeDoAfterEvent(foodComp.Solution, flavors),
eventTarget: food,
target: target,
Expand Down
22 changes: 22 additions & 0 deletions Content.Server/Traits/Assorted/ConsumeDelayModifierComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Traits.Assorted.Components;

/// <summary>
/// This is used for any trait that modifies how fast an entity consumes food and drinks.
/// </summary>
[RegisterComponent]
public sealed partial class ConsumeDelayModifierComponent : Component
{
/// <summary>
/// What to multiply the eating delay by.
/// </summary>
[DataField]
public float FoodDelayMultiplier { get; set; } = 1f;

/// <summary>
/// What to multiply the drinking delay by.
/// </summary>
[DataField]
public float DrinkDelayMultiplier { get; set; } = 1f;
}
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ trait-name-Foreigner = Foreigner
trait-description-Foreigner =
For one reason or another you do not speak this station's primary language.
Instead, you have a translator issued to you that only you can use.
trait-name-Voracious = Voracious
trait-description-Voracious = Nothing gets between you and your food.
You eat food and drink drinks twice as fast.
9 changes: 9 additions & 0 deletions Resources/Prototypes/Traits/skills.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@
inverted: true
species:
- Felinid

- type: trait
id: Voracious
category: Physical
points: -1
components:
- type: ConsumeDelayModifier
foodDelayMultiplier: 0.5
drinkDelayMultiplier: 0.5

0 comments on commit a3263b6

Please sign in to comment.