示例#1
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in this.< GetGizmos > __BaseCallProxy0())
            {
                yield return(c);
            }
            foreach (Gizmo c2 in ShipUtility.ShipStartupGizmos(this))
            {
                yield return(c2);
            }
            Command_Action launch = new Command_Action();

            launch.action       = new Action(this.TryLaunch);
            launch.defaultLabel = "CommandShipLaunch".Translate();
            launch.defaultDesc  = "CommandShipLaunchDesc".Translate();
            if (!this.CanLaunchNow)
            {
                launch.Disable(ShipUtility.LaunchFailReasons(this).First <string>());
            }
            if (ShipCountdown.CountingDown)
            {
                launch.Disable(null);
            }
            launch.hotKey = KeyBindingDefOf.Misc1;
            launch.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip", true);

            yield return(launch);

            yield break;
        }
示例#2
0
        public static Command TradeCommand(Caravan caravan)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement settlement = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (settlement != null && settlement.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(settlement.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithSettlement".Translate(), false, true);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.NeutralEvent, settlement, null);
                    }
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
示例#3
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            foreach (Gizmo g in base.CompGetGizmosExtra())
            {
                yield return(g);
            }
            Command_Action launch = new Command_Action
            {
                defaultLabel = "D9CTM_CommandLaunchPod".Translate(base.parent.Label),
                defaultDesc  = "D9CTM_CommandLaunchPodDesc".Translate(base.parent.Label),
                icon         = LaunchCommandTex,
                alsoClickIfOtherInGroupClicked = false,
                action = delegate
                {
                    TryLaunch();
                }
            };

            if (!EnoughFuel)
            {
                launch.Disable("D9CTM_PodUnderfueled".Translate(base.parent.Label));
            }
            else if (IsUnderRoof)
            {
                launch.Disable("D9CTM_PodUnderRoof".Translate(base.parent.Label));
            }
            yield return(launch);
        }
示例#4
0
        public static Command TradeCommand(Caravan caravan, Faction faction = null, TraderKindDef trader = null)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan, faction, trader);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement settlement = SettlementVisitedNow(caravan);
                if (settlement != null && settlement.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlement.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent);
                }
            };
            if (bestNegotiator == null)
            {
                if (trader != null && trader.permitRequiredForTrading != null && !caravan.PawnsListForReading.Any((Pawn p) => p.royalty != null && p.royalty.HasPermit(trader.permitRequiredForTrading, faction)))
                {
                    command_Action.Disable("CommandTradeFailNeedPermit".Translate(trader.permitRequiredForTrading.LabelCap));
                }
                else
                {
                    command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
                }
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
示例#5
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            foreach (Gizmo c2 in ArchotechUtility.ShipStartupGizmos(this))
            {
                yield return(c2);
            }
            Command_Action launch = new Command_Action();

            launch.action       = new Action(this.TryLaunch);
            launch.defaultLabel = "GR_ArchotechProjectLaunch".Translate();
            launch.defaultDesc  = "GR_ArchotechProjectLaunchDesc".Translate();
            if (!this.CanLaunchNow)
            {
                launch.Disable(ArchotechUtility.LaunchFailReasons(this).First <string>());
            }
            if (ShipCountdown.CountingDown)
            {
                launch.Disable(null);
            }
            launch.hotKey = KeyBindingDefOf.Misc1;
            launch.icon   = ContentFinder <Texture2D> .Get("ui/commands/GR_AwakenArchotech", true);

            yield return(launch);
        }
示例#6
0
        /// <summary>
        /// Trade dialog for AerialVehicle located on a Settlement
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="settlement"></param>
        public static Command ShuttleTradeCommand(AerialVehicleInFlight vehicle, Settlement settlement)
        {
            Pawn           bestNegotiator = WorldHelper.FindBestNegotiator(vehicle.vehicle, settlement.Faction, settlement.TraderKind);
            Command_Action command_Action = new Command_Action
            {
                defaultLabel = "CommandTrade".Translate(),
                defaultDesc  = "CommandTradeDesc".Translate(),
                icon         = VehicleTex.TradeCommandTex,
                action       = delegate()
                {
                    if (settlement != null && settlement.CanTradeNow)
                    {
                        Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement, false));
                        PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlement.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, false, true);
                    }
                }
            };

            if (bestNegotiator is null)
            {
                if (settlement.TraderKind != null && settlement.TraderKind.permitRequiredForTrading != null && !vehicle.vehicle.AllPawnsAboard.Any((Pawn p) => p.royalty != null && p.royalty.HasPermit(settlement.TraderKind.permitRequiredForTrading, settlement.Faction)))
                {
                    command_Action.Disable("CommandTradeFailNeedPermit".Translate(settlement.TraderKind.permitRequiredForTrading.LabelCap));
                }
                else
                {
                    command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
                }
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
示例#7
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            foreach (Gizmo item in ShipUtility.ShipStartupGizmos(this))
            {
                yield return(item);
            }
            Command_Action command_Action = new Command_Action();

            command_Action.action       = TryLaunch;
            command_Action.defaultLabel = "CommandShipLaunch".Translate();
            command_Action.defaultDesc  = "CommandShipLaunchDesc".Translate();
            if (!CanLaunchNow)
            {
                command_Action.Disable(ShipUtility.LaunchFailReasons(this).First());
            }
            if (ShipCountdown.CountingDown)
            {
                command_Action.Disable();
            }
            command_Action.hotKey = KeyBindingDefOf.Misc1;
            command_Action.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip");

            yield return(command_Action);
        }
 public override IEnumerable <Gizmo> GetCaravanGizmos(Pawn pawn, Faction faction)
 {
     if (FillCaravanAidOption(pawn, faction, out var description, out free, out var disableNotEnoughFavor))
     {
         Command_Action command_Action = new Command_Action
         {
             defaultLabel = def.LabelCap + " (" + pawn.LabelShort + ")",
             defaultDesc  = description,
             icon         = CommandTex,
             action       = delegate
             {
                 CallShuttleToCaravan(pawn, faction, free);
             }
         };
         if (faction.HostileTo(Faction.OfPlayer))
         {
             command_Action.Disable("CommandCallRoyalAidFactionHostile".Translate(faction.Named("FACTION")));
         }
         if (disableNotEnoughFavor)
         {
             command_Action.Disable("CommandCallRoyalAidNotEnoughFavor".Translate());
         }
         yield return(command_Action);
     }
 }
        public Gizmo RoyalAidGizmo()
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandCallRoyalAid".Translate();
            command_Action.defaultDesc  = "CommandCallRoyalAidDesc".Translate();
            command_Action.icon         = CommandTex;
            if (pawn.Downed)
            {
                command_Action.Disable("CommandDisabledUnconscious".TranslateWithBackup("CommandCallRoyalAidUnconscious").Formatted(pawn));
            }
            if (pawn.IsQuestLodger())
            {
                command_Action.Disable("CommandCallRoyalAidLodger".Translate());
            }
            command_Action.action = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (RoyalTitle item in AllTitlesInEffectForReading.Where((RoyalTitle t) => !t.def.permits.NullOrEmpty()))
                {
                    foreach (RoyalTitlePermitDef permit in item.def.permits)
                    {
                        IEnumerable <FloatMenuOption> royalAidOptions = permit.Worker.GetRoyalAidOptions(pawn.MapHeld, pawn, item.faction);
                        if (royalAidOptions != null)
                        {
                            list.AddRange(royalAidOptions);
                        }
                    }
                }
                Find.WindowStack.Add(new FloatMenu(list));
            };
            return(command_Action);
        }
