public static IEnumerable <Thing> AllLaunchableThings(Map map)
        {
            HashSet <Thing> yieldedThings = new HashSet <Thing>();

            foreach (Building_OrbitalTradeBeacon item in Building_OrbitalTradeBeacon.AllPowered(map))
            {
                foreach (IntVec3 tradeableCell in item.TradeableCells)
                {
                    List <Thing> thingList = tradeableCell.GetThingList(map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Thing t = thingList[i];
                        if (TradeUtility.EverTradeable(t.def) && t.def.category == ThingCategory.Item && !yieldedThings.Contains(t) && TradeUtility.TradeableNow(t))
                        {
                            yieldedThings.Add(t);
                            yield return(t);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            yield break;
IL_01f0:
            /*Error near IL_01f1: Unexpected return in MoveNext()*/;
        }
Exemple #2
0
        public FloatMenuOption CommFloatMenuOption(Building_CommsConsole console, Pawn negotiator)
        {
            string           label          = "CallOnRadio".Translate(GetCallLabel());
            Action           action         = null;
            AcceptanceReport canCommunicate = CanCommunicateWith_NewTemp(negotiator);

            if (!canCommunicate.Accepted)
            {
                if (!canCommunicate.Reason.NullOrEmpty())
                {
                    action = delegate
                    {
                        Messages.Message(canCommunicate.Reason, console, MessageTypeDefOf.RejectInput, historical: false);
                    };
                }
            }
            else
            {
                action = delegate
                {
                    if (!Building_OrbitalTradeBeacon.AllPowered(Map).Any())
                    {
                        Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), console, MessageTypeDefOf.RejectInput, historical: false);
                    }
                    else
                    {
                        console.GiveUseCommsJob(negotiator, this);
                    }
                };
            }
            return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.InitiateSocial), negotiator, console));
        }
Exemple #3
0
 internal void <> m__0()
 {
     if (!Building_OrbitalTradeBeacon.AllPowered(this.$this.Map).Any <Building_OrbitalTradeBeacon>())
     {
         Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), this.console, MessageTypeDefOf.RejectInput, false);
         return;
     }
     this.console.GiveUseCommsJob(this.negotiator, this.$this);
 }
        public FloatMenuOption CommFloatMenuOption(Building_CommsConsole console, Pawn negotiator)
        {
            string label  = "CallOnRadio".Translate(this.GetCallLabel());
            Action action = delegate
            {
                if (!Building_OrbitalTradeBeacon.AllPowered(this.Map).Any <Building_OrbitalTradeBeacon>())
                {
                    Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), console, MessageTypeDefOf.RejectInput, false);
                    return;
                }
                console.GiveUseCommsJob(negotiator, this);
            };

            return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.InitiateSocial, null, null, 0f, null, null), negotiator, console, "ReservedBy"));
        }
Exemple #5
0
        public static void LaunchThingsOfType(ThingDef resDef, int debt, Map map, TradeShip trader)
        {
            while (true)
            {
                Thing thing;
                if (debt > 0)
                {
                    thing = null;
                    foreach (Building_OrbitalTradeBeacon item in Building_OrbitalTradeBeacon.AllPowered(map))
                    {
                        foreach (IntVec3 tradeableCell in item.TradeableCells)
                        {
                            foreach (Thing item2 in map.thingGrid.ThingsAt(tradeableCell))
                            {
                                if (item2.def != resDef)
                                {
                                    continue;
                                }
                                thing = item2;
                                goto IL_009d;
                            }
                        }
                    }
                    goto IL_009d;
                }
                return;

IL_009d:
                if (thing == null)
                {
                    break;
                }
                int num = Math.Min(debt, thing.stackCount);
                if (trader != null)
                {
                    trader.GiveSoldThingToTrader(thing, num, TradeSession.playerNegotiator);
                }
                else
                {
                    thing.SplitOff(num).Destroy();
                }
                debt -= num;
            }
            Log.Error("Could not find any " + resDef + " to transfer to trader.");
        }
