Esempio n. 1
0
        public static Building_Throne FindBestUsableThrone(Pawn pawn)
        {
            Building_Throne building_Throne = pawn.ownership.AssignedThrone;

            if (building_Throne != null)
            {
                if (!building_Throne.Spawned || building_Throne.IsForbidden(pawn) || !pawn.CanReserveAndReach(building_Throne, PathEndMode.InteractionCell, pawn.NormalMaxDanger()))
                {
                    return(null);
                }
                if (RoomRoleWorker_ThroneRoom.Validate(building_Throne.GetRoom()) != null)
                {
                    return(null);
                }
            }
            else
            {
                building_Throne = FindBestUnassignedThrone(pawn);
                if (building_Throne == null)
                {
                    return(null);
                }
                pawn.ownership.ClaimThrone(building_Throne);
            }
            return(building_Throne);
        }
Esempio n. 2
0
        public static Building_Throne FindBestUnassignedThrone(Pawn pawn)
        {
            float           num    = float.PositiveInfinity;
            Building_Throne result = null;

            foreach (Thing item in pawn.Map.listerThings.ThingsOfDef(ThingDefOf.Throne))
            {
                Building_Throne building_Throne = item as Building_Throne;
                if (building_Throne != null && building_Throne.CompAssignableToPawn.HasFreeSlot && building_Throne.Spawned && !building_Throne.IsForbidden(pawn) && pawn.CanReserveAndReach(building_Throne, PathEndMode.InteractionCell, pawn.NormalMaxDanger()) && RoomRoleWorker_ThroneRoom.Validate(building_Throne.GetRoom()) == null)
                {
                    PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, building_Throne, pawn, PathEndMode.InteractionCell);
                    float    num2     = (pawnPath.Found ? pawnPath.TotalCost : float.PositiveInfinity);
                    pawnPath.ReleaseToPool();
                    if (num > num2)
                    {
                        num    = num2;
                        result = building_Throne;
                    }
                }
            }
            if (num == float.PositiveInfinity)
            {
                return(null);
            }
            return(result);
        }