示例#1
0
        public static Thing FindAmmoForTurret(Pawn pawn, Building_TurretGun gun)
        {
            StorageSettings   allowedShellsSettings = (!pawn.IsColonist) ? null : gun.gun.TryGetComp <CompChangeableProjectile>().allowedShellsSettings;
            Predicate <Thing> validator             = (Thing t) => !t.IsForbidden(pawn) && pawn.CanReserve(t, 10, 1, null, false) && (allowedShellsSettings == null || allowedShellsSettings.AllowedToAccept(t));

            return(GenClosest.ClosestThingReachable(gun.Position, gun.Map, ThingRequest.ForGroup(ThingRequestGroup.Shell), PathEndMode.OnCell, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 40f, validator, null, 0, -1, false, RegionType.Set_Passable, false));
        }
示例#2
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.TickHigh.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.TickHigh.PlayOneShotOnCamera(null);
                StorageSettingsClipboard.PasteInto(s);
            };
            paste.hotKey = KeyBindingDefOf.Misc5;
            if (!StorageSettingsClipboard.HasCopiedSettings)
            {
                paste.Disable(null);
            }
            yield return(paste);
        }
示例#3
0
 public Zone_Stockpile(StorageSettingsPreset preset, ZoneManager zoneManager)
     : base(preset.PresetName(), zoneManager)
 {
     this.settings = new StorageSettings(this);
     this.settings.SetFromPreset(preset);
     this.slotGroup = new SlotGroup(this);
 }
示例#4
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();
        }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.allowedShellsSettings = new StorageSettings(this);
     if (this.parent.def.building.defaultStorageSettings != null)
     {
         this.allowedShellsSettings.CopyFrom(this.parent.def.building.defaultStorageSettings);
     }
 }
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();
            Vector2 winSize  = ITab_Storage.WinSize;
            float   x        = winSize.x;
            Vector2 winSize2 = ITab_Storage.WinSize;
            Rect    position = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, (float)(this.TopAreaHeight - 6.0));
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
                {
                    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;
                                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                            }
                        }
                    }
                    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 (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, (IEnumerable <ThingDef>)null, (IEnumerable <SpecialThingFilterDef>)null, (List <ThingDef>)null);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
 public override void PostMake()
 {
     base.PostMake();
     this.settings = new StorageSettings(this);
     if (this.def.building.defaultStorageSettings != null)
     {
         this.settings.CopyFrom(this.def.building.defaultStorageSettings);
     }
 }
示例#8
0
 public StorageSettings(IStoreSettingsParent owner) : this()
 {
     this.owner = owner;
     if (owner != null)
     {
         StorageSettings parentStoreSettings = owner.GetParentStoreSettings();
         if (parentStoreSettings != null)
         {
             this.priorityInt = parentStoreSettings.priorityInt;
         }
     }
 }
示例#9
0
 public bool AllowedToAccept(Thing t)
 {
     if (!this.filter.Allows(t))
     {
         return(false);
     }
     if (this.owner != null)
     {
         StorageSettings parentStoreSettings = this.owner.GetParentStoreSettings();
         if (parentStoreSettings != null && !parentStoreSettings.AllowedToAccept(t))
         {
             return(false);
         }
     }
     return(true);
 }
示例#10
0
        public static IEnumerable <Gizmo> CopyPasteGizmosFor(StorageSettings s)
        {
            yield return((Gizmo) new Command_Action
            {
                icon = ContentFinder <Texture2D> .Get("UI/Commands/CopySettings", true),
                defaultLabel = "CommandCopyZoneSettingsLabel".Translate(),
                defaultDesc = "CommandCopyZoneSettingsDesc".Translate(),
                action = delegate
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    StorageSettingsClipboard.Copy(s);
                },
                hotKey = KeyBindingDefOf.Misc4
            });

            /*Error: Unable to find new state assignment for yield return*/;
        }
