Exemplo n.º 1
0
 private string UsableNowStatus()
 {
     if (!this.AnyCoupleForWhichIsValid())
     {
         StringBuilder     stringBuilder = new StringBuilder();
         Pair <Pawn, Pawn> pair;
         if (this.TryFindAnyFiancesCouple(out pair))
         {
             if (!MarriageSpotUtility.IsValidMarriageSpotFor(base.Position, pair.First, pair.Second, stringBuilder))
             {
                 return("MarriageSpotNotUsable".Translate(new object[]
                 {
                     stringBuilder
                 }));
             }
         }
         else if (!MarriageSpotUtility.IsValidMarriageSpot(base.Position, base.Map, stringBuilder))
         {
             return("MarriageSpotNotUsable".Translate(new object[]
             {
                 stringBuilder
             }));
         }
     }
     return("MarriageSpotUsable".Translate());
 }
 private bool AnyCoupleForWhichIsValid()
 {
     return(base.Map.mapPawns.FreeColonistsSpawned.Any(delegate(Pawn p)
     {
         Pawn firstDirectRelationPawn = p.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Fiance, (Pawn x) => x.Spawned);
         return firstDirectRelationPawn != null && MarriageSpotUtility.IsValidMarriageSpotFor(base.Position, p, firstDirectRelationPawn, null);
     }));
 }
Exemplo n.º 3
0
        public static bool TryFindMarriageSite(Pawn firstFiance, Pawn secondFiance, out IntVec3 result)
        {
            if (!firstFiance.CanReach(secondFiance, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
            {
                result = IntVec3.Invalid;
                return(false);
            }
            Map map = firstFiance.Map;

            if ((from x in map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.MarriageSpot)
                 where MarriageSpotUtility.IsValidMarriageSpotFor(x.Position, firstFiance, secondFiance, null)
                 select x.Position).TryRandomElement <IntVec3>(out result))
            {
                return(true);
            }
            Predicate <IntVec3> noMarriageSpotValidator = delegate(IntVec3 cell)
            {
                IntVec3 c = cell + LordToil_MarriageCeremony.OtherFianceNoMarriageSpotCellOffset;
                if (!c.InBounds(map))
                {
                    return(false);
                }
                if (!c.IsForbidden(firstFiance) && !c.IsForbidden(secondFiance))
                {
                    if (!c.Standable(map))
                    {
                        return(false);
                    }
                    Room room = cell.GetRoom(map, RegionType.Set_Passable);
                    if (room != null && !room.IsHuge && !room.PsychologicallyOutdoors && room.CellCount < 10)
                    {
                        return(false);
                    }
                    return(true);
                }
                return(false);
            };

            foreach (CompGatherSpot item in map.gatherSpotLister.activeSpots.InRandomOrder(null))
            {
                for (int i = 0; i < 10; i++)
                {
                    IntVec3 intVec = CellFinder.RandomClosewalkCellNear(item.parent.Position, item.parent.Map, 4, null);
                    if (MarriageSpotUtility.IsValidMarriageSpotFor(intVec, firstFiance, secondFiance, null) && noMarriageSpotValidator(intVec))
                    {
                        result = intVec;
                        return(true);
                    }
                }
            }
            if (CellFinder.TryFindRandomCellNear(firstFiance.Position, firstFiance.Map, 25, (Predicate <IntVec3>)((IntVec3 cell) => MarriageSpotUtility.IsValidMarriageSpotFor(cell, firstFiance, secondFiance, null) && noMarriageSpotValidator(cell)), out result))
            {
                return(true);
            }
            result = IntVec3.Invalid;
            return(false);
        }
Exemplo n.º 4
0
 private string UsableNowStatus()
 {
     if (!AnyCoupleForWhichIsValid())
     {
         StringBuilder stringBuilder = new StringBuilder();
         if (TryFindAnyFiancesCouple(out var fiances))
         {
             if (!MarriageSpotUtility.IsValidMarriageSpotFor(base.Position, fiances.First, fiances.Second, stringBuilder))
             {
                 return("MarriageSpotNotUsable".Translate(stringBuilder));
             }
         }
         else if (!MarriageSpotUtility.IsValidMarriageSpot(base.Position, base.Map, stringBuilder))
         {
             return("MarriageSpotNotUsable".Translate(stringBuilder));
         }
     }
     return("MarriageSpotUsable".Translate());
 }
Exemplo n.º 5
0
        private bool <AnyCoupleForWhichIsValid> m__0(Pawn p)
        {
            Pawn firstDirectRelationPawn = p.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Fiance, (Pawn x) => x.Spawned);

            return(firstDirectRelationPawn != null && MarriageSpotUtility.IsValidMarriageSpotFor(base.Position, p, firstDirectRelationPawn, null));
        }
Exemplo n.º 6
0
 public static bool IsValidMarriageSpotFor(IntVec3 cell, Pawn firstFiance, Pawn secondFiance, StringBuilder outFailReason = null)
 {
     if (!firstFiance.Spawned || !secondFiance.Spawned)
     {
         Log.Warning("Can't check if a marriage spot is valid because one of the fiances isn't spawned.", false);
         return(false);
     }
     if (firstFiance.Map != secondFiance.Map)
     {
         return(false);
     }
     if (!MarriageSpotUtility.IsValidMarriageSpot(cell, firstFiance.Map, outFailReason))
     {
         return(false);
     }
     if (!cell.Roofed(firstFiance.Map))
     {
         if (!JoyUtility.EnjoyableOutsideNow(firstFiance, outFailReason))
         {
             return(false);
         }
         if (!JoyUtility.EnjoyableOutsideNow(secondFiance, outFailReason))
         {
             return(false);
         }
     }
     if (cell.GetDangerFor(firstFiance, firstFiance.Map) != Danger.None)
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotDangerous".Translate(new object[]
             {
                 firstFiance.LabelShort
             }));
         }
         return(false);
     }
     if (cell.GetDangerFor(secondFiance, secondFiance.Map) != Danger.None)
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotDangerous".Translate(new object[]
             {
                 secondFiance.LabelShort
             }));
         }
         return(false);
     }
     if (cell.IsForbidden(firstFiance))
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotForbidden".Translate(new object[]
             {
                 firstFiance.LabelShort
             }));
         }
         return(false);
     }
     if (cell.IsForbidden(secondFiance))
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotForbidden".Translate(new object[]
             {
                 secondFiance.LabelShort
             }));
         }
         return(false);
     }
     if (!firstFiance.CanReserve(cell, 1, -1, null, false) || !secondFiance.CanReserve(cell, 1, -1, null, false))
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotReserved".Translate());
         }
         return(false);
     }
     if (!firstFiance.CanReach(cell, PathEndMode.OnCell, Danger.None, false, TraverseMode.ByPawn))
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotUnreachable".Translate(new object[]
             {
                 firstFiance.LabelShort
             }));
         }
         return(false);
     }
     if (!secondFiance.CanReach(cell, PathEndMode.OnCell, Danger.None, false, TraverseMode.ByPawn))
     {
         if (outFailReason != null)
         {
             outFailReason.Append("MarriageSpotUnreachable".Translate(new object[]
             {
                 secondFiance.LabelShort
             }));
         }
         return(false);
     }
     if (!firstFiance.IsPrisoner && !secondFiance.IsPrisoner)
     {
         Room room = cell.GetRoom(firstFiance.Map, RegionType.Set_Passable);
         if (room != null && room.isPrisonCell)
         {
             if (outFailReason != null)
             {
                 outFailReason.Append("MarriageSpotInPrisonCell".Translate());
             }
             return(false);
         }
     }
     return(true);
 }