space-station-14 icon indicating copy to clipboard operation
space-station-14 copied to clipboard

Refactor hunger and thirst systems

Open Lukasz825700516 opened this issue 9 months ago • 1 comments

About the PR

The common logic of those systems was moved into new SatiationSystem that serves as the common base for them. Also it introduces an ability to have damage on different satiation (old thirst and hunger) thresholds.

Why / Balance

The old ThirstSystem was almost the same as HungerSystem.

Technical details

The new SatiationSystem operates on new SatiationComponent which was created by merging Thirst and Hunger components together. The data of merged components has been separated by putting it into new data definition Satiation, which is now part of the Satiation component (one Satiation for thirst, and one for hunger)

Thirst and hunger thresholds enum have been merged into new SatiationThreshold, that would be shared between them and future new Thirst/Hunger systems.

Media

  • [x] I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

Fields of old Hunger and Thirst components are now accessed through the Thirst and Hunger fields. Changed the signature of ModifyThirst, now it accepts nullable component as third argument instead of second. Removed Thirst Hunger specific mentions from field names. Merged the HungerSystem and ThirstSystem into new SatiationSystem. Merged the ShowHungerIconsSystem and ShowThirstIconsSystem into ShowSatiationIconsSystem As side effect of merging HungerComponent and ThirstComponent, new Thirst and Hunger fields in SatiationComponent share default values.

Changelog

:cl:

  • tweak: Thirst and hunger systems now share common logic.

Lukasz825700516 avatar Apr 29 '24 10:04 Lukasz825700516

Just combine hunger and thirst component as there's a lot of weird code trying to skirt around this.

I think it now looks bit messy, but done.

Lukasz825700516 avatar Apr 30 '24 04:04 Lukasz825700516

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

github-actions[bot] avatar May 13 '24 01:05 github-actions[bot]

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

github-actions[bot] avatar May 24 '24 03:05 github-actions[bot]

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

github-actions[bot] avatar May 31 '24 18:05 github-actions[bot]

This looks pretty good, only one problem. I completely rewrote how hunger is handled in newmed... 😅 That being said, It's going to be a bit before newmed is merged so I don't see why this couldn't be used in the meantime since it sounds/looks like a big improvement over the current hunger/thirst system. (I haven't been able to do a code review because github web is fucking completely unusable for reviewing large prs)

Some elements of this could be reused by the newmed hunger/thirst implementation but a lot of this is made redundant by the blood-glucose and fast/slow calorie storage system that newmed uses instead of a more traditional saturation/hunger approach like you went with.

Jezithyr avatar Jun 14 '24 11:06 Jezithyr

Quick one from me as I don't have time to read the code (sorry): when hacking in the April Fools slugcats I had to bolt on code to the old hunger system to monitor hunger so I could detect when a scug had eaten enough to conclude their prep-for-hibernation target. How event-driven is this system?

FairlySadPanda avatar Jun 14 '24 11:06 FairlySadPanda

Quick one from me as I don't have time to read the code (sorry): when hacking in the April Fools slugcats I had to bolt on code to the old hunger system to monitor hunger so I could detect when a scug had eaten enough to conclude their prep-for-hibernation target. How event-driven is this system?

As all of master code that touched the Hunger/Thirst system just read their value of hunger and thirst respectively, or just checked if it was on specific level I haven't added any events that would notify about changes. But now when you mention that, I see there could be added event for change of the current satiation threshold. If you look for something like this, I will make another PR with it after this one is done.

This looks pretty good, only one problem. I completely rewrote how hunger is handled in newmed... 😅 That being said, It's going to be a bit before newmed is merged so I don't see why this couldn't be used in the meantime since it sounds/looks like a big improvement over the current hunger/thirst system. (I haven't been able to do a code review because github web is fucking completely unusable for reviewing large prs)

Some elements of this could be reused by the newmed hunger/thirst implementation but a lot of this is made redundant by the blood-glucose and fast/slow calorie storage system that newmed uses instead of a more traditional saturation/hunger approach like you went with.

Probably newmed will supersede entirely this satiation system for hunger/thirst, but the system alone should be flexible enough to be able support some other type of constantly decreasing metrics. It would probably require some small changes then - more generic threshold effect handling?

Lukasz825700516 avatar Jun 17 '24 15:06 Lukasz825700516

uhh... why does yaml test fails? the UsedSatiation is in UdderComponent

Lukasz825700516 avatar Jun 17 '24 15:06 Lukasz825700516

uhh... why does yaml test fails? the UsedSatiation is in UdderComponent

Datafields are automatically renamed, you need to use usedSatiation in the prototype

AJCM-git avatar Jun 17 '24 21:06 AJCM-git

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

github-actions[bot] avatar Jun 20 '24 00:06 github-actions[bot]

Re-open if you come back to it.

metalgearsloth avatar Jul 11 '24 01:07 metalgearsloth