public override void OnLevelLoaded(LoadMode mode) { try { if (Mod.isEnabled && mode != LoadMode.LoadAsset && mode != LoadMode.NewAsset) { //First we need to gather data about the trees because //info.m_createruining is actually only true on the first load //before we change the assets, this saves us from processing //uncessessary true\false and updates upon re-loads. //What I mean by that is if you loop though the info.m_createruining's //on each tree instance after you change the <TreeInfo>'s you will //always get 'false'...I guess because they are but they've already been //rendered first as true. So we need to figure out who's got to be updated //for that before we actually update the asset's core TreeInfo setting. // //only side effect is we loadup our m_MarkedForUpdate list even //if the option is not enabled... but overall it's worth it for //that use case to take the extra couple milliseconds. adding //and if() to change that also adds tiny per hit so it's almost a wash. int retval = 0; if (Mod.config.UpdateTreeAssets) { //go gather the ones we need for later, and while it's at it //mark their ruining false. uint tcount = countRuiningTrues(); retval = GatherRuiningData(); //ok now go change all 'assets' that are tree, custom or not. SetupAllTreeAssets(); } //Do they have the option set to actually update existing trees on-map-load? //Even if they do, is there anything to actually do? if (Mod.config.UpdateTreeAssets && Mod.config.UpdateResetTrees && m_MarkedForUpdate.Count > 0) { //yea they do! and yeah there is! // are we using couroutine route? if (!m_CoroutineTest) { //no? Good cause it is the suck for our purposes! //go call the expensive operation of updating all the trees //that we need too, the list only includes ones that were //a)created b)have info objects c)are not hidden d)were previously //marked as having ruining=true ie.. not bushes or other assets. //where the prefab was made with ruining = false. ProcessTreesForUpdate(); } else { //testing - only ever called during test builds where you change the trigger var up top. Helper.dbgLog("Using coroutine version. prepare for framerate death ;) ."); gameview = UIView.GetAView(); gameview.StartCoroutine(UpdateExistingTrees()); } } } } catch(Exception ex) {Helper.dbgLog("Exception: ",ex,true);} }