Пример #1
0
        public TitheEntryGlobal()
        {
            this.requestedTitheAmount = (int)TitheUtilities.TaxCalculation(50000);
            this.titheDef             = DefDatabase <TitheDef> .GetRandom();

            //         this.ID = CorruptionStoryTrackerUtilities.currentStoryTracker.GetTitheID();
        }
Пример #2
0
        public static void CalculateColonyTithes(CorruptionStoryTracker tracker)
        {
            Log.Message("Calculating Tithes");
            float      wealthInt = 0f;
            List <Map> maps      = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                if (maps[i].IsPlayerHome)
                {
                    wealthInt += maps[i].wealthWatcher.WealthTotal;
                }
            }
            float calc = 0f;

            float totalAmount = TitheUtilities.TaxCalculation(wealthInt);
            float baseAmount  = totalAmount / DefDatabase <TitheDef> .AllDefsListForReading.Count;

            foreach (TitheDef current in DefDatabase <TitheDef> .AllDefsListForReading)
            {
                if (!tracker.currentTithes.Any(x => x.titheDef == current))
                {
                    if (calc <= totalAmount)
                    {
                        calc += baseAmount;
                        float            num   = baseAmount * current.wealthFactor;
                        TitheEntryGlobal entry = new TitheEntryGlobal(current, num);
                        tracker.currentTithes.Add(entry);
                    }
                }
            }
            tracker.DaysToTitheCollection = 60;
            tracker.TitheCollectionActive = false;
        }
Пример #3
0
        private bool SetItemToCollect(TitheContainer container, out int count, out Thing thing)
        {
            List <ThingDef> listTithes = container.titheDefsEnabled;

            if (!container.currentTitheEntries.NullOrEmpty())
            {
                TitheEntryForContainer entry       = container.currentTitheEntries.RandomElement();
                TitheEntryGlobal       globalEntry = entry.Tithe;
                if (globalEntry.tithePercent < 1f && entry.active)
                {
                    List <Thing> list = (from x in CaravanFormingUtility.AllReachableColonyItems(container.Map, false, false) where globalEntry.thingDefs.Contains(x.def) select x).ToList();
                    if (!list.NullOrEmpty())
                    {
                        thing = list.RandomElement();
                        float num  = Mathf.Min((int)TitheUtilities.SpaceRemainingForThing(container.compTithe, thing) / thing.GetStatValue(StatDefOf.Mass), thing.stackCount);
                        float num2 = TitheUtilities.RemainingTitheToCollect(globalEntry, thing);
                        int   num3 = (int)(Mathf.Min(num, num2));
                        if (num3 < 1)
                        {
                            if (globalEntry.tithePercent < 1f)
                            {
                                num3 = 1;
                            }
                            else
                            {
                                count = 0;
                                return(false);
                            }
                        }
                        count = num3;

                        return(true);
                    }
                }
            }
            thing = null;
            count = 0;
            return(false);
        }