示例#11
0
        public static Thing FindAmmoForTurret(Pawn pawn, Building_TurretGun gun)
        {
            StorageSettings   allowedShellsSettings = pawn.IsColonist ? gun.gun.TryGetComp <CompChangeableProjectile>().allowedShellsSettings : null;
            Predicate <Thing> validator             = delegate(Thing t)
            {
                if (t.IsForbidden(pawn))
                {
                    return(false);
                }
                if (!pawn.CanReserve(t, 10, 1))
                {
                    return(false);
                }
                return((allowedShellsSettings == null || allowedShellsSettings.AllowedToAccept(t)) ? true : false);
            };

            return(GenClosest.ClosestThingReachable(gun.Position, gun.Map, ThingRequest.ForGroup(ThingRequestGroup.Shell), PathEndMode.OnCell, TraverseParms.For(pawn), 40f, validator));
        }
示例#12
0
 public void ResolveReferencesSpecial()
 {
     if (this.soundDoorOpenPowered == null)
     {
         this.soundDoorOpenPowered = SoundDefOf.Door_OpenPowered;
     }
     if (this.soundDoorClosePowered == null)
     {
         this.soundDoorClosePowered = SoundDefOf.Door_ClosePowered;
     }
     if (this.soundDoorOpenManual == null)
     {
         this.soundDoorOpenManual = SoundDefOf.Door_OpenManual;
     }
     if (this.soundDoorCloseManual == null)
     {
         this.soundDoorCloseManual = SoundDefOf.Door_CloseManual;
     }
     if (!this.turretTopGraphicPath.NullOrEmpty())
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             this.turretTopMat = MaterialPool.MatFrom(this.turretTopGraphicPath);
         });
     }
     if (this.fixedStorageSettings != null)
     {
         this.fixedStorageSettings.filter.ResolveReferences();
     }
     if (this.defaultStorageSettings == null)
     {
         if (this.fixedStorageSettings != null)
         {
             this.defaultStorageSettings = new StorageSettings();
             this.defaultStorageSettings.CopyFrom(this.fixedStorageSettings);
         }
     }
     if (this.defaultStorageSettings != null)
     {
         this.defaultStorageSettings.filter.ResolveReferences();
     }
 }
示例#13
0
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.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(), 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 (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, this.TopAreaHeight, position.width, position.height - this.TopAreaHeight);

            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, null);
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
        public bool AllowedToAccept(ThingDef t)
        {
            bool result;

            if (!this.filter.Allows(t))
            {
                result = false;
            }
            else
            {
                if (this.owner != null)
                {
                    StorageSettings parentStoreSettings = this.owner.GetParentStoreSettings();
                    if (parentStoreSettings != null && !parentStoreSettings.AllowedToAccept(t))
                    {
                        return(false);
                    }
                }
                result = true;
            }
            return(result);
        }
 public void ResolveReferencesSpecial()
 {
     if (soundDoorOpenPowered == null)
     {
         soundDoorOpenPowered = SoundDefOf.Door_OpenPowered;
     }
     if (soundDoorClosePowered == null)
     {
         soundDoorClosePowered = SoundDefOf.Door_ClosePowered;
     }
     if (soundDoorOpenManual == null)
     {
         soundDoorOpenManual = SoundDefOf.Door_OpenManual;
     }
     if (soundDoorCloseManual == null)
     {
         soundDoorCloseManual = SoundDefOf.Door_CloseManual;
     }
     if (turretGunDef != null)
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             turretTopMat = MaterialPool.MatFrom(turretGunDef.graphicData.texPath);
         });
     }
     if (fixedStorageSettings != null)
     {
         fixedStorageSettings.filter.ResolveReferences();
     }
     if (defaultStorageSettings == null && fixedStorageSettings != null)
     {
         defaultStorageSettings = new StorageSettings();
         defaultStorageSettings.CopyFrom(fixedStorageSettings);
     }
     if (defaultStorageSettings != null)
     {
         defaultStorageSettings.filter.ResolveReferences();
     }
 }
