Devlog #40-42 - OfficeSystem Bug- and optimisation , HubType, introducing Enum and bug fixes ,

 *******OfficeSystem bug with upgrading, optimisation ( running update data only when upgrade happens) , same for HubType and HubSystem , same issue occured.*******


Essentially , Office upgrade was happening via office.tier += 1 in simple terms, the thing was that the office size and information, max workers etc, ( as we discussed in previous logs) , didnt come from any tier information, but from scriptable object, in synch with Enum. So , officeType.SmallOffice had certain data, but didnt care about the tier. Another issue was that even after 'tierUpgrade' that does essentially nothing, the data would still update from the Enum officeType, which would just always take the old embedded data. Same it waw happening to the Hub. Lets take an example


We have officeType.Small office max workers = x, upkeep = x  

Eachturn the Updateoffice method goes, to check ( in case the office upgrades it should take new values) but why would it run each turn? it can run only when the actual upgrade happens? yeah i realized that later..


we say ok we upgrade office to have more workers, the upgrade happens, office.tier + = 1;



nothing happens. The office runs each tick and takes the old data, and old information. Even if i change it manually, it still goes to the first Small office and takes data.

So the solution was , not to use Tier at all, but rather use the same enum.

So then the method for upgrade calls the office.type = (OfficeType)((int)office.type +1 ; 

Which means, the office type converted to int and added to the value, which means if the enum value of small office = 0, we chang ethe enum value to 1, and then the office loads the database ONLY THEN from the database which contains data for the "medium office' ( if we say that on the enum 1 is medium office).


Does that makes sense? 

Same was happening to the HUB, same issue. Store...but luckily the system is universal, so it works well for all changes! So now except that its wokring, its even lighter on the cpu, that only updates the infromation once per turn.






Thank you!


Comments

Popular posts from this blog

Devlog #47 - TaxSystem/FinanceSystem ,Update-FIx -LoanFixes-- TruckSystem Update - Upgrade/BuyNEwTruck - Costs Prices introduced / OfficeSystem CreateNewOffice, upgrade office - other Fixes

Devlog #46 - HubSystem - CreatNewHub added, HubBuild Ui + INdustrySystem Update - -INdustryTierData to be combined with the IndustryData and IndustryState struct -

Devlog #49-50 - Asset System-NEW system, *Game Design* -construction costs update - LoanSystem- fix-redesign-upgrade,Bug fixes-storeSystem,AutoAdvance Day, Market system, Truck System cost redesign, refactored, Ui bug fixes