Ejemplo n.º 1
0
 public virtual void Notify_MemberDied(Pawn member)
 {
     if (!base.Spawned)
     {
         Log.Error("Caravan member died in an unspawned caravan. Unspawned caravans shouldn't be kept for more than a single frame.");
     }
     if (!PawnsListForReading.Any((Pawn x) => x != member && IsOwner(x)))
     {
         RemovePawn(member);
         if (base.Faction == Faction.OfPlayer)
         {
             Find.LetterStack.ReceiveLetter("LetterLabelAllCaravanColonistsDied".Translate(), "LetterAllCaravanColonistsDied".Translate(Name).CapitalizeFirst(), LetterDefOf.NegativeEvent, new GlobalTargetInfo(base.Tile));
         }
         pawns.Clear();
         Destroy();
     }
     else
     {
         member.Strip();
         RemovePawn(member);
     }
 }
Ejemplo n.º 2
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (Find.WorldSelector.SingleSelectedObject == this)
            {
                yield return((Gizmo) new Gizmo_CaravanInfo(this));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo g2 = enumerator.Current;
                    yield return(g2);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (IsPlayerControlled)
            {
                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    yield return((Gizmo)SettleInEmptyTileUtility.SettleCommand(this));

                    /*Error: Unable to find new state assignment for yield return*/;
                }
                if (Find.WorldSelector.SingleSelectedObject == this && PawnsListForReading.Count((Pawn x) => x.IsColonist) >= 2)
                {
                    yield return((Gizmo) new Command_Action
                    {
                        defaultLabel = "CommandSplitCaravan".Translate(),
                        defaultDesc = "CommandSplitCaravanDesc".Translate(),
                        icon = SplitCommand,
                        action = delegate
                        {
                            Find.WindowStack.Add(new Dialog_SplitCaravan(((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_01ff: stateMachine*/)._0024this));
                        }
                    });

                    /*Error: Unable to find new state assignment for yield return*/;
                }
                if (pather.Moving)
                {
                    yield return((Gizmo) new Command_Toggle
                    {
                        hotKey = KeyBindingDefOf.Misc1,
                        isActive = (() => ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0266: stateMachine*/)._0024this.pather.Paused),
                        toggleAction = delegate
                        {
                            if (((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_027d: stateMachine*/)._0024this.pather.Moving)
                            {
                                ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_027d: stateMachine*/)._0024this.pather.Paused = !((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_027d: stateMachine*/)._0024this.pather.Paused;
                            }
                        },
                        defaultDesc = "CommandToggleCaravanPauseDesc".Translate(2f.ToString("0.#"), 0.3f.ToStringPercent()),
                        icon = TexCommand.PauseCaravan,
                        defaultLabel = "CommandPauseCaravan".Translate()
                    });

                    /*Error: Unable to find new state assignment for yield return*/;
                }
                if (CaravanMergeUtility.ShouldShowMergeCommand)
                {
                    yield return((Gizmo)CaravanMergeUtility.MergeCommand(this));

                    /*Error: Unable to find new state assignment for yield return*/;
                }
                using (IEnumerator <Gizmo> enumerator2 = forage.GetGizmos().GetEnumerator())
                {
                    if (enumerator2.MoveNext())
                    {
                        Gizmo g = enumerator2.Current;
                        yield return(g);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
                foreach (WorldObject item in Find.WorldObjects.ObjectsAt(base.Tile))
                {
                    using (IEnumerator <Gizmo> enumerator4 = item.GetCaravanGizmos(this).GetEnumerator())
                    {
                        if (enumerator4.MoveNext())
                        {
                            Gizmo gizmo = enumerator4.Current;
                            yield return(gizmo);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            if (Prefs.DevMode)
            {
                yield return((Gizmo) new Command_Action
                {
                    defaultLabel = "Dev: Mental break",
                    action = delegate
                    {
                        if ((from x in ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0502: stateMachine*/)._0024this.PawnsListForReading
                             where x.RaceProps.Humanlike && !x.InMentalState
                             select x).TryRandomElement(out Pawn result))
                        {
                            result.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Wander_Sad);
                        }
                    }
                });
Ejemplo n.º 3
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (Find.WorldSelector.SingleSelectedObject == this)
            {
                yield return(new Gizmo_CaravanInfo(this));
            }
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            if (IsPlayerControlled)
            {
                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    yield return(SettleInEmptyTileUtility.SettleCommand(this));
                }
                if (Find.WorldSelector.SingleSelectedObject == this && PawnsListForReading.Count((Pawn x) => x.IsColonist) >= 2)
                {
                    Command_Action command_Action = new Command_Action();
                    command_Action.defaultLabel = "CommandSplitCaravan".Translate();
                    command_Action.defaultDesc  = "CommandSplitCaravanDesc".Translate();
                    command_Action.icon         = SplitCommand;
                    command_Action.hotKey       = KeyBindingDefOf.Misc5;
                    command_Action.action       = delegate
                    {
                        Find.WindowStack.Add(new Dialog_SplitCaravan(this));
                    };
                    yield return(command_Action);
                }
                if (pather.Moving)
                {
                    Command_Toggle command_Toggle = new Command_Toggle();
                    command_Toggle.hotKey       = KeyBindingDefOf.Misc1;
                    command_Toggle.isActive     = (() => pather.Paused);
                    command_Toggle.toggleAction = delegate
                    {
                        if (pather.Moving)
                        {
                            pather.Paused = !pather.Paused;
                        }
                    };
                    command_Toggle.defaultDesc  = "CommandToggleCaravanPauseDesc".Translate(2f.ToString("0.#"), 0.3f.ToStringPercent());
                    command_Toggle.icon         = TexCommand.PauseCaravan;
                    command_Toggle.defaultLabel = "CommandPauseCaravan".Translate();
                    yield return(command_Toggle);
                }
                if (CaravanMergeUtility.ShouldShowMergeCommand)
                {
                    yield return(CaravanMergeUtility.MergeCommand(this));
                }
                foreach (Gizmo gizmo2 in forage.GetGizmos())
                {
                    yield return(gizmo2);
                }
                foreach (WorldObject item in Find.WorldObjects.ObjectsAt(base.Tile))
                {
                    foreach (Gizmo caravanGizmo in item.GetCaravanGizmos(this))
                    {
                        yield return(caravanGizmo);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                Command_Action command_Action2 = new Command_Action();
                command_Action2.defaultLabel = "Dev: Mental break";
                command_Action2.action       = delegate
                {
                    if (PawnsListForReading.Where((Pawn x) => x.RaceProps.Humanlike && !x.InMentalState).TryRandomElement(out Pawn result6))
                    {
                        result6.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Wander_Sad);
                    }
                };
                yield return(command_Action2);

                Command_Action command_Action3 = new Command_Action();
                command_Action3.defaultLabel = "Dev: Make random pawn hungry";
                command_Action3.action       = delegate
                {
                    if (PawnsListForReading.Where((Pawn x) => x.needs.food != null).TryRandomElement(out Pawn result5))
                    {
                        result5.needs.food.CurLevelPercentage = 0f;
                    }
                };
                yield return(command_Action3);

                Command_Action command_Action4 = new Command_Action();
                command_Action4.defaultLabel = "Dev: Kill random pawn";
                command_Action4.action       = delegate
                {
                    if (PawnsListForReading.TryRandomElement(out Pawn result4))
                    {
                        result4.Kill(null, null);
                        Messages.Message("Dev: Killed " + result4.LabelShort, this, MessageTypeDefOf.TaskCompletion, historical: false);
                    }
                };
                yield return(command_Action4);

                Command_Action command_Action5 = new Command_Action();
                command_Action5.defaultLabel = "Dev: Harm random pawn";
                command_Action5.action       = delegate
                {
                    if (PawnsListForReading.TryRandomElement(out Pawn result3))
                    {
                        DamageInfo dinfo = new DamageInfo(DamageDefOf.Scratch, 10f, 999f);
                        result3.TakeDamage(dinfo);
                    }
                };
                yield return(command_Action5);

                Command_Action command_Action6 = new Command_Action();
                command_Action6.defaultLabel = "Dev: Down random pawn";
                command_Action6.action       = delegate
                {
                    if (PawnsListForReading.Where((Pawn x) => !x.Downed).TryRandomElement(out Pawn result2))
                    {
                        HealthUtility.DamageUntilDowned(result2);
                        Messages.Message("Dev: Downed " + result2.LabelShort, this, MessageTypeDefOf.TaskCompletion, historical: false);
                    }
                };
                yield return(command_Action6);

                Command_Action command_Action7 = new Command_Action();
                command_Action7.defaultLabel = "Dev: Plague on random pawn";
                command_Action7.action       = delegate
                {
                    if (PawnsListForReading.Where((Pawn x) => !x.Downed).TryRandomElement(out Pawn result))
                    {
                        Hediff hediff = HediffMaker.MakeHediff(HediffDefOf.Plague, result);
                        hediff.Severity = HediffDefOf.Plague.stages[1].minSeverity - 0.001f;
                        result.health.AddHediff(hediff);
                        Messages.Message("Dev: Gave advanced plague to " + result.LabelShort, this, MessageTypeDefOf.TaskCompletion, historical: false);
                    }
                };
                yield return(command_Action7);

                Command_Action command_Action8 = new Command_Action();
                command_Action8.defaultLabel = "Dev: Teleport to destination";
                command_Action8.action       = delegate
                {
                    base.Tile = pather.Destination;
                    pather.StopDead();
                };
                yield return(command_Action8);
            }
        }
Ejemplo n.º 4
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (Find.WorldSelector.SingleSelectedObject == this)
            {
                yield return(new Gizmo_CaravanInfo(this));
            }
            foreach (Gizmo gizmo in base.GetGizmos().Where(g => g is Command_Action && (g as Command_Action).defaultLabel != "Dev: Mental break" &&
                                                           (g as Command_Action).defaultLabel != "Dev: Make random pawn hungry" && (g as Command_Action).defaultLabel != "Dev: Kill random pawn" &&
                                                           (g as Command_Action).defaultLabel != "Dev: Harm random pawn" && (g as Command_Action).defaultLabel != "Dev: Down random pawn" &&
                                                           (g as Command_Action).defaultLabel != "Dev: Plague on random pawn" && (g as Command_Action).defaultLabel != "Dev: Teleport to destination"))
            {
                yield return(gizmo);
            }

            if (IsPlayerControlled)
            {
                if (vPather.Moving)
                {
                    yield return(new Command_Toggle
                    {
                        hotKey = KeyBindingDefOf.Misc1,
                        isActive = (() => vPather.Paused),
                        toggleAction = delegate()
                        {
                            if (!vPather.Moving)
                            {
                                return;
                            }
                            vPather.Paused = !vPather.Paused;
                        },
                        defaultDesc = "CommandToggleCaravanPauseDesc".Translate(2f.ToString("0.#"), 0.3f.ToStringPercent()),
                        icon = TexCommand.PauseCaravan,
                        defaultLabel = "CommandPauseCaravan".Translate()
                    });
                }
                if (CaravanMergeUtility.ShouldShowMergeCommand)
                {
                    yield return(CaravanMergeUtility.MergeCommand(this));
                }
                foreach (Gizmo gizmo2 in this.forage.GetGizmos())
                {
                    yield return(gizmo2);
                }

                foreach (WorldObject worldObject in Find.WorldObjects.ObjectsAt(base.Tile))
                {
                    foreach (Gizmo gizmo3 in worldObject.GetCaravanGizmos(this))
                    {
                        yield return(gizmo3);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Vehicle Dev: Teleport to destination",
                    action = delegate()
                    {
                        Tile = vPather.Destination;
                        vPather.StopDead();
                    }
                });
            }
            if (this.HasBoat() && (Find.World.CoastDirectionAt(Tile).IsValid || WorldHelper.RiverIsValid(Tile, PawnsListForReading.Where(p => p.IsBoat()).ToList())))
            {
                if (!vPather.Moving && !PawnsListForReading.NotNullAndAny(p => !p.IsBoat()))
                {
                    Command_Action dock = new Command_Action();
                    dock.icon         = VehicleTex.Anchor;
                    dock.defaultLabel = Find.WorldObjects.AnySettlementBaseAt(Tile) ? "CommandDockShip".Translate() : "CommandDockShipDisembark".Translate();
                    dock.defaultDesc  = Find.WorldObjects.AnySettlementBaseAt(Tile) ? "CommandDockShipDesc".Translate(Find.WorldObjects.SettlementBaseAt(Tile)) : "CommandDockShipObjectDesc".Translate();
                    dock.action       = delegate()
                    {
                        List <WorldObject> objects = Find.WorldObjects.ObjectsAt(Tile).ToList();
                        if (!objects.All(x => x is Caravan))
                        {
                            CaravanHelper.ToggleDocking(this, true);
                        }
                        else
                        {
                            CaravanHelper.SpawnDockedBoatObject(this);
                        }
                    };

                    yield return(dock);
                }
                else if (!vPather.Moving && PawnsListForReading.NotNullAndAny(p => !p.IsBoat()))
                {
                    Command_Action undock = new Command_Action
                    {
                        icon         = VehicleTex.UnloadAll,
                        defaultLabel = "CommandUndockShip".Translate(),
                        defaultDesc  = "CommandUndockShipDesc".Translate(Label),
                        action       = delegate()
                        {
                            CaravanHelper.ToggleDocking(this, false);
                        }
                    };

                    yield return(undock);
                }
            }
        }