public static int RemainingTitheToCollect(TitheEntryGlobal entry, Thing t) { float num = 0f; num = (entry.requestedTitheAmount - entry.collectedTitheAmount) / t.def.BaseMarketValue; return((int)num); }
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; }
protected override void FillTab() { Rect mainrect = new Rect(0f, 80f, this.size.x, this.size.y); // Log.Message(CorruptionStoryTrackerUtilities.currentStoryTracker.currentTithes.Count.ToString()); Rect rect = new Rect(0f, 0f, this.size.x, 30f); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Medium; Widgets.Label(rect, "AllowedTithes".Translate()); Rect rect5 = new Rect(30f, 35f, 200f, 25f); Widgets.FillableBar(rect5, titheContainer.massUsage, TitheUtilities.TitheBarFillTex, TitheUtilities.TitheBarBGTex, true); Text.Font = GameFont.Small; Widgets.Label(rect5, "MassUsage".Translate()); if (Prefs.DevMode) { Rect debugRect = new Rect(rect5.xMax + 5f, rect5.y, 100f, 20f); if (Widgets.ButtonText(debugRect, "Debug: FillTithes")) { for (int i = 0; i < titheContainer.currentTitheEntries.Count; i++) { TitheEntryGlobal entry = titheContainer.currentTitheEntries[i].Tithe; Thing stuff = ThingMaker.MakeThing(entry.thingDefs.RandomElement()); stuff.stackCount = (int)((1 - entry.tithePercent) * entry.requestedTitheAmount / stuff.def.BaseMarketValue); titheContainer.GetInnerContainer().TryAdd(stuff); } } } Rect rect2 = new Rect(0f, rect5.yMax + 50f, rect.width, 450f).ContractedBy(10f); Rect tithesRect = new Rect(0f, rect2.y, rect.width, 900f); Widgets.BeginScrollView(mainrect, ref this.scrollPosition, rect2); float num = rect2.y + 5f; // Log.Message("tithes enabled" + this.titheContainer.tithesEnabled.Count()); // foreach (KeyValuePair<TitheEntry, bool> current in this.titheContainer.tithesEnabled) for (int i = 0; i < titheContainer.currentTitheEntries.Count; i++) { Rect rect3 = new Rect(30f, num, 200f, 25f); Widgets.CheckboxLabeled(rect3, titheContainer.currentTitheEntries[i].Tithe.titheDef.LabelCap, ref titheContainer.currentTitheEntries[i].active, false); Rect rect4 = new Rect(40f, num + 30f, 200f, 30f); Widgets.FillableBar(rect4, titheEntries[i].tithePercent, TitheUtilities.TitheBarFillTex, TitheUtilities.TitheBarBGTex, true); Widgets.Label(rect4, titheContainer.currentTitheEntries[i].Tithe.collectedTitheAmount + " / " + titheContainer.currentTitheEntries[i].Tithe.requestedTitheAmount); num += 75f; } Widgets.EndScrollView(); Text.Anchor = TextAnchor.UpperLeft; }
public static float DrawTitheRow(float rowY, TitheEntryGlobal entry) { Rect rect2 = new Rect(10f, rowY, 220f, 26f); Widgets.Label(rect2, entry.titheDef.label); Rect rect3 = new Rect(rect2); rect3.y = rect2.yMax + 10f; rect3.height = 30f; rect3.width = 200f; Widgets.FillableBar(rect3, entry.tithePercent, TitheUtilities.TitheBarFillTex, TitheUtilities.TitheBarBGTex, true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect3, entry.collectedTitheAmount.ToString("F0") + " / " + entry.requestedTitheAmount.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; float num = rowY + 60f; return(num); }
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); }
public TitheEntryForContainer(TitheEntryGlobal tithe) { this.Tithe = tithe; }
public TitheEntryForContainer() { this.Tithe = new TitheEntryGlobal(); }