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

Food Quality System (Goblin) #1159

Conversation

ErhardSteinhauer
Copy link
Contributor

@ErhardSteinhauer ErhardSteinhauer commented Mar 27, 2024

About the PR

New food quality system for species to enjoy (or suffer). Right now the only species affected by the new system are goblins. Food quality is divided into the following categories:

  • High. Consuming high-quality food grants you minor bonuses, like health regeneration, but slightly more than normal food.
  • Normal. Consuming high-quality food grants minor bonuses, like health regeneration.
  • Low. Just satiates your hunger.
  • Nasty. Consuming nasty quality food causes slight poisoning.
  • Toxin. Consuming nasty quality food causes severe poisoning.

With goblins, it's the other way around: what other species consider high-quality food is viewed by goblins as toxic, so if a goblin consumes a super bite burger, goblin will severely poison himself. However, anything that other species consider toxic (space shrooms or fly amanita for example) or nasty (like raw meat and body parts) is beneficial for goblins. Additionally, goblins can eat trash like food wrappers, candles, cardboard boxes, etc (but those don't hold too much nutritious value).

Additional food categories for future use:

  • Junk.
  • Mail.
  • Fiber.

Why / Balance

Adds more nuances to the game's food system, and lays the foundation for unique species diets (so eventually moth-persons will be able to feed upon clothes once again).

Technical details

  • Cooked food is good.
  • Junk food is bad.
  • Some food stuffs are in between: not exactly bad, but not good either.

Media

  • This PR does not require an ingame showcase.

Breaking changes

WIP.

Changelog
🆑 dvir01

  • add: Added robust food quality system. Only goblins are affected by it right now, so be careful what you eat if you're a goblin: majority of cooked meals is bad for goblins (except stuff made from xeno/spider/rat meat), raw meats/organs, fly amanita, space shrooms, rotten/moldy foods, snack wrappers, carboard boxes, mail envelopes, egg shells and such are good for goblins.
  • tweak: Moff food is working again for moffs.
  • tweak: Only moff and goblins can eat papers.

@github-actions github-actions bot added the No C# label Mar 27, 2024
@dvir001
Copy link
Contributor

dvir001 commented Mar 27, 2024

Here we go, time to move it all.

@dvir001 dvir001 changed the title (Goblin) Food Quality System Food Quality System (Goblin) Mar 27, 2024
@dvir001 dvir001 mentioned this pull request Mar 27, 2024
1 task
@dvir001 dvir001 mentioned this pull request Mar 31, 2024
1 task
@dvir001
Copy link
Contributor

dvir001 commented Mar 31, 2024

Missing mail eating for Clarrpy / moth (Only opened one for moth)
Missing "Fiber" for moth food.

@github-actions github-actions bot added the S: Merge Conflict This PR has conflicts that prevent merging label Apr 27, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the S: Merge Conflict This PR has conflicts that prevent merging label Apr 27, 2024
Copy link
Contributor

@whatston3 whatston3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review looks good. Testing as a goblin's pretty funny - curious to see goblin clowns try and escape a chase by eating fistfuls of trash. The immediate stimulants into the bloodstream seems a bit odd to me, but it works to good effect.

I've got a few suggested changes, I collected them all up on a branch on my own repo if you'd like to easily test or integrate them in one go: whatston3@4be5bd1 (toxin list additions here: whatston3@1d856d9)

@@ -257,13 +283,140 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
_stomach.TryTransferSolution(stomachToUse.Owner, split, stomachToUse);

/// Frontier - Food quality system
var foodQuality = entity.Comp.Quality;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with suggestion above, replace entity.Comp.FinalQuality with a local variable. It is only used within this function and does not need to live longer. Suggestion uses string as enumeration isn't used at time of writing.

Suggested change
var foodQuality = entity.Comp.Quality;
var foodQuality = entity.Comp.Quality;
var finalFoodQuality = "Junk";

If accepting this, replace all entity.Comp.FinalQuality entries with finalFoodQuality or whatever local variable name you choose.

Comment on lines +86 to +91

/// <summary>
/// Frontier - Edited by the system to find the final quility results
/// </summary>
[DataField, ViewVariables] // Frontier
public string FinalQuality = "Normal";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FinalQuality should be removed as a field in favour of a local variable inside FoodSystem.OnDoAfter - it is not used outside of that function.

Suggested change
/// <summary>
/// Frontier - Edited by the system to find the final quility results
/// </summary>
[DataField, ViewVariables] // Frontier
public string FinalQuality = "Normal";

Comment on lines +565 to +571
// Map each quality to the corresponding component property for digestion capability
var digestionMap = new Dictionary<string, bool>
{
{"Mail", comp.MailDigestion},
{"Fiber", comp.FiberDigestion},
{"Trash", comp.TrashDigestion}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to a static readonly field in the class?

@@ -402,6 +558,40 @@ private bool IsDigestibleBy(EntityUid food, FoodComponent component, List<(Stoma
// Run through the mobs' stomachs
foreach (var (comp, _) in stomachs)
{
// Frontier - Food System
var foodQuality = component.Quality;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can component.Quality be used directly in the foreach?

Comment on lines +573 to +593
foreach (var quality in foodQuality)
{
if (digestionMap.ContainsKey(quality))
{
// Set foodQualityBlock based on whether the specific digestion capability is true
// If the component can digest this type of quality, set to false and break out of the loop
if (digestionMap[quality])
{
foodQualityBlock = false;
break;
}
else
{
// If the component cannot digest this quality, set to true
foodQualityBlock = true;
}
}
}
if (foodQualityBlock)
return false;
// Frontier - Food System
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be made slightly more compact.
Written out as whole:

            foreach (var quality in foodQuality)
            {
                if (digestionMap.ContainsKey(quality))
                {
                    // Set foodQualityBlock based on the specific digestion capability
                    foodQualityBlock = !digestionMap[quality];
                    // If the component can digest any quality in the food, we're done.
                    if (!foodQualityBlock)
                        break;
                }
            }
            if (foodQualityBlock)
                return false;
            // End Frontier - Food System
Suggested change
foreach (var quality in foodQuality)
{
if (digestionMap.ContainsKey(quality))
{
// Set foodQualityBlock based on whether the specific digestion capability is true
// If the component can digest this type of quality, set to false and break out of the loop
if (digestionMap[quality])
{
foodQualityBlock = false;
break;
}
else
{
// If the component cannot digest this quality, set to true
foodQualityBlock = true;
}
}
}
if (foodQualityBlock)
return false;
// Frontier - Food System
foreach (var quality in foodQuality)
{
if (digestionMap.ContainsKey(quality))
{
// Set foodQualityBlock based on the specific digestion capability
foodQualityBlock = !digestionMap[quality];
// If the component can digest any quality in the food, we're done.
if (!foodQualityBlock)
break;
}
}
if (foodQualityBlock)
return false;
// End Frontier - Food System

Comment on lines +313 to +315
var speedRegent = "Stimulants";
var damagingRegent = "Toxin";
var emoteId = "Laugh";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with const versions? Recommendation: refactor Regent->Reagent.

Suggested change
var speedRegent = "Stimulants";
var damagingRegent = "Toxin";
var emoteId = "Laugh";
const string speedRegent = "Stimulants";
const string damagingRegent = "Toxin";
const string emoteId = "Laugh";

// TODO: Add detection for fried food on nasty to update it to toxin for goblins.
// TODO: Add inspect food but only for goblin eyes to see, goblins can tell food quality.

string[] toxinsRegent = { "Toxin", "CarpoToxin", "Mold", "Amatoxin", "SulfuricAcid" };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions:

  • move toxin list to a static readonly field in the class.
  • Rename to ToxinReagents (or toxinReagents if local)
  • Add Gastrotoxin and Bungotoxin, for rotten meat and bungo pits.

Resources/Locale/en-US/_NF/reagents/foods.ftl Outdated Show resolved Hide resolved
@github-actions github-actions bot added the S: Merge Conflict This PR has conflicts that prevent merging label Jun 7, 2024
Copy link
Contributor

github-actions bot commented Jun 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the S: Merge Conflict This PR has conflicts that prevent merging label Jun 14, 2024
@whatston3 whatston3 mentioned this pull request Jun 22, 2024
1 task
@github-actions github-actions bot added the S: Merge Conflict This PR has conflicts that prevent merging label Jul 1, 2024
Copy link
Contributor

github-actions bot commented Jul 1, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@dvir001
Copy link
Contributor

dvir001 commented Aug 10, 2024

This is getting reopen in new PR

@dvir001 dvir001 closed this Aug 10, 2024
@whatston3 whatston3 mentioned this pull request Aug 10, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# FTL S: Awaiting Changes This PR has changes that need to be made before merging S: Merge Conflict This PR has conflicts that prevent merging YML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants