/// <summary> /// This should be called periodically so that HoldTracker can remove items that are no longer in the inventory via a method which isn't being watched. /// </summary> /// <param name="pawn">The pawn who's tracker should be checked.</param> public static void HoldTrackerCleanUp(this Pawn pawn) { if (_tickLastPurge <= GenTicks.TicksAbs) { LoadoutManager.PurgeHoldTrackerRolls(); _tickLastPurge = GenTicks.TicksAbs + GenDate.TicksPerDay; } List <HoldRecord> recs = LoadoutManager.GetHoldRecords(pawn); CompInventory inventory = pawn.TryGetComp <CompInventory>(); if (recs == null || inventory == null) { return; } for (int i = recs.Count - 1; i > 0; i--) { if (recs[i].pickedUp && inventory.container.TotalStackCountOfDef(recs[i].thingDef) <= 0) { recs.RemoveAt(i); } } }