private void TryDrawMassInfo(ref float curY, float width) { if (!this.SelPawnForGear.Dead) { Rect rect = new Rect(0f, curY, width, 22f); float num = MassUtility.GearAndInventoryMass(this.SelPawnForGear); float num2 = MassUtility.Capacity(this.SelPawnForGear); Widgets.Label(rect, "MassCarried".Translate(num.ToString("0.##"), num2.ToString("0.##"))); curY += 22f; } }
public static float Capacity(List <ThingCount> thingCounts, StringBuilder explanation = null) { float num = 0f; for (int i = 0; i < thingCounts.Count; i++) { if (thingCounts[i].Count > 0) { Pawn pawn = thingCounts[i].Thing as Pawn; if (pawn != null) { num += MassUtility.Capacity(pawn, explanation) * (float)thingCounts[i].Count; } } } return(Mathf.Max(num, 0f)); }
private void TryDrawMassInfo(ref float curY, float width) { if (this.SelPawnForGear.Dead || !this.ShouldShowInventory(this.SelPawnForGear)) { return; } Rect rect = new Rect(0f, curY, width, 22f); float num = MassUtility.GearAndInventoryMass(this.SelPawnForGear); float num2 = MassUtility.Capacity(this.SelPawnForGear, null); Widgets.Label(rect, "MassCarried".Translate(new object[] { num.ToString("0.##"), num2.ToString("0.##") })); curY += 22f; }
public static float Capacity(List <ThingStackPart> stackParts) { float num = 0f; for (int i = 0; i < stackParts.Count; i++) { if (stackParts[i].Count > 0) { Pawn pawn = stackParts[i].Thing as Pawn; if (pawn != null) { num += MassUtility.Capacity(pawn) * (float)stackParts[i].Count; } } } return(Mathf.Max(num, 0f)); }
private void TryDrawMassInfo(ref float curY, float width) { if (!SelPawnForGear.Dead && ShouldShowInventory(SelPawnForGear)) { Rect rect = new Rect(0f, curY, width, 22f); float num = MassUtility.GearAndInventoryMass(SelPawnForGear); Widgets.Label(rect, TranslatorFormattedStringExtensions.Translate(arg2: MassUtility.Capacity(SelPawnForGear).ToString("0.##"), key: "MassCarried", arg1: num.ToString("0.##"))); curY += 22f; } }
private void DrawMass(Rect rect, TransferableOneWay trad, float availableMass) { if (!trad.HasAnyThing) { return; } Thing anyThing = trad.AnyThing; Pawn pawn = anyThing as Pawn; if (pawn != null && !this.includePawnsMassInMassUsage && !MassUtility.CanEverCarryAnything(pawn)) { return; } Widgets.DrawHighlightIfMouseover(rect); if (pawn == null || this.includePawnsMassInMassUsage) { float mass = this.GetMass(anyThing); if (pawn != null) { float gearMass = 0f; float invMass = 0f; gearMass = MassUtility.GearMass(pawn); if (!InventoryCalculatorsUtility.ShouldIgnoreInventoryOf(pawn, this.ignorePawnInventoryMass)) { invMass = MassUtility.InventoryMass(pawn); } TooltipHandler.TipRegion(rect, () => this.GetPawnMassTip(trad, 0f, mass - gearMass - invMass, gearMass, invMass), trad.GetHashCode() * 59); } else { TooltipHandler.TipRegion(rect, "ItemWeightTip".Translate()); } if (mass > availableMass) { GUI.color = Color.red; } else { GUI.color = TransferableOneWayWidget.ItemMassColor; } Widgets.Label(rect, mass.ToStringMass()); } else { float cap = MassUtility.Capacity(pawn, null); float gearMass = MassUtility.GearMass(pawn); float invMass = (!InventoryCalculatorsUtility.ShouldIgnoreInventoryOf(pawn, this.ignorePawnInventoryMass)) ? MassUtility.InventoryMass(pawn) : 0f; float num = cap - gearMass - invMass; if (num > 0f) { GUI.color = Color.green; } else if (num < 0f) { GUI.color = Color.red; } else { GUI.color = Color.gray; } Widgets.Label(rect, num.ToStringMassOffset()); TooltipHandler.TipRegion(rect, () => this.GetPawnMassTip(trad, cap, 0f, gearMass, invMass), trad.GetHashCode() * 59); } GUI.color = Color.white; }
public static float FreeSpace(Pawn pawn) { return(Mathf.Max(MassUtility.Capacity(pawn, null) - MassUtility.GearAndInventoryMass(pawn), 0f)); }
public static float UnboundedEncumbrancePercent(Pawn pawn) { return(MassUtility.GearAndInventoryMass(pawn) / MassUtility.Capacity(pawn, null)); }