-
Notifications
You must be signed in to change notification settings - Fork 599
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
Food Quality System (Goblin) #1159
Conversation
Here we go, time to move it all. |
Missing mail eating for Clarrpy / moth (Only opened one for moth) |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
….ftl Co-authored-by: whatston3 <[email protected]>
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
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.
|
||
/// <summary> | ||
/// Frontier - Edited by the system to find the final quility results | ||
/// </summary> | ||
[DataField, ViewVariables] // Frontier | ||
public string FinalQuality = "Normal"; |
There was a problem hiding this comment.
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.
/// <summary> | |
/// Frontier - Edited by the system to find the final quility results | |
/// </summary> | |
[DataField, ViewVariables] // Frontier | |
public string FinalQuality = "Normal"; |
// 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} | ||
}; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
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 |
There was a problem hiding this comment.
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
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 |
var speedRegent = "Stimulants"; | ||
var damagingRegent = "Toxin"; | ||
var emoteId = "Laugh"; |
There was a problem hiding this comment.
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.
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" }; |
There was a problem hiding this comment.
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.
Co-authored-by: whatston3 <[email protected]>
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This is getting reopen in new PR |
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:
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:
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
Media
Breaking changes
WIP.
Changelog
🆑 dvir01