コード例 #1
0
 private static bool IsValidDoctorFor(Pawn doctor, Pawn patient, Caravan caravan)
 {
     return(doctor.RaceProps.Humanlike && caravan.IsOwner(doctor) && (doctor != patient || (doctor.IsColonist && doctor.playerSettings.selfTend)) && !doctor.Downed && !doctor.InMentalState && (doctor.story == null || !doctor.story.WorkTypeIsDisabled(WorkTypeDefOf.Doctor)));
 }
コード例 #2
0
        private static void DoRow(ref float curY, Rect viewRect, Rect scrollOutRect, Vector2 scrollPosition, TransferableImmutable thing, Caravan caravan)
        {
            float num  = scrollPosition.y - 30f;
            float num2 = scrollPosition.y + scrollOutRect.height;

            if (curY > num && curY < num2)
            {
                DoRow(new Rect(0f, curY, viewRect.width, 30f), thing, caravan);
            }
            curY += 30f;
        }
コード例 #3
0
 public CaravanInfo(Caravan caravan)
 {
     pawns        = caravan.PawnsListForReading;
     massUsage    = caravan.MassUsage;
     massCapacity = caravan.MassCapacity;
 }
コード例 #4
0
 public static Pawn RandomOwner(this Caravan caravan)
 {
     return(caravan.PawnsListForReading.Where((Pawn p) => caravan.IsOwner(p)).RandomElement());
 }
コード例 #5
0
 public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, PeaceTalks peaceTalks)
 {
     return(peaceTalks?.Spawned ?? false);
 }
コード例 #6
0
 public static void TryAbandonSpecificCountViaInterface(TransferableImmutable t, Caravan caravan)
 {
     Find.WindowStack.Add(new Dialog_Slider("AbandonSliderText".Translate(t.Label), 1, t.TotalStackCount, delegate(int x)
     {
         int num = x;
         for (int i = 0; i < t.things.Count; i++)
         {
             if (num <= 0)
             {
                 break;
             }
             Thing thing  = t.things[i];
             Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
             if (ownerOf == null)
             {
                 Log.Error("Could not find owner of " + thing);
                 return;
             }
             if (num >= thing.stackCount)
             {
                 num -= thing.stackCount;
                 ownerOf.inventory.innerContainer.Remove(thing);
                 thing.Destroy();
             }
             else
             {
                 thing.SplitOff(num).Destroy();
                 num = 0;
             }
         }
         caravan.RecacheImmobilizedNow();
         caravan.RecacheDaysWorthOfFood();
     }));
 }
コード例 #7
0
        public static bool CarriedByCaravan(this Pawn p)
        {
            Caravan caravan = p.GetCaravan();

            return(caravan != null && caravan.carryTracker.IsCarried(p));
        }
コード例 #8
0
        public static void DoAbandonSpecificCountButton(Rect rowRect, TransferableImmutable t, Caravan caravan)
        {
            Rect rect = new Rect(rowRect.width - 24f, (rowRect.height - 24f) / 2f, 24f, 24f);

            if (Widgets.ButtonImage(rect, AbandonSpecificCountButtonTex))
            {
                CaravanAbandonOrBanishUtility.TryAbandonSpecificCountViaInterface(t, caravan);
            }
            if (Mouse.IsOver(rect))
            {
                TooltipHandler.TipRegion(rect, () => CaravanAbandonOrBanishUtility.GetAbandonOrBanishButtonTooltip(t, abandonSpecificCount: true), Gen.HashCombineInt(t.GetHashCode(), 1163428609));
            }
        }
コード例 #9
0
 public static bool CanReach(this Caravan c, int tile)
 {
     return(Find.WorldReachability.CanReach(c, tile));
 }
コード例 #10
0
 public static float ApproxDaysWorthOfFood(Caravan caravan)
 {
     return(DaysWorthOfFoodCalculator.ApproxDaysWorthOfFood(caravan.PawnsListForReading, null, VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(caravan.Tile), IgnorePawnsInventoryMode.DontIgnore));
 }
コード例 #11
0
ファイル: Site.cs プロジェクト: aihhr1832/RimWorld-Decompile
 private IEnumerable <FloatMenuOption> < GetFloatMenuOptions > __BaseCallProxy1(Caravan caravan)
 {
     return(base.GetFloatMenuOptions(caravan));
 }
コード例 #12
0
 public virtual void PostCaravanFormed(Caravan caravan)
 {
 }
コード例 #13
0
 public virtual IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
 {
     yield break;
 }
コード例 #14
0
 public virtual IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
 {
     yield break;
 }
