public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (!pawn.IsGuest()) { return; } // Store cache friendsShortCache = pawn.GetFriendsInColony(); friendsRequiredShortCache = GuestUtility.FriendsRequired(pawn.MapHeld) + pawn.GetEnemiesInColony(); base.DoCell(rect, pawn, table); // Use cache - only get comp when we have enough friends if (friendsShortCache >= friendsRequiredShortCache && MayRecruitAtAll(pawn)) { var rect2 = rect; rect2.x -= 4; if (Widgets.ButtonText(rect2, txtRecruit)) { ITab_Pawn_Guest.RecruitDialog(pawn, false); } } else { base.DoCell(rect, pawn, table); } }
private int GetValueToCompare(Pawn pawn) { // Can't use cache here // Changed check if (!pawn.IsGuest()) { return(-2147483648); } friendsShortCache = pawn.GetFriendsInColony(); friendsRequiredShortCache = GuestUtility.FriendsRequired(pawn.MapHeld) + pawn.GetEnemiesInColony(); if (friendsRequiredShortCache == 0) { return(-2147483648); } return((int)(100f * friendsShortCache / friendsRequiredShortCache)); }
private void UpdateCache(Pawn pawn) { var isRoyal = pawn.royalty?.MostSeniorTitle != null; friendsShortCache = isRoyal ? pawn.GetFriendsSeniorityInColony() / 100 : pawn.GetFriendsInColony(); friendsRequiredShortCache = isRoyal ? (GuestUtility.RoyalFriendsSeniorityRequired(pawn) + pawn.GetRoyalEnemiesSeniorityInColony()) / 100 : GuestUtility.FriendsRequired(pawn.MapHeld) + pawn.GetEnemiesInColony(); }