示例#10
0
        public static Command_Action SetUpCampCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action
            {
                defaultLabel = "SetUpCamp".Translate(),
                defaultDesc  = "SetUpCampDesc".Translate(),
                icon         = SetUpCampCommandTex,
                action       = delegate()
                {
                    SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_High, null);
                    Camp(caravan);
                }
            };

            tmpSettleFailReason.Length = 0;
            if (!TileFinder.IsValidTileForNewSettlement(caravan.Tile, tmpSettleFailReason))
            {
                command_Action.Disable(tmpSettleFailReason.ToString());
            }
            if (Find.WorldObjects.AnyWorldObjectOfDefAt(SetUpCampDefOf.AbandonedCamp, caravan.Tile))
            {
                command_Action.Disable("SetUpCampOccupied".Translate());
            }
            return(command_Action);
        }
        public static Command TradeCommand(Caravan caravan)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                SettlementBase settlementBase = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (settlementBase != null && settlementBase.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlementBase, false));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlementBase.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, false, true);
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
示例#12
0
        public virtual IEnumerable <Gizmo> EquippedGizmos()
        {
            ThingWithComps owner = IsHeld ? GetUser : parent;
            bool           flag  = Find.Selector.SingleSelectedThing == GetUser;

            if (flag && GetUser.Drafted)
            {
                int            num            = 700000101;
                Command_Action command_Action = new Command_Action()
                {
                    icon          = Active.defaultProjectile.uiIcon,
                    defaultLabel  = "Firemode: " + Active.label,
                    defaultDesc   = "Switch mode.",
                    hotKey        = KeyBindingDefOf.Misc10,
                    activateSound = SoundDefOf.Click,
                    action        = delegate()
                    {
                        Find.WindowStack.Add(MakeModeMenu());
                    },
                    groupKey = num + 1
                };
                if (GetUser.Faction != Faction.OfPlayer)
                {
                    command_Action.Disable("CannotOrderNonControlled".Translate());
                }
                else if (GetUser.stances.curStance.StanceBusy && !Props.canSwitchWhileBusy)
                {
                    command_Action.Disable(GetUser.Name + " can't switch now (Busy)");
                }
                yield return(command_Action);
            }
            yield break;
        }
示例#13
0
        /********************************
        * Gizmos commands              *
        ********************************/

        public static Command AddConstructionSite(Caravan caravan)
        {
            var command_Action = new Command_Action
            {
                defaultLabel = "RoadsOfTheRimAddConstructionSite".Translate(),
                defaultDesc  = "RoadsOfTheRimAddConstructionSiteDescription".Translate(),
                icon         = ContentFinder <Texture2D> .Get("UI/Commands/AddConstructionSite"),
                action       = delegate
                {
                    var constructionSite =
                        (RoadConstructionSite)WorldObjectMaker.MakeWorldObject(
                            DefDatabase <WorldObjectDef> .GetNamed("RoadConstructionSite"));
                    constructionSite.Tile = caravan.Tile;
                    Find.WorldObjects.Add(constructionSite);

                    var menu = new ConstructionMenu(constructionSite, caravan);

                    if (menu.CountBuildableRoads() == 0)
                    {
                        Find.WorldObjects.Remove(constructionSite);
                        Messages.Message("RoadsOfTheRim_NoBetterRoadCouldBeBuilt".Translate(),
                                         MessageTypeDefOf.RejectInput);
                    }
                    else
                    {
                        menu.closeOnClickedOutside = true;
                        menu.forcePause            = true;
                        Find.WindowStack.Add(menu);
                    }
                }
            };

            // Disable if there's already a construction site here
            if (Find.WorldObjects.AnyWorldObjectOfDefAt(DefDatabase <WorldObjectDef> .GetNamed("RoadConstructionSite"),
                                                        caravan.Tile))
            {
                command_Action.Disable("RoadsOfTheRimBuildConstructionSiteAlreadyHere".Translate());
            }

            // disable if the caravan can't work OR if the site is not ready
            if (caravan.GetComponent <WorldObjectComp_Caravan>().CaravanCurrentState() != CaravanState.ReadyToWork)
            {
                command_Action.Disable("RoadsOfTheRimBuildWorkOnSiteCantWork".Translate());
            }

            // Disable on biomes that don't allow roads
            // TO DO : did that ever belong here ? testing for each leg should be enough except if somehow a caravan is in an ocean (glitter road ?) building a lower tier road towards the shore ?
            // In which case, problem is easy to resolve : limit the roads that can be chosen in the menu

            /*
             * BiomeDef biomeHere = Find.WorldGrid.tiles[caravan.Tile].biome ;
             * if (!biomeHere.allowRoads)
             * {
             *  command_Action.Disable("RoadsOfTheRim_BiomePreventsConstruction".Translate(biomeHere.label));
             * }
             */
            return(command_Action);
        }
示例#14
0
            public static void Postfix(Pawn __instance, ref IEnumerable <Gizmo> __result)
            {
                var localResult = __result.ToList();

                // If the pawn is downed, is a colonist and can take adrenaline, add a 'take adrenaline' gizmo
                if (!__instance.Downed || !__instance.IsColonistPlayerControlled || !__instance.CanGetAdrenaline())
                {
                    return;
                }

                var extraRaceProps = __instance.def.GetModExtension <ExtendedRaceProperties>() ??
                                     ExtendedRaceProperties.defaultValues;

                foreach (var tDef in extraRaceProps.RelevantConsumablesDowned)
                {
                    var thingDefExtension =
                        tDef.GetModExtension <ThingDefExtension>() ?? ThingDefExtension.defaultValues;

                    var anyNearbyAdrenaline =
                        AdrenalineUtility.AnyNearbyAdrenaline(__instance, tDef, out var adrenalineThings);

                    var adrenalineGizmo = new Command_Action
                    {
                        defaultLabel = thingDefExtension.downedIngestGizmoLabel,
                        defaultDesc  = thingDefExtension.downedIngestGizmoDescription
                    };

                    if (AdrenalineUtility.adrenalineGizmoIcons.TryGetValue(tDef, out var icon))
                    {
                        adrenalineGizmo.icon = icon;
                    }

                    // No adrenaline nearby
                    if (!anyNearbyAdrenaline)
                    {
                        adrenalineGizmo.Disable(thingDefExtension.downedIngestGizmoNoneNearby);
                        localResult.Add(adrenalineGizmo);
                        continue;
                    }

                    // Can't do manipulation
                    if (!__instance.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                    {
                        adrenalineGizmo.Disable(
                            "Adrenaline.Command_TakeAdrenaline_FailNoManipulation"
                            .Translate(__instance.LabelShort));
                        localResult.Add(adrenalineGizmo);
                        continue;
                    }

                    adrenalineGizmo.action = () => adrenalineThings[0].Ingested(__instance, 0);
                    localResult.Add(adrenalineGizmo);
                }
            }
示例#15
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            using (IEnumerator <Gizmo> enumerator = base.CompGetGizmosExtra().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo g = enumerator.Current;
                    yield return(g);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (!this.LoadingInProgressOrReadyToLaunch)
            {
                yield break;
            }
            Command_Action launch = new Command_Action
            {
                defaultLabel = "CommandLaunchGroup".Translate(),
                defaultDesc  = "CommandLaunchGroupDesc".Translate(),
                icon         = CompLaunchable.LaunchCommandTex,
                alsoClickIfOtherInGroupClicked = false,
                action = delegate
                {
                    if (((_003CCompGetGizmosExtra_003Ec__Iterator0) /*Error near IL_011b: stateMachine*/)._0024this.AnyInGroupHasAnythingLeftToLoad)
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSendNotCompletelyLoadedPods".Translate(((_003CCompGetGizmosExtra_003Ec__Iterator0) /*Error near IL_011b: stateMachine*/)._0024this.FirstThingLeftToLoadInGroup.LabelCapNoCount), ((_003CCompGetGizmosExtra_003Ec__Iterator0) /*Error near IL_011b: stateMachine*/)._0024this.StartChoosingDestination, false, null));
                    }
                    else
                    {
                        ((_003CCompGetGizmosExtra_003Ec__Iterator0) /*Error near IL_011b: stateMachine*/)._0024this.StartChoosingDestination();
                    }
                }
            };

            if (!this.AllInGroupConnectedToFuelingPort)
            {
                launch.Disable("CommandLaunchGroupFailNotConnectedToFuelingPort".Translate());
            }
            else if (!this.AllFuelingPortSourcesInGroupHaveAnyFuel)
            {
                launch.Disable("CommandLaunchGroupFailNoFuel".Translate());
            }
            else if (this.AnyInGroupIsUnderRoof)
            {
                launch.Disable("CommandLaunchGroupFailUnderRoof".Translate());
            }
            yield return((Gizmo)launch);

            /*Error: Unable to find new state assignment for yield return*/;
IL_01ce:
            /*Error near IL_01cf: Unexpected return in MoveNext()*/;
        }
示例#16
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            if (ShipUtility.HasHibernatingParts(this))
            {
                yield return(new Command_Action
                {
                    action = delegate
                    {
                        DiaNode diaNode = new DiaNode("HibernateWarning".Translate());
                        DiaOption diaOption = new DiaOption("Confirm".Translate());
                        diaOption.action = delegate
                        {
                            ShipUtility.StartupHibernatingParts(this.$this);
                        };
                        diaOption.resolveTree = true;
                        diaNode.options.Add(diaOption);
                        DiaOption diaOption2 = new DiaOption("GoBack".Translate());
                        diaOption2.resolveTree = true;
                        diaNode.options.Add(diaOption2);
                        Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, null));
                    },
                    defaultLabel = "CommandShipStartup".Translate(),
                    defaultDesc = "CommandShipStartupDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc1,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DesirePower", true)
                });
            }
            Command_Action launch = new Command_Action();

            launch.action       = new Action(this.TryLaunch);
            launch.defaultLabel = "CommandShipLaunch".Translate();
            launch.defaultDesc  = "CommandShipLaunchDesc".Translate();
            if (!this.CanLaunchNow)
            {
                launch.Disable(ShipUtility.LaunchFailReasons(this).First <string>());
            }
            if (ShipCountdown.CountingDown)
            {
                launch.Disable(null);
            }
            launch.hotKey = KeyBindingDefOf.Misc1;
            launch.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip", true);

            yield return(launch);
        }
        public static IEnumerable <Gizmo> CopyPasteGizmosFor(StorageSettings s)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.icon = ContentFinder <Texture2D> .Get("UI/Commands/CopySettings");

            command_Action.defaultLabel = "CommandCopyZoneSettingsLabel".Translate();
            command_Action.defaultDesc  = "CommandCopyZoneSettingsDesc".Translate();
            command_Action.action       = delegate
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                Copy(s);
            };
            command_Action.hotKey = KeyBindingDefOf.Misc4;
            yield return(command_Action);

            Command_Action command_Action2 = new Command_Action();

            command_Action2.icon = ContentFinder <Texture2D> .Get("UI/Commands/PasteSettings");

            command_Action2.defaultLabel = "CommandPasteZoneSettingsLabel".Translate();
            command_Action2.defaultDesc  = "CommandPasteZoneSettingsDesc".Translate();
            command_Action2.action       = delegate
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                PasteInto(s);
            };
            command_Action2.hotKey = KeyBindingDefOf.Misc5;
            if (!HasCopiedSettings)
            {
                command_Action2.Disable();
            }
            yield return(command_Action2);
        }
示例#18
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    com      = new Command_Action();
                    com.icon = ContentFinder <Texture2D> .Get("UI/Commands/Detonate", true);

                    com.defaultDesc = "CommandDetonateDesc".Translate();
                    com.action      = new Action(base.Command_Detonate);
                    if (base.GetComp <CompExplosive>().wickStarted)
                    {
                        com.Disable(null);
                    }
                    com.defaultLabel = "CommandDetonateLabel".Translate();
                    this.$current    = com;
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
示例#19
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo baseGizmo in base.GetGizmos())
            {
                yield return(baseGizmo);
            }

            if (this.CanSetForcedTarget)
            {
                {
                    Command_VerbPewPew attack = new Command_VerbPewPew();
                    attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                    attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                    attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                    attack.verb   = GunCompEq.PrimaryVerb;
                    attack.hotKey = KeyBindingDefOf.Misc4;
                    yield return(attack);
                }
                {
                    Command_Action stop = new Command_Action();
                    stop.defaultLabel = "CommandStopForceAttack".Translate();
                    stop.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                    stop.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                    stop.action = delegate
                    {
                        this.ResetForcedTarget();
                        SoundDefOf.TickLow.PlayOneShotOnCamera();
                    };
                    if (!this.forcedTarget.IsValid)
                    {
                        stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                    }
                    stop.hotKey = KeyBindingDefOf.Misc5;
                    yield return(stop);
                }
            }

            if (this.CanToggleHoldFire)
            {
                Command_Toggle toggleHoldFire = new Command_Toggle();
                toggleHoldFire.defaultLabel = "CommandHoldFire".Translate();
                toggleHoldFire.defaultDesc  = "CommandHoldFireDesc".Translate();
                toggleHoldFire.icon         = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true);

                toggleHoldFire.hotKey       = KeyBindingDefOf.Misc6;
                toggleHoldFire.toggleAction = delegate
                {
                    this.holdFire = !this.holdFire;
                    if (this.holdFire)
                    {
                        this.currentTargetInt     = LocalTargetInfo.Invalid;
                        this.burstWarmupTicksLeft = 0;
                    }
                };
                toggleHoldFire.isActive = (() => this.holdFire);
                yield return(toggleHoldFire);
            }
        }