コード例 #15
0
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, SettlementBase settlement)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions <CaravanArrivalAction_AttackSettlement>(() => CaravanArrivalAction_AttackSettlement.CanAttack(caravan, settlement), () => new CaravanArrivalAction_AttackSettlement(settlement), "AttackSettlement".Translate(settlement.Label), caravan, settlement.Tile, settlement));
 }
コード例 #16
0
 public Caravan_NeedsTracker(Caravan caravan)
 {
     this.caravan = caravan;
 }
コード例 #17
0
        public WorldPath FindPath(int startTile, int destTile, Caravan caravan, Func <float, bool> terminator = null)
        {
            if (startTile < 0)
            {
                Log.Error("Tried to FindPath with invalid start tile " + startTile + ", caravan= " + caravan);
                return(WorldPath.NotFound);
            }
            if (destTile < 0)
            {
                Log.Error("Tried to FindPath with invalid dest tile " + destTile + ", caravan= " + caravan);
                return(WorldPath.NotFound);
            }
            if (caravan != null)
            {
                if (!caravan.CanReach(destTile))
                {
                    return(WorldPath.NotFound);
                }
            }
            else if (!Find.WorldReachability.CanReach(startTile, destTile))
            {
                return(WorldPath.NotFound);
            }
            int        num   = startTile;
            World      world = Find.World;
            WorldGrid  grid  = world.grid;
            List <int> tileIDToNeighbors_offsets = grid.tileIDToNeighbors_offsets;
            List <int> tileIDToNeighbors_values  = grid.tileIDToNeighbors_values;
            Vector3    normalized = grid.GetTileCenter(destTile).normalized;

            float[] movementDifficulty = world.pathGrid.movementDifficulty;
            int     num2 = 0;
            int     num3 = caravan?.TicksPerMove ?? 3300;
            int     num4 = CalculateHeuristicStrength(startTile, destTile);

            statusOpenValue   += 2;
            statusClosedValue += 2;
            if (statusClosedValue >= 65435)
            {
                ResetStatuses();
            }
            calcGrid[num].knownCost     = 0;
            calcGrid[num].heuristicCost = 0;
            calcGrid[num].costNodeCost  = 0;
            calcGrid[num].parentTile    = startTile;
            calcGrid[num].status        = statusOpenValue;
            openList.Clear();
            openList.Push(new CostNode(num, 0));
            while (true)
            {
                if (openList.Count <= 0)
                {
                    Log.Warning(string.Concat(caravan, " pathing from ", startTile, " to ", destTile, " ran out of tiles to process."));
                    return(WorldPath.NotFound);
                }
                CostNode costNode = openList.Pop();
                if (costNode.cost != calcGrid[costNode.tile].costNodeCost)
                {
                    continue;
                }
                num = costNode.tile;
                if (calcGrid[num].status == statusClosedValue)
                {
                    continue;
                }
                if (num == destTile)
                {
                    return(FinalizedPath(num));
                }
                if (num2 > 500000)
                {
                    Log.Warning(string.Concat(caravan, " pathing from ", startTile, " to ", destTile, " hit search limit of ", 500000, " tiles."));
                    return(WorldPath.NotFound);
                }
                int num5 = ((num + 1 < tileIDToNeighbors_offsets.Count) ? tileIDToNeighbors_offsets[num + 1] : tileIDToNeighbors_values.Count);
                for (int i = tileIDToNeighbors_offsets[num]; i < num5; i++)
                {
                    int num6 = tileIDToNeighbors_values[i];
                    if (calcGrid[num6].status == statusClosedValue || world.Impassable(num6))
                    {
                        continue;
                    }
                    int    num7   = (int)((float)num3 * movementDifficulty[num6] * grid.GetRoadMovementDifficultyMultiplier(num, num6)) + calcGrid[num].knownCost;
                    ushort status = calcGrid[num6].status;
                    if ((status != statusClosedValue && status != statusOpenValue) || calcGrid[num6].knownCost > num7)
                    {
                        Vector3 tileCenter = grid.GetTileCenter(num6);
                        if (status != statusClosedValue && status != statusOpenValue)
                        {
                            float num8 = grid.ApproxDistanceInTiles(GenMath.SphericalDistance(tileCenter.normalized, normalized));
                            calcGrid[num6].heuristicCost = Mathf.RoundToInt((float)num3 * num8 * (float)num4 * 0.5f);
                        }
                        int num9 = num7 + calcGrid[num6].heuristicCost;
                        calcGrid[num6].parentTile   = num;
                        calcGrid[num6].knownCost    = num7;
                        calcGrid[num6].status       = statusOpenValue;
                        calcGrid[num6].costNodeCost = num9;
                        openList.Push(new CostNode(num6, num9));
                    }
                }
                num2++;
                calcGrid[num].status = statusClosedValue;
                if (terminator != null && terminator(calcGrid[num].costNodeCost))
                {
                    break;
                }
            }
            return(WorldPath.NotFound);
        }
