public static Command SettleCommand(Caravan caravan)
        {
            Command_Settle command_Settle = new Command_Settle();

            command_Settle.defaultLabel = "CommandSettle".Translate();
            command_Settle.defaultDesc  = "CommandSettleDesc".Translate();
            command_Settle.icon         = SettleUtility.SettleCommandTex;
            command_Settle.action       = delegate
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                SettlementProximityGoodwillUtility.CheckConfirmSettle(caravan.Tile, delegate
                {
                    SettleInEmptyTileUtility.Settle(caravan);
                });
            };
            SettleInEmptyTileUtility.tmpSettleFailReason.Length = 0;
            if (!TileFinder.IsValidTileForNewSettlement(caravan.Tile, SettleInEmptyTileUtility.tmpSettleFailReason))
            {
                command_Settle.Disable(SettleInEmptyTileUtility.tmpSettleFailReason.ToString());
            }
            else if (SettleUtility.PlayerSettlementsCountLimitReached)
            {
                if (Prefs.MaxNumberOfPlayerSettlements > 1)
                {
                    command_Settle.Disable("CommandSettleFailReachedMaximumNumberOfBases".Translate());
                }
                else
                {
                    command_Settle.Disable("CommandSettleFailAlreadyHaveBase".Translate());
                }
            }
            return(command_Settle);
        }
示例#2
0
文件: Caravan.cs 项目: potsh/RimWorld
        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);
                        }
                    }
                });
示例#3
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (Find.WorldSelector.SingleSelectedObject == this)
            {
                yield return(new Gizmo_CaravanInfo(this));
            }
            foreach (Gizmo g in base.GetGizmos())
            {
                yield return(g);
            }
            if (this.IsPlayerControlled)
            {
                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    yield return(SettleInEmptyTileUtility.SettleCommand(this));
                }
                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    if (this.PawnsListForReading.Count((Pawn x) => x.IsColonist) >= 2)
                    {
                        yield return(new Command_Action
                        {
                            defaultLabel = "CommandSplitCaravan".Translate(),
                            defaultDesc = "CommandSplitCaravanDesc".Translate(),
                            icon = Caravan.SplitCommand,
                            action = delegate
                            {
                                Find.WindowStack.Add(new Dialog_SplitCaravan(this.$this));
                            }
                        });
                    }
                }
                if (this.pather.Moving)
                {
                    yield return(new Command_Toggle
                    {
                        hotKey = KeyBindingDefOf.Misc1,
                        isActive = (() => this.$this.pather.Paused),
                        toggleAction = delegate
                        {
                            if (!this.$this.pather.Moving)
                            {
                                return;
                            }
                            this.$this.pather.Paused = !this.$this.pather.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 g2 in this.forage.GetGizmos())
                {
                    yield return(g2);
                }
                foreach (WorldObject wo in Find.WorldObjects.ObjectsAt(base.Tile))
                {
                    foreach (Gizmo gizmo in wo.GetCaravanGizmos(this))
                    {
                        yield return(gizmo);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Mental break",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where x.RaceProps.Humanlike && !x.InMentalState
                             select x).TryRandomElement(out pawn))
                        {
                            pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Wander_Sad, null, false, false, null, false);
                        }
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Make random pawn hungry",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where x.needs.food != null
                             select x).TryRandomElement(out pawn))
                        {
                            pawn.needs.food.CurLevelPercentage = 0f;
                        }
                    }
                });

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

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Harm random pawn",
                    action = delegate
                    {
                        Pawn pawn;
                        if (this.$this.PawnsListForReading.TryRandomElement(out pawn))
                        {
                            DamageInfo dinfo = new DamageInfo(DamageDefOf.Scratch, 10f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null);
                            pawn.TakeDamage(dinfo);
                        }
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Down random pawn",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where !x.Downed
                             select x).TryRandomElement(out pawn))
                        {
                            HealthUtility.DamageUntilDowned(pawn, true);
                            Messages.Message("Dev: Downed " + pawn.LabelShort, this.$this, MessageTypeDefOf.TaskCompletion, false);
                        }
                    }
                });

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

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Teleport to destination",
                    action = delegate
                    {
                        this.$this.Tile = this.$this.pather.Destination;
                        this.$this.pather.StopDead();
                    }
                });
            }
        }
示例#4
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);
            }
        }
示例#5
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo g in base.GetGizmos())
            {
                yield return(g);
            }
            if (this.IsPlayerControlled)
            {
                if (CaravanMergeUtility.ShouldShowMergeCommand)
                {
                    yield return(CaravanMergeUtility.MergeCommand(this));
                }
                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    if (this.PawnsListForReading.Count((Pawn x) => x.IsColonist) >= 2)
                    {
                        yield return(new Command_Action
                        {
                            defaultLabel = "CommandSplitCaravan".Translate(),
                            defaultDesc = "CommandSplitCaravanDesc".Translate(),
                            icon = Caravan.SplitCommand,
                            action = delegate
                            {
                                Find.WindowStack.Add(new Dialog_SplitCaravan(this.$this));
                            }
                        });
                    }
                }
                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    yield return(SettleInEmptyTileUtility.SettleCommand(this));
                }
                foreach (WorldObject wo in Find.WorldObjects.ObjectsAt(base.Tile))
                {
                    foreach (Gizmo gizmo in wo.GetCaravanGizmos(this))
                    {
                        yield return(gizmo);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Mental break",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where x.RaceProps.Humanlike && !x.InMentalState
                             select x).TryRandomElement(out pawn))
                        {
                            pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.WanderSad, null, false, false, null);
                        }
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Extreme mental break",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where x.RaceProps.Humanlike && !x.InMentalState
                             select x).TryRandomElement(out pawn))
                        {
                            pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, null, false, false, null);
                        }
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Make random pawn hungry",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where x.needs.food != null
                             select x).TryRandomElement(out pawn))
                        {
                            pawn.needs.food.CurLevelPercentage = 0f;
                        }
                    }
                });

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

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Harm random pawn",
                    action = delegate
                    {
                        Pawn pawn;
                        if (this.$this.PawnsListForReading.TryRandomElement(out pawn))
                        {
                            DamageInfo dinfo = new DamageInfo(DamageDefOf.Scratch, 10, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown);
                            pawn.TakeDamage(dinfo);
                        }
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Down random pawn",
                    action = delegate
                    {
                        Pawn pawn;
                        if ((from x in this.$this.PawnsListForReading
                             where !x.Downed
                             select x).TryRandomElement(out pawn))
                        {
                            HealthUtility.DamageUntilDowned(pawn);
                            Messages.Message("Dev: Downed " + pawn.LabelShort, this.$this, MessageTypeDefOf.TaskCompletion);
                        }
                    }
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: Teleport to destination",
                    action = delegate
                    {
                        this.$this.Tile = this.$this.pather.Destination;
                        this.$this.pather.StopDead();
                    }
                });
            }
        }
示例#6
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo g = enumerator.Current;
                    yield return(g);

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

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

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

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

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            if (!Prefs.DevMode)
            {
                yield break;
            }
            yield return((Gizmo) new Command_Action
            {
                defaultLabel = "Dev: Mental break",
                action = delegate
                {
                    Pawn pawn = default(Pawn);
                    if ((from x in ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_034c: stateMachine*/)._0024this.PawnsListForReading
                         where x.RaceProps.Humanlike && !x.InMentalState
                         select x).TryRandomElement <Pawn>(out pawn))
                    {
                        pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.WanderSad, null, false, false, null);
                    }
                }
            });

            /*Error: Unable to find new state assignment for yield return*/;
IL_0576:
            /*Error near IL_0577: Unexpected return in MoveNext()*/;
        }