public override float VoluntaryJoinPriorityFor(Pawn p)
 {
     if (IsFiance(p))
     {
         if (!MarriageCeremonyUtility.FianceCanContinueCeremony(p, (p == firstPawn) ? secondPawn : firstPawn))
         {
             return(0f);
         }
         return(VoluntarilyJoinableLordJobJoinPriorities.MarriageCeremonyFiance);
     }
     if (IsGuest(p))
     {
         if (!MarriageCeremonyUtility.ShouldGuestKeepAttendingCeremony(p))
         {
             return(0f);
         }
         if (!lord.ownedPawns.Contains(p))
         {
             if (IsCeremonyAboutToEnd())
             {
                 return(0f);
             }
             LordToil_MarriageCeremony lordToil_MarriageCeremony = lord.CurLordToil as LordToil_MarriageCeremony;
             if (lordToil_MarriageCeremony != null && !SpectatorCellFinder.TryFindSpectatorCellFor(p, lordToil_MarriageCeremony.Data.spectateRect, base.Map, out IntVec3 _, lordToil_MarriageCeremony.Data.spectateRectAllowedSides))
             {
                 return(0f);
             }
         }
         return(VoluntarilyJoinableLordJobJoinPriorities.MarriageCeremonyGuest);
     }
     return(0f);
 }
        protected override Job TryGiveJob(Pawn pawn)
        {
            PawnDuty duty = pawn.mindState.duty;
            Job      result;
            IntVec3  c;

            if (duty == null)
            {
                result = null;
            }
            else if (!SpectatorCellFinder.TryFindSpectatorCellFor(pawn, duty.spectateRect, pawn.Map, out c, duty.spectateRectAllowedSides, 1, null))
            {
                result = null;
            }
            else
            {
                IntVec3  centerCell = duty.spectateRect.CenterCell;
                Building edifice    = c.GetEdifice(pawn.Map);
                if (edifice != null && edifice.def.category == ThingCategory.Building && edifice.def.building.isSittable && pawn.CanReserve(edifice, 1, -1, null, false))
                {
                    result = new Job(JobDefOf.SpectateCeremony, edifice, centerCell);
                }
                else
                {
                    result = new Job(JobDefOf.SpectateCeremony, c, centerCell);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
 public override float VoluntaryJoinPriorityFor(Pawn p)
 {
     if (this.IsFiance(p))
     {
         if (!MarriageCeremonyUtility.FianceCanContinueCeremony(p))
         {
             return(0f);
         }
         return(VoluntarilyJoinableLordJobJoinPriorities.MarriageCeremonyFiance);
     }
     if (this.IsGuest(p))
     {
         if (!MarriageCeremonyUtility.ShouldGuestKeepAttendingCeremony(p))
         {
             return(0f);
         }
         if (!base.lord.ownedPawns.Contains(p))
         {
             if (this.IsCeremonyAboutToEnd())
             {
                 return(0f);
             }
             LordToil_MarriageCeremony lordToil_MarriageCeremony = base.lord.CurLordToil as LordToil_MarriageCeremony;
             IntVec3 intVec = default(IntVec3);
             if (lordToil_MarriageCeremony != null && !SpectatorCellFinder.TryFindSpectatorCellFor(p, lordToil_MarriageCeremony.Data.spectateRect, base.Map, out intVec, lordToil_MarriageCeremony.Data.spectateRectAllowedSides, 1, (List <IntVec3>)null))
             {
                 return(0f);
             }
         }
         return(VoluntarilyJoinableLordJobJoinPriorities.MarriageCeremonyGuest);
     }
     return(0f);
 }
Ejemplo n.º 4
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            PawnDuty duty = pawn.mindState.duty;

            if (duty == null)
            {
                return(null);
            }
            if (!SpectatorCellFinder.TryFindSpectatorCellFor(pawn, duty.spectateRect, pawn.Map, out IntVec3 cell, duty.spectateRectAllowedSides))
            {
                return(null);
            }
            IntVec3  centerCell = duty.spectateRect.CenterCell;
            Building edifice    = cell.GetEdifice(pawn.Map);

            if (edifice != null && edifice.def.category == ThingCategory.Building && edifice.def.building.isSittable && pawn.CanReserve(edifice))
            {
                return(new Job(JobDefOf.SpectateCeremony, edifice, centerCell));
            }
            return(new Job(JobDefOf.SpectateCeremony, cell, centerCell));
        }
Ejemplo n.º 5
0
        public static void DebugFlashPotentialSpectatorCells(CellRect spectateRect, Map map, SpectateRectSide allowedSides = SpectateRectSide.All, int margin = 1)
        {
            List <IntVec3> list = new List <IntVec3>();
            int            num  = 50;

            for (int i = 0; i < num; i++)
            {
                IntVec3 intVec;
                if (!SpectatorCellFinder.TryFindSpectatorCellFor(null, spectateRect, map, out intVec, allowedSides, margin, list))
                {
                    break;
                }
                list.Add(intVec);
                float    a   = Mathf.Lerp(1f, 0.08f, (float)i / (float)num);
                Material mat = SolidColorMaterials.SimpleSolidColorMaterial(new Color(0f, 0.8f, 0f, a), false);
                map.debugDrawer.FlashCell(intVec, mat, (i + 1).ToString(), 50);
            }
            SpectateRectSide spectateRectSide = SpectatorCellFinder.FindSingleBestSide(spectateRect, map, allowedSides, margin);
            IntVec3          centerCell       = spectateRect.CenterCell;

            switch (spectateRectSide)
            {
            case SpectateRectSide.Up:
                centerCell.z += spectateRect.Height / 2 + 10;
                break;

            case SpectateRectSide.Right:
                centerCell.x += spectateRect.Width / 2 + 10;
                break;

            case SpectateRectSide.Down:
                centerCell.z -= spectateRect.Height / 2 + 10;
                break;

            case SpectateRectSide.Left:
                centerCell.x -= spectateRect.Width / 2 + 10;
                break;
            }
            map.debugDrawer.FlashLine(spectateRect.CenterCell, centerCell, 50);
        }
Ejemplo n.º 6
0
        public static SpectateRectSide FindSingleBestSide(CellRect spectateRect, Map map, SpectateRectSide allowedSides = SpectateRectSide.All, int margin = 1)
        {
            for (int i = 0; i < SpectatorCellFinder.scorePerSide.Length; i++)
            {
                SpectatorCellFinder.scorePerSide[i] = 0f;
            }
            SpectatorCellFinder.usedCells.Clear();
            int      num      = 30;
            CellRect cellRect = spectateRect.ExpandedBy(margin).ClipInsideMap(map);

            for (int j = 0; j < num; j++)
            {
                IntVec3 intVec;
                if (!SpectatorCellFinder.TryFindSpectatorCellFor(null, spectateRect, map, out intVec, allowedSides, margin, SpectatorCellFinder.usedCells))
                {
                    break;
                }
                SpectatorCellFinder.usedCells.Add(intVec);
                float    num2 = Mathf.Lerp(1f, 0.35f, (float)j / (float)num);
                float    num3 = num2;
                Building correctlyRotatedChairAt = SpectatorCellFinder.GetCorrectlyRotatedChairAt(intVec, map, spectateRect);
                if (intVec.z > cellRect.maxZ && (allowedSides & SpectateRectSide.Up) == SpectateRectSide.Up)
                {
                    SpectatorCellFinder.scorePerSide[0] += num3;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.South)
                    {
                        SpectatorCellFinder.scorePerSide[0] += 1.2f * num2;
                    }
                }
                if (intVec.x > cellRect.maxX && (allowedSides & SpectateRectSide.Right) == SpectateRectSide.Right)
                {
                    SpectatorCellFinder.scorePerSide[1] += num3;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.West)
                    {
                        SpectatorCellFinder.scorePerSide[1] += 1.2f * num2;
                    }
                }
                if (intVec.z < cellRect.minZ && (allowedSides & SpectateRectSide.Down) == SpectateRectSide.Down)
                {
                    SpectatorCellFinder.scorePerSide[2] += num3;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.North)
                    {
                        SpectatorCellFinder.scorePerSide[2] += 1.2f * num2;
                    }
                }
                if (intVec.x < cellRect.minX && (allowedSides & SpectateRectSide.Left) == SpectateRectSide.Left)
                {
                    SpectatorCellFinder.scorePerSide[3] += num3;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.East)
                    {
                        SpectatorCellFinder.scorePerSide[3] += 1.2f * num2;
                    }
                }
            }
            float num4 = 0f;
            int   num5 = -1;

            for (int k = 0; k < SpectatorCellFinder.scorePerSide.Length; k++)
            {
                if (SpectatorCellFinder.scorePerSide[k] != 0f)
                {
                    if (num5 < 0 || SpectatorCellFinder.scorePerSide[k] > num4)
                    {
                        num5 = k;
                        num4 = SpectatorCellFinder.scorePerSide[k];
                    }
                }
            }
            SpectatorCellFinder.usedCells.Clear();
            switch (num5)
            {
            case 0:
                return(SpectateRectSide.Up);

            case 1:
                return(SpectateRectSide.Right);

            case 2:
                return(SpectateRectSide.Down);

            case 3:
                return(SpectateRectSide.Left);

            default:
                return(SpectateRectSide.None);
            }
        }
        public static SpectateRectSide FindSingleBestSide(CellRect spectateRect, Map map, SpectateRectSide allowedSides = SpectateRectSide.All, int margin = 1)
        {
            for (int i = 0; i < SpectatorCellFinder.scorePerSide.Length; i++)
            {
                SpectatorCellFinder.scorePerSide[i] = 0f;
            }
            SpectatorCellFinder.usedCells.Clear();
            int      num      = 30;
            CellRect cellRect = spectateRect.ExpandedBy(margin).ClipInsideMap(map);
            int      num2     = 0;
            IntVec3  intVec   = default(IntVec3);

            while (num2 < num && SpectatorCellFinder.TryFindSpectatorCellFor((Pawn)null, spectateRect, map, out intVec, allowedSides, margin, SpectatorCellFinder.usedCells))
            {
                SpectatorCellFinder.usedCells.Add(intVec);
                float    num3 = Mathf.Lerp(1f, 0.35f, (float)num2 / (float)num);
                float    num4 = num3;
                Building correctlyRotatedChairAt = SpectatorCellFinder.GetCorrectlyRotatedChairAt(intVec, map, spectateRect);
                if (intVec.z > cellRect.maxZ && (allowedSides & SpectateRectSide.Up) == SpectateRectSide.Up)
                {
                    SpectatorCellFinder.scorePerSide[0] += num4;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.South)
                    {
                        SpectatorCellFinder.scorePerSide[0] += (float)(1.2000000476837158 * num3);
                    }
                }
                if (intVec.x > cellRect.maxX && (allowedSides & SpectateRectSide.Right) == SpectateRectSide.Right)
                {
                    SpectatorCellFinder.scorePerSide[1] += num4;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.West)
                    {
                        SpectatorCellFinder.scorePerSide[1] += (float)(1.2000000476837158 * num3);
                    }
                }
                if (intVec.z < cellRect.minZ && (allowedSides & SpectateRectSide.Down) == SpectateRectSide.Down)
                {
                    SpectatorCellFinder.scorePerSide[2] += num4;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.North)
                    {
                        SpectatorCellFinder.scorePerSide[2] += (float)(1.2000000476837158 * num3);
                    }
                }
                if (intVec.x < cellRect.minX && (allowedSides & SpectateRectSide.Left) == SpectateRectSide.Left)
                {
                    SpectatorCellFinder.scorePerSide[3] += num4;
                    if (correctlyRotatedChairAt != null && correctlyRotatedChairAt.Rotation == Rot4.East)
                    {
                        SpectatorCellFinder.scorePerSide[3] += (float)(1.2000000476837158 * num3);
                    }
                }
                num2++;
            }
            float num5 = 0f;
            int   num6 = -1;

            for (int j = 0; j < SpectatorCellFinder.scorePerSide.Length; j++)
            {
                if (SpectatorCellFinder.scorePerSide[j] != 0.0 && (num6 <0 || SpectatorCellFinder.scorePerSide[j]> num5))
                {
                    num6 = j;
                    num5 = SpectatorCellFinder.scorePerSide[j];
                }
            }
            SpectatorCellFinder.usedCells.Clear();
            switch (num6)
            {
            case 0:
                return(SpectateRectSide.Up);

            case 1:
                return(SpectateRectSide.Right);

            case 2:
                return(SpectateRectSide.Down);

            case 3:
                return(SpectateRectSide.Left);

            default:
                return(SpectateRectSide.None);
            }
        }