コード例 #18
0
        private static void GetCaravansStandingAtOrAboutToStandAt(int tile, out int caravansCount, out int caravansWithLowerIdCount, Caravan forCaravan)
        {
            caravansCount            = 0;
            caravansWithLowerIdCount = 0;
            List <Caravan> caravans = Find.WorldObjects.Caravans;

            for (int i = 0; i < caravans.Count; i++)
            {
                Caravan caravan = caravans[i];
                if (caravan.Tile != tile)
                {
                    if (caravan.pather.Moving && caravan.pather.nextTile == caravan.pather.Destination && caravan.pather.Destination == tile)
                    {
                        goto IL_0087;
                    }
                }
                else if (!caravan.pather.Moving)
                {
                    goto IL_0087;
                }
                continue;
IL_0087:
                caravansCount++;
                if (caravan.ID < forCaravan.ID)
                {
                    caravansWithLowerIdCount++;
                }
            }
        }
コード例 #19
0
 public Caravan_TraderTracker(Caravan caravan)
 {
     this.caravan = caravan;
 }
コード例 #20
0
 public Caravan_PathFollower(Caravan caravan)
 {
     this.caravan = caravan;
 }
コード例 #21
0
 public static Pawn RandomOwner(this Caravan caravan)
 {
     return((from p in caravan.PawnsListForReading
             where caravan.IsOwner(p)
             select p).RandomElement());
 }
コード例 #22
0
 public static int CostToMove(Caravan caravan, int start, int end, int?ticksAbs = null)
 {
     return(Caravan_PathFollower.CostToMove(caravan.TicksPerMove, start, end, ticksAbs, false, null, null));
 }
コード例 #23
0
 public override void Arrived(Caravan caravan)
 {
     peaceTalks.Notify_CaravanArrived(caravan);
 }
コード例 #24
0
 public static float ApproxTilesPerDay(Caravan caravan, StringBuilder explanation = null)
 {
     return(ApproxTilesPerDay(caravan.TicksPerMove, caravan.Tile, caravan.pather.Moving ? caravan.pather.nextTile : (-1), explanation, (explanation != null) ? caravan.TicksPerMoveExplanation : null));
 }
コード例 #25
0
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, PeaceTalks peaceTalks)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(() => CanVisit(caravan, peaceTalks), () => new CaravanArrivalAction_VisitPeaceTalks(peaceTalks), "VisitPeaceTalks".Translate(peaceTalks.Label), caravan, peaceTalks.Tile, peaceTalks));
 }
コード例 #26
0
 public Caravan_Tweener(Caravan caravan)
 {
     this.caravan = caravan;
 }
コード例 #27
0
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, MapParent mapParent)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(() => CanEnter(caravan, mapParent), () => new CaravanArrivalAction_Enter(mapParent), "EnterMap".Translate(mapParent.Label), caravan, mapParent.Tile, mapParent));
 }
コード例 #28
0
 public override void Arrived(Caravan caravan)
 {
     SettlementUtility.Attack(caravan, this.settlement);
 }