Exemple #6
0
        public static IEnumerable <Thing> AllLaunchableThingsForTrade(Map map, ITrader trader = null)
        {
            HashSet <Thing> yieldedThings = new HashSet <Thing>();

            foreach (Building_OrbitalTradeBeacon item in Building_OrbitalTradeBeacon.AllPowered(map))
            {
                foreach (IntVec3 tradeableCell in item.TradeableCells)
                {
                    List <Thing> thingList = tradeableCell.GetThingList(map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Thing thing = thingList[i];
                        if (thing.def.category == ThingCategory.Item && PlayerSellableNow(thing, trader) && !yieldedThings.Contains(thing))
                        {
                            yieldedThings.Add(thing);
                            yield return(thing);
                        }
                    }
                }
            }
        }
        public static IEnumerable <Thing> AllLaunchableThings(Map map)
        {
            HashSet <Thing> yieldedThings = new HashSet <Thing>();

            foreach (Building_OrbitalTradeBeacon beacon in Building_OrbitalTradeBeacon.AllPowered(map))
            {
                foreach (IntVec3 c in beacon.TradeableCells)
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Thing t = thingList[i];
                        if (TradeUtility.EverTradeable(t.def) && t.def.category == ThingCategory.Item && !yieldedThings.Contains(t) && TradeUtility.TradeableNow(t))
                        {
                            yieldedThings.Add(t);
                            yield return(t);
                        }
                    }
                }
            }
        }
 public static IEnumerable <IntVec3> AllTradeableCells(Map map)
 {
     foreach (Building b in AllPowered(map))
     {
         RimWorld.Building_OrbitalTradeBeacon rb = (RimWorld.Building_OrbitalTradeBeacon)b;
         if (rb != null)
         {
             foreach (IntVec3 cell in rb.TradeableCells)
             {
                 yield return(cell);
             }
         }
         D9OTH.Building_OrbitalTradeBeacon ob = b as D9OTH.Building_OrbitalTradeBeacon;
         if (ob != null)
         {
             foreach (IntVec3 cell in ob.TradeableCells())
             {
                 yield return(cell);
             }
         }
     }
 }
        public static void LaunchThingsOfType(ThingDef resDef, int debt, Map map, TradeShip trader)
        {
            while (debt > 0)
            {
                Thing thing = null;
                foreach (Building_OrbitalTradeBeacon current in Building_OrbitalTradeBeacon.AllPowered(map))
                {
                    foreach (IntVec3 current2 in current.TradeableCells)
                    {
                        foreach (Thing current3 in map.thingGrid.ThingsAt(current2))
                        {
                            if (current3.def == resDef)
                            {
                                thing = current3;
                                goto IL_CC;
                            }
                        }
                    }
                }
IL_CC:
                if (thing == null)
                {
                    Log.Error("Could not find any " + resDef + " to transfer to trader.");
                    break;
                }
                int num = Math.Min(debt, thing.stackCount);
                if (trader != null)
                {
                    trader.GiveSoldThingToTrader(thing, num, TradeSession.playerNegotiator);
                }
                else
                {
                    thing.SplitOff(num).Destroy(DestroyMode.Vanish);
                }
                debt -= num;
            }
        }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol)
        {
            Map currentMap = Find.CurrentMap;

            GenDraw.DrawFieldEdges(Building_OrbitalTradeBeacon.TradeableCellsAround(center, currentMap));
        }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot)
        {
            Map visibleMap = Find.VisibleMap;

            GenDraw.DrawFieldEdges(Building_OrbitalTradeBeacon.TradeableCellsAround(center, visibleMap));
        }
Exemple #12
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn)
        {
            if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn))
            {
                FloatMenuOption        item = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                list.Add(item);
                return(list);
            }
            if (base.Spawned && base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.SolarFlare))
            {
                FloatMenuOption        item2 = new FloatMenuOption("CannotUseSolarFlare".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                List <FloatMenuOption> list  = new List <FloatMenuOption>();
                list.Add(item2);
                return(list);
            }
            if (!this.powerComp.PowerOn)
            {
                FloatMenuOption        item3 = new FloatMenuOption("CannotUseNoPower".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                List <FloatMenuOption> list  = new List <FloatMenuOption>();
                list.Add(item3);
                return(list);
            }
            if (!myPawn.health.capacities.CapableOf(PawnCapacityDefOf.Talking))
            {
                FloatMenuOption        item4 = new FloatMenuOption("CannotUseReason".Translate("IncapableOfCapacity".Translate(PawnCapacityDefOf.Talking.label)), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                List <FloatMenuOption> list  = new List <FloatMenuOption>();
                list.Add(item4);
                return(list);
            }
            if (myPawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                FloatMenuOption        item5 = new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                List <FloatMenuOption> list  = new List <FloatMenuOption>();
                list.Add(item5);
                return(list);
            }
            if (!this.CanUseCommsNow)
            {
                Log.Error(myPawn + " could not use comm console for unknown reason.");
                FloatMenuOption        item6 = new FloatMenuOption("Cannot use now", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                List <FloatMenuOption> list  = new List <FloatMenuOption>();
                list.Add(item6);
                return(list);
            }
            List <FloatMenuOption>      list2      = new List <FloatMenuOption>();
            IEnumerable <ICommunicable> enumerable = myPawn.Map.passingShipManager.passingShips.Cast <ICommunicable>().Concat(Find.FactionManager.AllFactionsInViewOrder.Cast <ICommunicable>());

            foreach (ICommunicable item7 in enumerable)
            {
                ICommunicable localCommTarget = item7;
                string        text            = "CallOnRadio".Translate(localCommTarget.GetCallLabel());
                Faction       faction         = localCommTarget as Faction;
                if (faction != null)
                {
                    if (!faction.IsPlayer)
                    {
                        if (Building_CommsConsole.LeaderIsAvailableToTalk(faction))
                        {
                            goto IL_0339;
                        }
                        string str = (faction.leader == null) ? "LeaderUnavailableNoLeader".Translate() : "LeaderUnavailable".Translate(faction.leader.LabelShort);
                        list2.Add(new FloatMenuOption(text + " (" + str + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    continue;
                }
                goto IL_0339;
IL_0339:
                Action action = delegate
                {
                    ICommunicable commTarget2 = localCommTarget;
                    if (item7 is TradeShip && !Building_OrbitalTradeBeacon.AllPowered(base.Map).Any())
                    {
                        Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), this, MessageTypeDefOf.RejectInput);
                    }
                    else
                    {
                        Job job = new Job(JobDefOf.UseCommsConsole, this);
                        job.commTarget = commTarget2;
                        myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.OpeningComms, KnowledgeAmount.Total);
                    }
                };
                list2.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, action, MenuOptionPriority.InitiateSocial, null, null, 0f, null, null), myPawn, this, "ReservedBy"));
            }
            return(list2);
        }