示例#20
0
        public static Command TradeCommand(WorldShip worldShip)
        {
            Pawn           bestNegotiator = BestNegotiator(worldShip);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = DropShipUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                SettlementBase Settlement = (SettlementBase)Find.WorldObjects.SettlementBaseAt(worldShip.Tile);
                if (Settlement != null && Settlement.CanTradeNow)
                {
                    //caravan.UnloadCargoForTrading();
                    //Find.WindowStack.Add(new Dialog_TradeFromShips(caravan, bestNegotiator, Settlement));
                    Find.WindowStack.Add(new Dialog_TradeFromShips(worldShip, bestNegotiator, Settlement));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(Settlement.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithSettlement".Translate(), false);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.PositiveEvent, Settlement, null);
                    }
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            return(command_Action);
        }
示例#21
0
        /*
         * Remove Construction Site
         */
        public static Command RemoveConstructionSite(int tile)
        {
            // TO DO : Refactor this so we find the site first, to pass it to Deleteconstructionsite directly, or even get rid of that function all together
            var command_Action = new Command_Action
            {
                defaultLabel = "RoadsOfTheRimRemoveConstructionSite".Translate(),
                defaultDesc  = "RoadsOfTheRimRemoveConstructionSiteDescription".Translate(),
                icon         = ContentFinder <Texture2D> .Get("UI/Commands/RemoveConstructionSite"),
                action       = delegate
                {
                    SoundDefOf.CancelMode.PlayOneShotOnCamera();
                    DeleteConstructionSite(tile);
                }
            };
            // Test when the RemoveConstructionSite action should be disabled (i.e. there's no construction site here)
            var ConstructionSiteAlreadyHere = false;

            try
            {
                ConstructionSiteAlreadyHere =
                    Find.WorldObjects.AnyWorldObjectOfDefAt(
                        DefDatabase <WorldObjectDef> .GetNamed("RoadConstructionSite"), tile);
            }
            catch
            {
                // ignored
            }

            if (!ConstructionSiteAlreadyHere)
            {
                command_Action.Disable("RoadsOfTheRimBuildConstructionSiteNotAlreadyHere".Translate());
            }

            return(command_Action);
        }
示例#22
0
        private Command FulfillRequestCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
            command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
            command_Action.icon         = TradeCommandTex;
            command_Action.action       = delegate
            {
                if (!ActiveRequest)
                {
                    Log.Error("Attempted to fulfill an unavailable request");
                }
                else if (!CaravanInventoryUtility.HasThings(caravan, requestThingDef, requestCount, PlayerCanGive))
                {
                    Messages.Message("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(requestThingDef, requestCount)), MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CommandFulfillTradeOfferConfirm".Translate(GenLabel.ThingLabel(requestThingDef, null, requestCount), GenThing.ThingsToCommaList(rewards, useAnd: true)), delegate
                    {
                        Fulfill(caravan);
                    }));
                }
            };
            if (!CaravanInventoryUtility.HasThings(caravan, requestThingDef, requestCount, PlayerCanGive))
            {
                command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(requestThingDef, requestCount)));
            }
            return(command_Action);
        }
示例#23
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo c = enumerator.Current;
                    yield return(c);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (base.Faction == Faction.OfPlayer && innerContainer.Count > 0 && def.building.isPlayerEjectable)
            {
                Command_Action eject = new Command_Action
                {
                    action       = ((Building_Casket)this).EjectContents,
                    defaultLabel = "CommandPodEject".Translate(),
                    defaultDesc  = "CommandPodEjectDesc".Translate()
                };
                if (innerContainer.Count == 0)
                {
                    eject.Disable("CommandPodEjectFailEmpty".Translate());
                }
                eject.hotKey = KeyBindingDefOf.Misc1;
                eject.icon   = ContentFinder <Texture2D> .Get("UI/Commands/PodEject");

                yield return((Gizmo)eject);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            yield break;
IL_01c4:
            /*Error near IL_01c5: Unexpected return in MoveNext()*/;
        }
示例#24
0
        public override IEnumerable <Command> GetCommands()
        {
            IList <Command> list           = new List <Command>();
            Command_Action  command_Action = new Command_Action();

            if (powerComp.PowerOn && !Sending && !Find.RoofGrid.Roofed(this.Position))
            {
                command_Action.icon        = RadarUnit.UI_Pon;
                command_Action.defaultDesc = "On";
                command_Action.action      = new Action(SendingOn);
            }

            if (Sending || !powerComp.PowerOn || Find.RoofGrid.Roofed(this.Position))
            {
                command_Action.icon        = RadarUnit.UI_Poff;
                command_Action.defaultDesc = "Off";
                command_Action.Disable();
            }

            command_Action.activateSound = SoundDef.Named("Click");
            command_Action.groupKey      = 887767441;
            list.Add(command_Action);
            IEnumerable <Command> commands = base.GetCommands();

            return((commands == null) ? list.AsEnumerable <Command>() : list.AsEnumerable <Command>().Concat(commands));
        }
示例#25
0
        // Token: 0x0600000B RID: 11 RVA: 0x000022A8 File Offset: 0x000004A8
        public static Command CampCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "Set-Up Camp";
            command_Action.defaultDesc  = "Set-Up Camp";
            command_Action.icon         = SetUpCampTextures.CampCommandTex;
            command_Action.action       = delegate()
            {
                SoundStarter.PlayOneShotOnCamera(SoundDefOf.Tick_High, null);
                Camp(caravan);
            };
            bool flag = false;
            List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects;

            for (int i = 0; i < allWorldObjects.Count; i++)
            {
                WorldObject worldObject = allWorldObjects[i];
                bool        flag2       = worldObject.Tile == caravan.Tile && worldObject != caravan;
                if (flag2)
                {
                    flag = true;
                    break;
                }
            }
            bool flag3 = flag;

            if (flag3)
            {
                command_Action.Disable(Translator.Translate("CommandSettleFailOtherWorldObjectsHere"));
            }
            return(command_Action);
        }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = (MapParent)parent;

            if (!mapParent.HasMap)
            {
                yield break;
            }
            if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount != 0)
            {
                Command_Action reformCaravan = new Command_Action {
                    defaultLabel = "CommandReformCaravan".Translate(),
                    defaultDesc  = "CommandReformCaravanDesc".Translate(),
                    icon         = FormCaravanCommand,
                    hotKey       = KeyBindingDefOf.Misc2,
                    tutorTag     = "ReformCaravan",
                    action       = delegate
                    {
                        Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, reform: true)); //always show reform caravan
                    }
                };
                //Disable caravan reforming due to hostiles only in instant mode
                if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map) && RealRuins_ModSettings.caravanReformType == 1)
                {
                    reformCaravan.Disable("CommandReformCaravanFailHostilePawns".Translate());
                }
                yield return(reformCaravan);
            }
        }
