Closed boformer closed 9 years ago
GetRandomBuildingInfo is called in 3 places:
GetRandomBuildingInfo
ZoneBlock.SimulationStep
PrivateBuildingAI.GetUpgradeInfo
PrivateBuildingAI.SimulationStep
We ran into trouble when we tried to detour PrivateBuildingAI.GetUpgradeInfo and PrivateBuildingAI.SimulationStep.
That's why we used a LevelUpExtension and other hacky methods to determine where the building is/will be located.
LevelUpExtension
Luckily I found out how we can detour all of the 3 methods. It will make the code of this mod much clearer and maybe even improve performance:
We have to detour the AI methods for every subclass of PrivateBuildingAI. A very elegant way to do it is to use generics, as seen here.
PrivateBuildingAI
GetRandomBuildingInfo
is called in 3 places:ZoneBlock.SimulationStep
- Places new growables on empty landPrivateBuildingAI.GetUpgradeInfo
- Finds a new growable of the same size (current level +1)PrivateBuildingAI.SimulationStep
- "Downgrades" abandoned buildings to level1 buildingsWe ran into trouble when we tried to detour
PrivateBuildingAI.GetUpgradeInfo
andPrivateBuildingAI.SimulationStep
.That's why we used a
LevelUpExtension
and other hacky methods to determine where the building is/will be located.Luckily I found out how we can detour all of the 3 methods. It will make the code of this mod much clearer and maybe even improve performance:
We have to detour the AI methods for every subclass of
PrivateBuildingAI
. A very elegant way to do it is to use generics, as seen here.