Example #1
0
        public static float ApproxTilesPerDay(List <ThingCount> thingCounts, float massUsage, float massCapacity, int tile, int nextTile, StringBuilder explanation = null)
        {
            TilesPerDayCalculator.tmpPawns.Clear();
            for (int i = 0; i < thingCounts.Count; i++)
            {
                if (thingCounts[i].Count > 0)
                {
                    Pawn pawn = thingCounts[i].Thing as Pawn;
                    if (pawn != null)
                    {
                        TilesPerDayCalculator.tmpPawns.Add(pawn);
                    }
                }
            }
            if (!TilesPerDayCalculator.tmpPawns.Any <Pawn>())
            {
                return(0f);
            }
            StringBuilder stringBuilder = (explanation == null) ? null : new StringBuilder();
            int           ticksPerMove  = CaravanTicksPerMoveUtility.GetTicksPerMove(TilesPerDayCalculator.tmpPawns, massUsage, massCapacity, stringBuilder);
            float         result        = TilesPerDayCalculator.ApproxTilesPerDay(ticksPerMove, tile, nextTile, explanation, (stringBuilder == null) ? null : stringBuilder.ToString());

            TilesPerDayCalculator.tmpPawns.Clear();
            return(result);
        }
Example #2
0
        public static float ApproxTilesPerDayLeftAfterTransfer(List <TransferableOneWay> transferables, float massUsageLeftAfterTransfer, float massCapacityLeftAfterTransfer, int tile, int nextTile, StringBuilder explanation = null)
        {
            TilesPerDayCalculator.tmpPawns.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                TransferableOneWay transferableOneWay = transferables[i];
                if (transferableOneWay.HasAnyThing && transferableOneWay.AnyThing is Pawn)
                {
                    for (int j = transferableOneWay.things.Count - 1; j >= transferableOneWay.CountToTransfer; j--)
                    {
                        TilesPerDayCalculator.tmpPawns.Add((Pawn)transferableOneWay.things[j]);
                    }
                }
            }
            if (!TilesPerDayCalculator.tmpPawns.Any <Pawn>())
            {
                return(0f);
            }
            StringBuilder stringBuilder = (explanation == null) ? null : new StringBuilder();
            int           ticksPerMove  = CaravanTicksPerMoveUtility.GetTicksPerMove(TilesPerDayCalculator.tmpPawns, massUsageLeftAfterTransfer, massCapacityLeftAfterTransfer, stringBuilder);
            float         result        = TilesPerDayCalculator.ApproxTilesPerDay(ticksPerMove, tile, nextTile, explanation, (stringBuilder == null) ? null : stringBuilder.ToString());

            TilesPerDayCalculator.tmpPawns.Clear();
            return(result);
        }
Example #3
0
        public static float ApproxTilesPerDayLeftAfterTradeableTransfer(List <Thing> allCurrentThings, List <Tradeable> tradeables, float massUsageLeftAfterTradeableTransfer, float massCapacityLeftAfterTradeableTransfer, int tile, int nextTile, StringBuilder explanation = null)
        {
            TilesPerDayCalculator.tmpThingCounts.Clear();
            TransferableUtility.SimulateTradeableTransfer(allCurrentThings, tradeables, TilesPerDayCalculator.tmpThingCounts);
            float result = TilesPerDayCalculator.ApproxTilesPerDay(TilesPerDayCalculator.tmpThingCounts, massUsageLeftAfterTradeableTransfer, massCapacityLeftAfterTradeableTransfer, tile, nextTile, explanation);

            TilesPerDayCalculator.tmpThingCounts.Clear();
            return(result);
        }
Example #4
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            if (!this.caravan.Spawned)
            {
                return(new GizmoResult(GizmoState.Clear));
            }
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);

            Widgets.DrawWindowBackground(rect);
            GUI.BeginGroup(rect);
            Rect          rect2         = rect.AtZero();
            int?          ticksToArrive = (!this.caravan.pather.Moving) ? null : new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this.caravan, true));
            StringBuilder stringBuilder = new StringBuilder();
            float         tilesPerDay   = TilesPerDayCalculator.ApproxTilesPerDay(this.caravan, stringBuilder);

            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.caravan.MassUsage, this.caravan.MassCapacity, this.caravan.MassCapacityExplanation, tilesPerDay, stringBuilder.ToString(), this.caravan.DaysWorthOfFood, this.caravan.forage.ForagedFoodPerDay, this.caravan.forage.ForagedFoodPerDayExplanation, this.caravan.Visibility, this.caravan.VisibilityExplanation, -1f, -1f, null), null, this.caravan.Tile, ticksToArrive, -9999f, rect2, true, null, true);
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(rect);
            return(new GizmoResult(GizmoState.Clear));
        }
Example #5
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            if (!caravan.Spawned)
            {
                return(new GizmoResult(GizmoState.Clear));
            }
            Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);

            Widgets.DrawWindowBackground(rect);
            GUI.BeginGroup(rect);
            Rect          rect2         = rect.AtZero();
            int?          ticksToArrive = (caravan.pather.Moving ? new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(caravan, allowCaching: true)) : null);
            StringBuilder stringBuilder = new StringBuilder();

            CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(tilesPerDay: TilesPerDayCalculator.ApproxTilesPerDay(caravan, stringBuilder), massUsage: caravan.MassUsage, massCapacity: caravan.MassCapacity, massCapacityExplanation: caravan.MassCapacityExplanation, tilesPerDayExplanation: stringBuilder.ToString(), daysWorthOfFood: caravan.DaysWorthOfFood, foragedFoodPerDay: caravan.forage.ForagedFoodPerDay, foragedFoodPerDayExplanation: caravan.forage.ForagedFoodPerDayExplanation, visibility: caravan.Visibility, visibilityExplanation: caravan.VisibilityExplanation), null, caravan.Tile, ticksToArrive, -9999f, rect2, lerpMassColor: true, null, multiline: true);
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(rect);
            return(new GizmoResult(GizmoState.Clear));
        }
Example #6
0
 public static float ApproxTilesPerDay(Caravan caravan, StringBuilder explanation = null)
 {
     return(TilesPerDayCalculator.ApproxTilesPerDay(caravan.TicksPerMove, caravan.Tile, (!caravan.pather.Moving) ? -1 : caravan.pather.nextTile, explanation, (explanation == null) ? null : caravan.TicksPerMoveExplanation));
 }