Inflow (Wealth) implementation (Experimental/Proposal) #862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a product of a discussion we had in discord regarding the implementation of "Wealth". Check it out here
There is a lot of boiler plate code because a new type of producable items was introduced.
I ended up calling it Inflow, not that it's a good name, but I spent at least 2 hours searching for a proper term, in the end I just went with something.
This type/category is meant to host items like "Wealth". The wealth producable is fully implemented. I have included 2 other examples with dummy code, I hope you will get the idea.
The point is to have stuff like wealth, that add to the city (and perhaps in the future globally), so in my examples you can see another item called "Cultivation" that is boosting the city's culture based on its current value, and another called "Expertise" that boosts science based on the city's beakers. So it's like Wealth but for Culture and Science.
These are fully exposed to the lua layer so it can do whatever it's instructed, so no need to hardcode anything in C#. We could add more restrictions like after what tech each is available and so on, this is I guess a more minimalistic example as I have simply hardcoded CanProduce() to true.
The triggers that call Lua eventually is in the Player and City classes. All 3 triggers send an integer so that Lua can use to calculate what it should do. At first I was passing the city object, but I had some infinite loop issues where I was calling from lua the method that was calling it in C#, so again, for now and for the sake of simplicity I pass an int to base the calcualtions on. This can change in the future.
If it's any easier for you to understand, I kind of tried to follow the way Terraform/TerraformImprovement is implemented and integrated with Lua.
FInal thing, this is not the "final" implementation, there are many things to be done for this to be actually merged, this is more of a POC.
Let me know what you think or if you have any questions.
@WildWeazel I hope you will like this!
Cheers!