Add the worker action for irrigation
Like #493, we should support irrigating tiles, and loading save files that have irrigation.
@TomWerner I see the basic irrigation action is done already, correct? But the multi Turn part is missing. Do you minbd if I try my hand at this?
Please do!
A couple of pointers:
- This doc has some notes about how stacks of workers operate
-
Tfrm.cs has the worker move costs. I'm guessing the
Requiredfield in that struct is an index into the list of techs, but I don't know for sure. I'm also not sure what theOrderstring is there. Any easy way to printf debug this kind of thing is withConsole.WriteLogstatements and then running the unit tests, which loads a standard game and some scenarios. To see the logs you'll wantdotnet test -v n. -
Unit.csin the sav section has information about active worker jobs and based on this forum post this unknown buffer might be the worker speed (native vs captured worker).
@TomWerner I have about good practices that came up while using the terraform data.
I would like to change the WorkerJob attribute directly to a reference of a Terraform object. This would make all of the corresponding functions much easier to write and faster to run. However it means that at some points I need to switch from the order to the Terraform by finding the correct terraform with a linq query.
The first spot is the irrigate function. This function gets called by message and currently has no references to the gamedata. Here I wonder if it is allowed/possible to send the list of terraforms with the ActionToEngineMsg function? Or if it is okay, to calculate the cirrect Terraform berforehand and then call the ActionToEngineMsg with that terraform as a parameter.
The second spot is when mapping old save data to our format. If I understand it correctly we are using the old formats readOnly, meaning, after creating the game from them we only use our own save format to save the game afterwards, so I would not need a function which converts terraforms back into numbers, correct? but for the convertion when reading the current worker jobs of units I would at this time only need an attribute in the terraform which shows that number. Now I feel bad about adding an attribute that get never used at any later point in time. Any suggestion on how this could best be handled. (PS The solution in the current code is that horrible hardcoding that should surely not be used anymore.)
Thanks for any Pointers and If you would rather see the copmplete code first, I can also provide a draft pull request with one of the options.
This function gets called by message and currently has no references to the gamedata
Within the process function of a MessageToEngine subclass it's totally ok to access the game data via EngineStorage.gameData, like we do here: https://github.com/C7-Game/Prototype/blob/e14a7a8e54c4aac794478427c93b0ca46ee1cce1/C7Engine/EntryPoints/MessageToEngine.cs#L57
If I understand it correctly we are using the old formats readOnly, meaning, after creating the game from them we only use our own save format to save the game afterwards, so I would not need a function which converts terraforms back into numbers, correct?
Correct.
but for the convertion when reading the current worker jobs of units I would at this time only need an attribute in the terraform which shows that number. Now I feel bad about adding an attribute that get never used at any later point in time. Any suggestion on how this could best be handled. (PS The solution in the current code is that horrible hardcoding that should surely not be used anymore.)
Within ImportCiv3.cs I would feel comfortable indexing into the imported list of terraform objects by the worker job index in the sav file.
So something like save.Terraforms[savObj.workerJobIndex] (variable names made up).
Open Todos
- Check for blocking between WorkerJobs
- Choose the correct animation (currently everybody is irrigating) (DONE)
- Implement the generic version for saving and loading (DONE)
- Find out how to best test the WorkerAI (DONE)
- The Tooltext is still missing (DONE)
- Fix MultiworkerJobs, to finish all workers at once, [OUT OF SCOPE]