Пример #1
0
 public void Kidnap(Pawn pawn, Pawn kidnapper)
 {
     if (kidnappedPawns.Contains(pawn))
     {
         Log.Error("Tried to kidnap already kidnapped pawn " + pawn);
     }
     else if (pawn.Faction == faction)
     {
         Log.Error("Tried to kidnap pawn with the same faction: " + pawn);
     }
     else
     {
         pawn.PreKidnapped(kidnapper);
         if (pawn.Spawned)
         {
             pawn.DeSpawn();
         }
         kidnappedPawns.Add(pawn);
         if (!Find.WorldPawns.Contains(pawn))
         {
             Find.WorldPawns.PassToWorld(pawn);
             if (!Find.WorldPawns.Contains(pawn))
             {
                 Log.Error("WorldPawns discarded kidnapped pawn.");
                 kidnappedPawns.Remove(pawn);
             }
         }
         if (pawn.Faction == Faction.OfPlayer)
         {
             BillUtility.Notify_ColonistUnavailable(pawn);
         }
     }
 }
 public void Kidnap(Pawn pawn, Pawn kidnapper)
 {
     if (this.kidnappedPawns.Contains(pawn))
     {
         Log.Error("Tried to kidnap already kidnapped pawn " + pawn, false);
         return;
     }
     if (pawn.Faction == this.faction)
     {
         Log.Error("Tried to kidnap pawn with the same faction: " + pawn, false);
         return;
     }
     pawn.PreKidnapped(kidnapper);
     if (pawn.Spawned)
     {
         pawn.DeSpawn(DestroyMode.Vanish);
     }
     this.kidnappedPawns.Add(pawn);
     if (!Find.WorldPawns.Contains(pawn))
     {
         Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Decide);
         if (!Find.WorldPawns.Contains(pawn))
         {
             Log.Error("WorldPawns discarded kidnapped pawn.", false);
             this.kidnappedPawns.Remove(pawn);
         }
     }
     if (pawn.Faction == Faction.OfPlayer)
     {
         BillUtility.Notify_ColonistUnavailable(pawn);
     }
 }
Пример #3
0
 public static void Notify_ZoneStockpileRemoved(Zone_Stockpile stockpile)
 {
     foreach (Bill current in BillUtility.GlobalBills())
     {
         current.ValidateSettings();
     }
 }
Пример #4
0
 public static void Notify_ColonistUnavailable(Pawn pawn)
 {
     foreach (Bill bill in BillUtility.GlobalBills())
     {
         bill.ValidateSettings();
     }
 }
Пример #5
0
        protected override void FillTab()
        {
            IStoreSettingsParent storeSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings            = storeSettingsParent.GetStoreSettings();
            Rect position = new Rect(0f, 0f, ITab_Storage.WinSize.x, ITab_Storage.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label().CapitalizeFirst(), true, false, true))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (StoragePriority storagePriority in Enum.GetValues(typeof(StoragePriority)))
                    {
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                            {
                                settings.Priority = localPr;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            ThingFilter parentFilter = null;

            if (storeSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = storeSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            Bill[] first = (from b in BillUtility.GlobalBills()
                            where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                            select b).ToArray <Bill>();
            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, null, null);
            Bill[] second = (from b in BillUtility.GlobalBills()
                             where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                             select b).ToArray <Bill>();
            IEnumerable <Bill> enumerable = first.Except(second);

            foreach (Bill current in enumerable)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(new object[]
                {
                    current.LabelCap,
                    current.billStack.billGiver.LabelShort.CapitalizeFirst(),
                    current.GetStoreZone().label
                }), current.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, false);
            }
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
Пример #6
0
 public static void Notify_ColonistUnavailable(Pawn pawn)
 {
     try
     {
         foreach (Bill current in BillUtility.GlobalBills())
         {
             current.ValidateSettings();
         }
     }
     catch (Exception arg)
     {
         Log.Error("Could not notify bills: " + arg, false);
     }
 }