示例#27
0
        private Command FulfillRequestCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
            command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
            command_Action.icon         = TradeRequestComp.TradeCommandTex;
            command_Action.action       = delegate
            {
                if (!this.ActiveRequest)
                {
                    Log.Error("Attempted to fulfill an unavailable request", false);
                    return;
                }
                if (!CaravanInventoryUtility.HasThings(caravan, this.requestThingDef, this.requestCount, new Func <Thing, bool>(this.PlayerCanGive)))
                {
                    Messages.Message("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(this.requestThingDef, this.requestCount)), MessageTypeDefOf.RejectInput, false);
                    return;
                }
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CommandFulfillTradeOfferConfirm".Translate(GenLabel.ThingLabel(this.requestThingDef, null, this.requestCount), GenThing.ThingsToCommaList(this.rewards, true, true, -1)), delegate
                {
                    this.Fulfill(caravan);
                }, false, null));
            };
            if (!CaravanInventoryUtility.HasThings(caravan, this.requestThingDef, this.requestCount, new Func <Thing, bool>(this.PlayerCanGive)))
            {
                command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(this.requestThingDef, this.requestCount)));
            }
            return(command_Action);
        }
示例#28
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator();

            while (enumerator.MoveNext())
            {
                Gizmo current = enumerator.Current;
                yield return(current);
            }
            if (base.Faction == Faction.OfPlayer && this.innerContainer.Count > 0 && this.def.building.isPlayerEjectable)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.action       = new Action(this.EjectContents);
                command_Action.defaultLabel = "CommandPodEject".Translate();
                command_Action.defaultDesc  = "CommandPodEjectDesc".Translate();
                if (this.innerContainer.Count == 0)
                {
                    command_Action.Disable("CommandPodEjectFailEmpty".Translate());
                }
                command_Action.hotKey = KeyBindingDefOf.Misc1;
                command_Action.icon   = ContentFinder <Texture2D> .Get("UI/Commands/PodEject", true);

                yield return(command_Action);
            }
            yield break;
        }
示例#29
0
        public static IEnumerable <Gizmo> CopyPasteGizmosFor(StorageSettings s)
        {
            yield return(new Command_Action
            {
                icon = ContentFinder <Texture2D> .Get("UI/Commands/CopySettings", true),
                defaultLabel = "CommandCopyZoneSettingsLabel".Translate(),
                defaultDesc = "CommandCopyZoneSettingsDesc".Translate(),
                action = delegate()
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    StorageSettingsClipboard.Copy(s);
                },
                hotKey = KeyBindingDefOf.Misc4
            });

            Command_Action paste = new Command_Action();

            paste.icon = ContentFinder <Texture2D> .Get("UI/Commands/PasteSettings", true);

            paste.defaultLabel = "CommandPasteZoneSettingsLabel".Translate();
            paste.defaultDesc  = "CommandPasteZoneSettingsDesc".Translate();
            paste.action       = delegate()
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                StorageSettingsClipboard.PasteInto(s);
            };
            paste.hotKey = KeyBindingDefOf.Misc5;
            if (!StorageSettingsClipboard.HasCopiedSettings)
            {
                paste.Disable(null);
            }
            yield return(paste);

            yield break;
        }
示例#30
0
        public static Command TradeCommand(LandedShip caravan)
        {
            Pawn           bestNegotiator = CaravanVisitUtility.BestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = DropShipUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                FactionBase factionBase = CaravanVisitUtility.FactionBaseVisitedNow(caravan);
                if (factionBase != null && factionBase.CanTradeNow)
                {
                    caravan.UnloadCargoForTrading();
                    Find.WindowStack.Add(new Dialog_TradeFromShips(caravan, bestNegotiator, factionBase));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer(factionBase.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithFactionBase".Translate(), false);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterType.Good, factionBase, null);
                    }
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            return(command_Action);
        }
        public override IEnumerable<Command> CompGetGizmosExtra()
        {
            var gizmo = new Command_Action
            {
                defaultDesc = "Upgrade this so you can get advanced version and save some resources",
                defaultLabel = "Upgrade",
                icon = ContentFinder<Texture2D>.Get("UI/Icons/Upgrade"),
                activateSound = SoundDef.Named("Click"),
                action = UpgradeBuilding
            };

            if (!ResearchPrereqsFulfilled)
                gizmo.Disable(DisabledReasonString());

            if (Properties.upgradeTargetDef == null || ThingDef.Named(Properties.upgradeTargetDef.ToString()) == null)
            {
                Log.Error("No such def to upgrade to.");
                yield return null;
            }

            yield return gizmo;
        }