示例#16
0
 public void ResolveReferencesSpecial()
 {
     if (!this.turretTopGraphicPath.NullOrEmpty())
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             this.turretTopMat = MaterialPool.MatFrom(this.turretTopGraphicPath);
         });
     }
     if (this.fixedStorageSettings != null)
     {
         this.fixedStorageSettings.filter.ResolveReferences();
     }
     if (this.defaultStorageSettings == null && this.fixedStorageSettings != null)
     {
         this.defaultStorageSettings = new StorageSettings();
         this.defaultStorageSettings.CopyFrom(this.fixedStorageSettings);
     }
     if (this.defaultStorageSettings != null)
     {
         this.defaultStorageSettings.filter.ResolveReferences();
     }
 }
示例#17
0
 public static void PasteInto(StorageSettings s)
 {
     s.CopyFrom(StorageSettingsClipboard.clipboard);
 }
示例#18
0
 public static void Copy(StorageSettings s)
 {
     StorageSettingsClipboard.clipboard.CopyFrom(s);
     StorageSettingsClipboard.copied = true;
 }
示例#19
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            if (CanExtractShell)
            {
                CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
                Command_Action           command_Action           = new Command_Action();
                command_Action.defaultLabel  = "CommandExtractShell".Translate();
                command_Action.defaultDesc   = "CommandExtractShellDesc".Translate();
                command_Action.icon          = compChangeableProjectile.LoadedShell.uiIcon;
                command_Action.iconAngle     = compChangeableProjectile.LoadedShell.uiIconAngle;
                command_Action.iconOffset    = compChangeableProjectile.LoadedShell.uiIconOffset;
                command_Action.iconDrawScale = GenUI.IconDrawScale(compChangeableProjectile.LoadedShell);
                command_Action.action        = delegate
                {
                    ExtractShell();
                };
                yield return(command_Action);
            }
            CompChangeableProjectile compChangeableProjectile2 = gun.TryGetComp <CompChangeableProjectile>();

            if (compChangeableProjectile2 != null)
            {
                StorageSettings storeSettings = compChangeableProjectile2.GetStoreSettings();
                foreach (Gizmo item in StorageSettingsClipboard.CopyPasteGizmosFor(storeSettings))
                {
                    yield return(item);
                }
            }
            if (CanSetForcedTarget)
            {
                Command_VerbTarget command_VerbTarget = new Command_VerbTarget();
                command_VerbTarget.defaultLabel = "CommandSetForceAttackTarget".Translate();
                command_VerbTarget.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                command_VerbTarget.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack");

                command_VerbTarget.verb       = AttackVerb;
                command_VerbTarget.hotKey     = KeyBindingDefOf.Misc4;
                command_VerbTarget.drawRadius = false;
                if (base.Spawned && IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    command_VerbTarget.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(command_VerbTarget);
            }
            if (forcedTarget.IsValid)
            {
                Command_Action command_Action2 = new Command_Action();
                command_Action2.defaultLabel = "CommandStopForceAttack".Translate();
                command_Action2.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                command_Action2.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt");

                command_Action2.action = delegate
                {
                    ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                };
                if (!forcedTarget.IsValid)
                {
                    command_Action2.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                command_Action2.hotKey = KeyBindingDefOf.Misc5;
                yield return(command_Action2);
            }
            if (!CanToggleHoldFire)
            {
                yield break;
            }
            Command_Toggle command_Toggle = new Command_Toggle();

            command_Toggle.defaultLabel = "CommandHoldFire".Translate();
            command_Toggle.defaultDesc  = "CommandHoldFireDesc".Translate();
            command_Toggle.icon         = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire");

            command_Toggle.hotKey       = KeyBindingDefOf.Misc6;
            command_Toggle.toggleAction = delegate
            {
                holdFire = !holdFire;
                if (holdFire)
                {
                    ResetForcedTarget();
                }
            };
            command_Toggle.isActive = () => holdFire;
            yield return(command_Toggle);
        }
示例#20
0
 public void CopyFrom(StorageSettings other)
 {
     this.Priority = other.Priority;
     this.filter.CopyAllowancesFrom(other.filter);
     this.TryNotifyChanged();
 }
示例#21
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();
        }