コード例 #29
0
        public WorldPath FindPath(int startTile, int destTile, Caravan caravan, Func <float, bool> terminator = null)
        {
            if (startTile < 0)
            {
                Log.Error("Tried to FindPath with invalid start tile " + startTile + ", caravan= " + caravan);
                return(WorldPath.NotFound);
            }
            if (destTile < 0)
            {
                Log.Error("Tried to FindPath with invalid dest tile " + destTile + ", caravan= " + caravan);
                return(WorldPath.NotFound);
            }
            if (caravan != null)
            {
                if (!caravan.CanReach(destTile))
                {
                    return(WorldPath.NotFound);
                }
            }
            else if (!Find.WorldReachability.CanReach(startTile, destTile))
            {
                return(WorldPath.NotFound);
            }
            World      world = Find.World;
            WorldGrid  grid  = world.grid;
            List <int> tileIDToNeighbors_offsets = grid.tileIDToNeighbors_offsets;
            List <int> tileIDToNeighbors_values  = grid.tileIDToNeighbors_values;
            Vector3    normalized = grid.GetTileCenter(destTile).normalized;

            int[] pathGrid = world.pathGrid.pathGrid;
            int   num      = 0;
            int   num2     = (caravan == null) ? 2500 : caravan.TicksPerMove;
            int   num3     = this.CalculateHeuristicStrength(startTile, destTile);

            this.statusOpenValue   += 2;
            this.statusClosedValue += 2;
            if (this.statusClosedValue >= 65435)
            {
                this.ResetStatuses();
            }
            this.calcGrid[startTile].knownCost     = 0;
            this.calcGrid[startTile].heuristicCost = 0;
            this.calcGrid[startTile].costNodeCost  = 0;
            this.calcGrid[startTile].parentTile    = startTile;
            this.calcGrid[startTile].status        = this.statusOpenValue;
            this.openList.Clear();
            this.openList.Push(new CostNode(startTile, 0));
            while (true)
            {
                if (this.openList.Count <= 0)
                {
                    Log.Warning(caravan + " pathing from " + startTile + " to " + destTile + " ran out of tiles to process.");
                    return(WorldPath.NotFound);
                }
                CostNode costNode = this.openList.Pop();
                if (costNode.cost == this.calcGrid[costNode.tile].costNodeCost)
                {
                    int tile = costNode.tile;
                    if (this.calcGrid[tile].status != this.statusClosedValue)
                    {
                        if (DebugViewSettings.drawPaths)
                        {
                            Find.WorldDebugDrawer.FlashTile(tile, (float)((float)this.calcGrid[tile].knownCost / 375000.0), this.calcGrid[tile].knownCost.ToString(), 50);
                        }
                        if (tile == destTile)
                        {
                            return(this.FinalizedPath(tile));
                        }
                        if (num > 500000)
                        {
                            Log.Warning(caravan + " pathing from " + startTile + " to " + destTile + " hit search limit of " + 500000 + " tiles.");
                            return(WorldPath.NotFound);
                        }
                        int num4 = (tile + 1 >= tileIDToNeighbors_offsets.Count) ? tileIDToNeighbors_values.Count : tileIDToNeighbors_offsets[tile + 1];
                        for (int i = tileIDToNeighbors_offsets[tile]; i < num4; i++)
                        {
                            int    num5 = tileIDToNeighbors_values[i];
                            int    num7;
                            ushort status;
                            if (this.calcGrid[num5].status != this.statusClosedValue && !world.Impassable(num5))
                            {
                                int num6 = num2;
                                num6  += pathGrid[num5];
                                num6   = (int)((float)num6 * grid.GetRoadMovementMultiplierFast(tile, num5));
                                num7   = num6 + this.calcGrid[tile].knownCost;
                                status = this.calcGrid[num5].status;
                                if (status != this.statusClosedValue && status != this.statusOpenValue)
                                {
                                    goto IL_041e;
                                }
                                if (this.calcGrid[num5].knownCost > num7)
                                {
                                    goto IL_041e;
                                }
                            }
                            continue;
IL_041e:
                            Vector3 tileCenter = grid.GetTileCenter(num5);
                            if (status != this.statusClosedValue && status != this.statusOpenValue)
                            {
                                float num8 = grid.ApproxDistanceInTiles(GenMath.SphericalDistance(tileCenter.normalized, normalized));
                                this.calcGrid[num5].heuristicCost = Mathf.RoundToInt((float)((float)num2 * num8 * (float)num3 * 0.5));
                            }
                            int num9 = num7 + this.calcGrid[num5].heuristicCost;
                            this.calcGrid[num5].parentTile   = tile;
                            this.calcGrid[num5].knownCost    = num7;
                            this.calcGrid[num5].status       = this.statusOpenValue;
                            this.calcGrid[num5].costNodeCost = num9;
                            this.openList.Push(new CostNode(num5, num9));
                        }
                        num++;
                        this.calcGrid[tile].status = this.statusClosedValue;
                        if (terminator != null && terminator((float)this.calcGrid[tile].costNodeCost))
                        {
                            break;
                        }
                    }
                }
            }
            return(WorldPath.NotFound);
        }
コード例 #30
0
        private static void DoRow(ref float curY, Rect viewRect, Rect scrollOutRect, Vector2 scrollPosition, Pawn pawn, Caravan caravan, ref Pawn specificNeedsTabForPawn, bool doNeeds)
        {
            float num  = scrollPosition.y - 50f;
            float num2 = scrollPosition.y + scrollOutRect.height;

            if (curY > num && curY < num2)
            {
                DoRow(new Rect(0f, curY, viewRect.width, 50f), pawn, caravan, ref specificNeedsTabForPawn, doNeeds);
            }
            curY += 50f;
        }