Пример #7
0
 public static IEnumerable <Bill> GlobalBills()
 {
     foreach (IBillGiver billgiver in BillUtility.GlobalBillGivers())
     {
         foreach (Bill bill in billgiver.BillStack)
         {
             yield return(bill);
         }
     }
     if (BillUtility.Clipboard != null)
     {
         yield return(BillUtility.Clipboard);
     }
 }
Пример #8
0
 public void Kidnap(Pawn pawn, Pawn kidnapper)
 {
     if (kidnappedPawns.Contains(pawn))
     {
         Log.Error("Tried to kidnap already kidnapped pawn " + pawn);
         return;
     }
     if (pawn.Faction == faction)
     {
         Log.Error("Tried to kidnap pawn with the same faction: " + pawn);
         return;
     }
     pawn.PreKidnapped(kidnapper);
     if (pawn.Spawned)
     {
         pawn.DeSpawn();
     }
     kidnappedPawns.Add(pawn);
     if (!Find.WorldPawns.Contains(pawn))
     {
         Find.WorldPawns.PassToWorld(pawn);
         if (!Find.WorldPawns.Contains(pawn))
         {
             Log.Error("WorldPawns discarded kidnapped pawn.");
             kidnappedPawns.Remove(pawn);
         }
     }
     if (pawn.Faction == Faction.OfPlayer)
     {
         PawnDiedOrDownedThoughtsUtility.TryGiveThoughts(pawn, null, PawnDiedOrDownedThoughtsKind.Lost);
         BillUtility.Notify_ColonistUnavailable(pawn);
         if (kidnapper != null)
         {
             Find.LetterStack.ReceiveLetter("LetterLabelPawnsKidnapped".Translate(pawn.Named("PAWN")), "LetterPawnsKidnapped".Translate(pawn.Named("PAWN"), kidnapper.Faction.Named("FACTION")), LetterDefOf.NegativeEvent);
         }
     }
     QuestUtility.SendQuestTargetSignals(pawn.questTags, "Kidnapped", this.Named("SUBJECT"), kidnapper.Named("KIDNAPPER"));
     Find.GameEnder.CheckOrUpdateGameOver();
 }
Пример #9
0
 public override void PostDeregister()
 {
     base.PostDeregister();
     BillUtility.Notify_ZoneStockpileRemoved(this);
 }
Пример #10
0
        protected override void FillTab()
        {
            IStoreSettingsParent storeSettingsParent = SelStoreSettingsParent;
            StorageSettings      settings            = storeSettingsParent.GetStoreSettings();
            Vector2 winSize  = WinSize;
            float   x        = winSize.x;
            Vector2 winSize2 = WinSize;
            Rect    position = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label().CapitalizeFirst()))
                {
                    List <FloatMenuOption> list       = new List <FloatMenuOption>();
                    IEnumerator            enumerator = Enum.GetValues(typeof(StoragePriority)).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            StoragePriority storagePriority = (StoragePriority)enumerator.Current;
                            if (storagePriority != 0)
                            {
                                StoragePriority localPr = storagePriority;
                                list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                                {
                                    settings.Priority = localPr;
                                }));
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable;
                        if ((disposable = (enumerator as IDisposable)) != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            ThingFilter parentFilter = null;

            if (storeSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = storeSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, TopAreaHeight, position.width, position.height - TopAreaHeight);

            Bill[] first = (from b in BillUtility.GlobalBills()
                            where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                            select b).ToArray();
            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref scrollPosition, settings.filter, parentFilter, 8);
            Bill[] second = (from b in BillUtility.GlobalBills()
                             where b is Bill_Production && b.GetStoreZone() == storeSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                             select b).ToArray();
            IEnumerable <Bill> enumerable = first.Except(second);

            foreach (Bill item in enumerable)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(item.LabelCap, item.billStack.billGiver.LabelShort.CapitalizeFirst(), item.GetStoreZone().label), item.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, historical: false);
            }
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }