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

Botany Rework Part 3: Plants as Entities #31941

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

drakewill-CRL
Copy link
Contributor

@drakewill-CRL drakewill-CRL commented Sep 8, 2024

About the PR

This PR creates plants as their own Entities, instead of a bunch of properties on a PlantHolder. SeedData gets moved to the PlantComponent.

This is part 3 of my Botany refactor writeup. Part 2 covers growth components. This is in draft state while I work on this logic for early feedback. While I work on moving and testing code, I'm only going to test on wheat stalks. I'll move everything to the final setup in YAML when I get there.

Why / Balance

As mentioned in the core writeup and other PRs, botany can't really get any major changes because the backend system is mostly handled in one big function and adding anything to that only makes it more difficult to clean up. This strips the plant-specific part out so PlantHolder can just update its lights and resources and the Plant can handle its tasks. Between this, growth components, and the mutation rework, the Botany code will be in a much better state for future maintenance and additions.

This should have no bearings on game balance, because this is just a refactor. A few bugs might be fixed or created in the process of porting code rather than porting poor/broken behavior.

Technical details

Plants are now entities. They are connected to their PlantHolder, and they are spawned when seeds are planted and deleted when they're harvested (if single harvest) or when the shovel is used to pull them out. SeedData is moved to the PlantComponent now.

All the existing plant logic was moved into a single Update() on PlantSystem. Breaking that out to separate components and systems is done in Part 2. It may be too granular to break each stat into its own component/system pair. Merging these should mostly require operating on Plants instead of PlantHolders.

Plants still need a PlantHolder. PlantHolder still has the water/nutrients the plant needs so the plant still need to have a connection to that. I have helper functions that get the Plant, PlantHolder, and SeedData all at once because of how often all 3 get referenced. The 2 entities keep a reference to the other, and blank it out when the plant is removed from the tray.

Plants should grow identically to before, almost entirely unnoticeable to players. As entities, you can see them instead of the tray and view them in the right-click menu. That's visibly different. You also need to apply different items to different entities (EX: clippers must be used on the plant, but spades and chemicals need to be used on the tray itself).

Additional changes:

  • Seed data is now cloned when seeds are planted, produce is made, or seeds are made from produce. This ensure the seed data is always unique, and the checks for uniqueness across the code have been removed.
  • IdealLight/LightTolerance were removed as a cleanup task, because they're unused stats, and now's as good a time as any to finish getting rid of unused code.

Media

probably dont have much to put here. Maybe the menu/inspect differences.

Requirements

  • I have read and I am following the Pull Request Guidelines. I understand that not doing so may get my pr closed at maintainer’s discretion
  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

PlantHolder is pretty dramatically different.

Changelog

🆑

  • tweak: Botany plants are now their own entity. You may need to click on the tray or the plant to do what you want, depending on what you're holding.

@mirrorcult
Copy link
Contributor

🙏

@nymhole
Copy link

nymhole commented Sep 12, 2024

this would also fix every sentience mutation being either hydroponics tray or soil? and it would kill the sentience with the plant?

@drakewill-CRL
Copy link
Contributor Author

this would also fix every sentience mutation being either hydroponics tray or soil?

Yes, This would let the plant itself be sentient.

and it would kill the sentience with the plant?

As written right now, without merging any of the other pieces smartly, this kills the sentience when the plant is destroyed (on shovel use to uproot, or on harvest if its a single-harvest crop). Whether sentient plants should stop aging when possessed, or get an extended lifespan, or just be fully at the mercy of a botanist's skills and patience is an unasked question. I would like the refactors to avoid changing balance or features as much as possible, so I expect that this would go in with "dead plants can talk, talking plants die on harvest" as known side effects and a discussion on how/if to change sentient plants occurs then.

@github-actions github-actions bot added the Merge Conflict This PR currently has conflicts that need to be addressed. label Sep 15, 2024
Copy link
Contributor

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

@github-actions github-actions bot added Changes: UI Can be reviewed or fixed by people who are knowledgeable with UI design Changes: Map Can be reviewed or fixed by people who are knowledgeable with mapping. Changes: Sprites Should be reviewed or fixed by people who are knowledgeable with spriting or visual design. and removed Merge Conflict This PR currently has conflicts that need to be addressed. labels Sep 18, 2024
@drakewill-CRL drakewill-CRL marked this pull request as ready for review September 19, 2024 23:51
@github-actions github-actions bot added the Status: Needs Review This PR requires new reviews before it can be merged. label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Botany Changes: Map Can be reviewed or fixed by people who are knowledgeable with mapping. Changes: Sprites Should be reviewed or fixed by people who are knowledgeable with spriting or visual design. Changes: UI Can be reviewed or fixed by people who are knowledgeable with UI design Status: Needs Review This PR requires new reviews before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants