Beispiel #1
0
        public void OnLoaded(object sender, OnLoadedEvent loadedEvent)
        {
            try{
                foreach (Vector3 vector in District.PlayerAddedColors.ToArray())
                {
                    Color  color  = ColorConversions.ConvertVector3ToColor(vector);
                    Swatch swatch = District.Swatches.Find(i => i.color == color);
                    if (swatch != null)
                    {
                        District.Swatches.Remove(swatch);
                        Destroy(swatch.gameObject);
                    }
                }
            }catch (Exception err)
            {
                Mod.helper.Log(err.ToString());
            }

            string json = LoadSave.ReadDataGeneric("DistrictModV2", "DistrictModV2Identifier");

            if (json != null)
            {
                var savedObject = Newtonsoft.Json.JsonConvert.DeserializeObject <DistrictSave>(json);
                District.DistrictBuildingData = savedObject.DistrictBuildingData;
                District.PlayerAddedColors    = ColorConversions.ConvertArrayToList(savedObject.PlayerAddedColors);
            }
            else
            {
                Mod.helper.Log("JSON IS NULL");
            }

            LoadSwatches();
            LoadBuildingColors();
        }
Beispiel #2
0
 public static void OnLoaded(object sender, OnLoadedEvent loadedEvent)
 {
     foreach (ModEvent _event in events)
     {
         Type saveObjType = _event.saveObject;
         if (LoadSave.ReadDataGeneric(Mod.modID, _event.saveID) != null)
         {
             _event.OnLoaded(Newtonsoft.Json.JsonConvert.DeserializeObject(LoadSave.ReadDataGeneric("insaneDifficultyMod", _event.saveID), saveObjType));
         }
     }
 }
        // Loads higher tax rates.
        public void OnLoaded(object sender, OnLoadedEvent loadedEvent)
        {
            int landmassesCount = Player.inst.PlayerLandmassOwner.ownedLandMasses.Count;

            for (int i = 0; i < landmassesCount; i++)
            {
                int    landmassId          = Player.inst.PlayerLandmassOwner.ownedLandMasses.data[i];
                float  currentTaxRate      = Player.inst.GetTaxRate(landmassId);
                string higherTaxRateString = LoadSave.ReadDataGeneric(modSaveId, $"{landmassId}");

                // If the current tax rate is less than 30%, don't set the higher tax rate. This covers the case where
                // the player set a higher tax rate, deleted the mod, then set a <30% tax rate, then installed the mod
                // again. Most likely the player would want to stay at the <30% tax rate.
                if (!string.IsNullOrEmpty(higherTaxRateString) && currentTaxRate >= 3f)
                {
                    float higherTaxRate = float.Parse(higherTaxRateString);
                    Player.inst.SetTaxRate(landmassId, higherTaxRate);
                }
            }
        }
Beispiel #4
0
        public static IEnumerator PreloadResources()
        {
            yield return(instance.PreloadResourcesInternal());

            OnLoadedEvent?.Invoke();
        }
Beispiel #5
0
 public override void FinishLoading()
 {
     OnLoadedEvent.Invoke();
     canvasGroup.DOFade(0.0f, 1f).SetDelay(0.3f).OnComplete(() => { GameObject.Destroy(this.gameObject); });
 }