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

 *****HubSystem added CreateNewHub + code refactoring- added HubBuild UI - 
IndustrySystem update, code refactoring and code/base/database upgrade, fixing spaghetti -
Code Refactoring*****


HubSystem
 - Again, yeah i know! But now I added CreateNewHub, and done some code refactoring. Lets dig in!

From UI the necessary data now is cityIndex, and type, which as we said is frmo Enum and HubType scriptable object.


  
So basically same as for upgrade, only this time we are doing something else. Ghost. yes. So i thought how can we apply the same -1 tick for timer for upgrade, now for construction.. Where? How? i didnt have clear idea, but i thought wait, what if we create a hub, but dont show it , so simply add bool isUnderConstruction = true, and if it is, dont show it and cant be used.! (Which reminds me i have to add that same condition for office Workload calculation.....dang) 

In essence, we create a hub immediatly, but bool it underConstruction untill the timer runs out, then we change bool to false, and bang, the new Hub just appeared!!

Also , noticing something really cool??? Look at those var variables.. so I wanted to make my code cleaner then found one example, and of course, abused it. So now, I will apply and I am applying same code cleaniness to whole code. so instead of writing

if(WorldManager.Instance.globalMoney.dcurrentcash >= WorldManager.Instance.hubDatabase.allHubs[(int)type].defaultState.constructioncost) {} 👀👀👀👀

We write... if(currentCash >= constructionCost) 😍😍😍

For real, this..is...sexy...

and we define

var currentCash = wm.globalMoney.currentCash;
        var hubDatabase = wm.hubDatabase.allHubs;
        var cities = wm.runtimeCities;
        float constructionCost = hubDatabase[(int)type].defaultState.constructionCost;


            **Proud Gif**
______________________________________________________________________________



IndustryTierData..pain...again..

This is not finished yet, but, the essence is this.

Because we introduced the Tier in industry. The tier has now to have all the necessary values that would change when the Industry Is upgraded. So that includes, the upgradeCost, upgradeTime, constructionCost, maxWorkers etc... Because the industry doesnt know that, and when its upgraded it has to get all those values and then recalcualate it, and update UI.

So , then we have had, industryData that cotains the list with industryStates(struct) as defaultState, which then would load in RAM, then it would be basically slapped with all the infro from the industryData from the inspector. And done thats it. but see, we dont have nothing to do with tiers. Because that systm that was before worked well when the industry upgrade was as we had it before ( industrysize +1); industry max workers  = size * 10... 

but now we cant do that we hav eto load all the data from the tier, depending on which tier it is, but then, the issue...

we must have all the double values, so the struct must have all the values that are as well within the IndustryTierData, and then it all has to be filled in, but we are already taking those data from the IndustryData default state, so then overwriting data later. PLUS , depending on which porduct the industry is producing that also gives the modifier, so we know the efficiency of industry and output based upon the setvalues in the ProductData, which is yes another database...So that was really messy.

 The solution was ( if anyone is still following, or cares hahaha kidding) was to remove defaultState which contains IndustryState(struct) that was filled with data within the inspector. and simply have the IndustryStruct completely Empty, and for IndustryData only put few variables that are not in the tier.SO then via, INdustrySystem we fill in everything , from the IndustryData , which contains basic values and ProductType, then using that we will in the ProductData from the ProductDatabase (over enum ProductType) , and then we also fill in the last data wihich is IndustryTier....whef

another Example:


public static void UpdateIndustryCapacities(ref IndustryState industry)
{
var tier = GetFreshTier(industry.industryTier);

//calculate MaxWorkers
industry.maxWorkers = tier.maxWorkers;


//dodaj radnike za Saate Owned INdustry
if (industry.isPlayerOwned == false)
{
industry.currentWorkers = tier.maxWorkers;
}


Here we can see (refactoring khm...) , that now we are taking Industry struct and filling it with tier information , and donw, if is State Owned, then there ar emax workers (game design ignore it) 

So what is left her eto do is...to do all the i wrote above...  (ref The Solution was() ) I just wrapped the idea, and started working on it..but after 10 hours today, its good that I am able to write down anything. 




_____________________________________________________________________________________


And, HubBuild Ui , as promised!!! 








Its rough I know, and it will have more changes, and better organized info.. but this is for the MVP..

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 #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