diff --git a/RJWSexperience/RJWSexperience/Cum/Building_Cumbucket.cs b/RJWSexperience/RJWSexperience/Cum/Building_Cumbucket.cs index 6057db4..5848277 100644 --- a/RJWSexperience/RJWSexperience/Cum/Building_Cumbucket.cs +++ b/RJWSexperience/RJWSexperience/Cum/Building_Cumbucket.cs @@ -1,23 +1,52 @@ using RimWorld; +using System.Linq; +using System.Text; using Verse; namespace RJWSexperience // Used in Menstruation with this namespace { public class Building_CumBucket : Building_Storage { - protected float storedcum = 0f; - protected float totalgathered = 0f; + protected float storedDecimalRemainder = 0f; + protected float totalGathered = 0f; + + public int StoredStackCount + { + get + { + if (!slotGroup.HeldThings.Any()) + return 0; + return slotGroup.HeldThings.Select(thing => thing.stackCount).Aggregate((sum, x) => sum + x); + } + } public override void ExposeData() { - Scribe_Values.Look(ref storedcum, "storedcum", storedcum, true); - Scribe_Values.Look(ref totalgathered, "totalgathered", totalgathered, true); + Scribe_Values.Look(ref storedDecimalRemainder, "storedcum", 0f); + Scribe_Values.Look(ref totalGathered, "totalgathered", 0f); base.ExposeData(); } public override string GetInspectString() { - return Keyed.RSTotalGatheredCum + string.Format("{0:0.##}ml", totalgathered); + StringBuilder stringBuilder = new StringBuilder(); + + string baseString = base.GetInspectString(); + if (!baseString.NullOrEmpty()) + { + stringBuilder.AppendLine(baseString); + } + + stringBuilder.Append(Keyed.RSTotalGatheredCum).AppendFormat("{0:0.##}ml", totalGathered); + + if (SexperienceMod.Settings.Debug.DevMode) + { + stringBuilder.AppendLine(); + stringBuilder.AppendLine($"[Debug] stored: {StoredStackCount}"); + stringBuilder.Append($"[Debug] storedDecimalRemainder: {storedDecimalRemainder}"); + } + + return stringBuilder.ToString(); } public void AddCum(float amount) @@ -33,16 +62,16 @@ namespace RJWSexperience // Used in Menstruation with this namespace public void AddCum(float amount, Thing cum) { - storedcum += amount; - totalgathered += amount; - int num = (int)storedcum; + storedDecimalRemainder += amount; + totalGathered += amount; + int num = (int)storedDecimalRemainder; cum.stackCount = num; if (cum.stackCount > 0 && !GenPlace.TryPlaceThing(cum, PositionHeld, Map, ThingPlaceMode.Direct, out Thing res)) { FilthMaker.TryMakeFilth(PositionHeld, Map, VariousDefOf.FilthCum, num); } - storedcum -= num; + storedDecimalRemainder -= num; } } } diff --git a/RJWSexperience/RJWSexperience/Cum/WorkGiver_CleanSelfWithBucket.cs b/RJWSexperience/RJWSexperience/Cum/WorkGiver_CleanSelfWithBucket.cs index 82be841..315dc28 100644 --- a/RJWSexperience/RJWSexperience/Cum/WorkGiver_CleanSelfWithBucket.cs +++ b/RJWSexperience/RJWSexperience/Cum/WorkGiver_CleanSelfWithBucket.cs @@ -22,11 +22,7 @@ namespace RJWSexperience.Cum if (!(t is Building_CumBucket bucket)) return false; - List thingsInBucket = bucket.Map.thingGrid.ThingsListAt(bucket.Position); - - int stackInBucket = thingsInBucket.Select(thing => thing.stackCount).Aggregate((sum, x) => sum + x); - - return stackInBucket < VariousDefOf.GatheredCum.stackLimit; + return bucket.StoredStackCount < VariousDefOf.GatheredCum.stackLimit; } public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)