public static void Draw(Rect rect, ThingDef thingDef, Color color)
        {
            rect      = new Rect(rect.MiddleX() - 17, rect.MiddleY() - 17, 34, 34);
            GUI.color = color;
            // EdB: Inline copy of static Widgets.ThingIcon(Rect, ThingDef) with the selected
            // color based on the stuff.
            // EdB: Inline copy of static private method with modifications to keep scaled icons within the
            // bounds of the specified Rect and to draw them using the stuff color.
            //Widgets.ThingIconWorker(rect, thing.def, thingDef.uiIcon);
            float num         = GenUI.IconDrawScale(thingDef);
            Rect  resizedRect = rect;

            if (num != 1f)
            {
                // For items that are going to scale out of the bounds of the icon rect, we need to shrink
                // the bounds a little.
                if (num > 1)
                {
                    resizedRect = rect.ContractedBy(4);
                }
                resizedRect.width  *= num;
                resizedRect.height *= num;
                resizedRect.center  = rect.center;
            }
            GUI.DrawTexture(resizedRect, thingDef.uiIcon);
            GUI.color = Color.white;
        }
        public Designator_Build(BuildableDef entDef)
        {
            this.entDef    = entDef;
            base.icon      = entDef.uiIcon;
            base.iconAngle = entDef.uiIconAngle;
            base.hotKey    = entDef.designationHotKey;
            base.tutorTag  = entDef.defName;
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.uiIconPath.NullOrEmpty())
            {
                base.iconProportions = thingDef.graphicData.drawSize;
                base.iconDrawScale   = GenUI.IconDrawScale(thingDef);
            }
            else
            {
                base.iconProportions = new Vector2(1f, 1f);
                base.iconDrawScale   = 1f;
            }
            TerrainDef terrainDef = entDef as TerrainDef;

            if (terrainDef != null)
            {
                Vector2 terrainTextureCroppedSize = Designator_Build.TerrainTextureCroppedSize;
                float   width = terrainTextureCroppedSize.x / (float)base.icon.width;
                Vector2 terrainTextureCroppedSize2 = Designator_Build.TerrainTextureCroppedSize;
                base.iconTexCoords = new Rect(0f, 0f, width, terrainTextureCroppedSize2.y / (float)base.icon.height);
            }
            this.ResetStuffToDefault();
        }
Esempio n. 3
0
        public Designator_Build(BuildableDef entDef)
        {
            this.entDef = entDef;
            icon        = entDef.uiIcon;
            iconAngle   = entDef.uiIconAngle;
            iconOffset  = entDef.uiIconOffset;
            hotKey      = entDef.designationHotKey;
            tutorTag    = entDef.defName;
            order       = 20f;
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null)
            {
                iconProportions = thingDef.graphicData.drawSize.RotatedBy(thingDef.defaultPlacingRot);
                iconDrawScale   = GenUI.IconDrawScale(thingDef);
            }
            else
            {
                iconProportions = new Vector2(1f, 1f);
                iconDrawScale   = 1f;
            }
            if (entDef is TerrainDef)
            {
                iconTexCoords = Widgets.CroppedTerrainTextureRect(icon);
            }
            ResetStuffToDefault();
        }
Esempio n. 4
0
        public Designator_Build(BuildableDef entDef)
        {
            this.entDef     = entDef;
            this.icon       = entDef.uiIcon;
            this.iconAngle  = entDef.uiIconAngle;
            this.iconOffset = entDef.uiIconOffset;
            this.hotKey     = entDef.designationHotKey;
            this.tutorTag   = entDef.defName;
            this.order      = 20f;
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null)
            {
                this.iconProportions = thingDef.graphicData.drawSize.RotatedBy(thingDef.defaultPlacingRot);
                this.iconDrawScale   = GenUI.IconDrawScale(thingDef);
            }
            else
            {
                this.iconProportions = new Vector2(1f, 1f);
                this.iconDrawScale   = 1f;
            }
            TerrainDef terrainDef = entDef as TerrainDef;

            if (terrainDef != null)
            {
                this.iconTexCoords = new Rect(0f, 0f, Designator_Build.TerrainTextureCroppedSize.x / (float)this.icon.width, Designator_Build.TerrainTextureCroppedSize.y / (float)this.icon.height);
            }
            this.ResetStuffToDefault();
        }
        private void SetDesignatorIcon()
        {
            // use graphic in first designator
            if (SelectedItem.PlacingDef == null && def.debug)
            {
                Controller.Logger.Warning("Failed to get def for icon automatically.");
            }
            else
            {
#if DEBUG_ICON
                Controller.Logger.Message($"using {SelectedItem.PlacingDef.defName} uiIcon");
#endif
                icon = SelectedItem.PlacingDef.uiIcon;
                var thingDef = SelectedItem.PlacingDef as ThingDef;
                if (thingDef != null && thingDef.uiIconPath.NullOrEmpty())
                {
                    iconProportions = thingDef.graphicData.drawSize;
                    iconDrawScale   = GenUI.IconDrawScale(thingDef);
                }
                else
                {
                    iconProportions = new Vector2(1f, 1f);
                    iconDrawScale   = 1f;
                }
                if (SelectedItem.PlacingDef is TerrainDef)
                {
                    iconTexCoords = new Rect(0.0f, 0.0f,
                                             TerrainTextureCroppedSize.x / icon.width,
                                             TerrainTextureCroppedSize.y / icon.height);
                }
            }
        }
Esempio n. 6
0
 public Designator_HaulCryptosleep()
 {
     defaultLabel    = "FrontierDevelopments.DeadCryptosleep.Designator.Label".Translate();
     defaultDesc     = "FrontierDevelopments.DeadCryptosleep.Designator.Desc".Translate();
     icon            = DeadCryptosleepDefOf.CryptosleepCasket.uiIcon;
     iconAngle       = DeadCryptosleepDefOf.CryptosleepCasket.uiIconAngle;
     iconOffset      = DeadCryptosleepDefOf.CryptosleepCasket.uiIconOffset;
     iconProportions = DeadCryptosleepDefOf.CryptosleepCasket.graphicData.drawSize.RotatedBy(DeadCryptosleepDefOf.CryptosleepCasket.defaultPlacingRot);
     iconDrawScale   = GenUI.IconDrawScale(DeadCryptosleepDefOf.CryptosleepCasket);
 }
        private static void ThingIconWorker(Rect rect, ThingDef thingDef, Texture resolvedIcon, float resolvedIconAngle, float scale = 1f)
        {
            Vector2 texProportions = new Vector2(resolvedIcon.width, resolvedIcon.height);
            Rect    texCoords      = new Rect(0f, 0f, 1f, 1f);

            if (thingDef.graphicData != null)
            {
                texProportions = thingDef.graphicData.drawSize.RotatedBy(thingDef.defaultPlacingRot);
                if (thingDef.uiIconPath.NullOrEmpty() && thingDef.graphicData.linkFlags != 0)
                {
                    texCoords = new Rect(0f, 0.5f, 0.25f, 0.25f);
                }
            }
            Widgets.DrawTextureFitted(rect, resolvedIcon, GenUI.IconDrawScale(thingDef) * scale, texProportions, texCoords, resolvedIconAngle);
        }
        public static void Draw(Rect rect, Thing thing, Color color)
        {
            rect      = new Rect(rect.center.x - 17, rect.center.y - 17, 38, 38);
            GUI.color = color;
            // EdB: Inline copy of static Widgets.ThingIcon(Rect, Thing) with graphics switched to show a side view
            // instead of a front view.
            GUI.color = thing.DrawColor;
            Texture resolvedIcon;

            if (!thing.def.uiIconPath.NullOrEmpty())
            {
                resolvedIcon = thing.def.uiIcon;
            }
            else if (thing is Pawn)
            {
                Pawn pawn = (Pawn)thing;
                if (!pawn.Drawer.renderer.graphics.AllResolved)
                {
                    pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                }
                Material matSingle = pawn.Drawer.renderer.graphics.nakedGraphic.MatSide;
                resolvedIcon = matSingle.mainTexture;
                GUI.color    = matSingle.color;
            }
            else
            {
                resolvedIcon = thing.Graphic.ExtractInnerGraphicFor(thing).MatSide.mainTexture;
            }
            // EdB: Inline copy of static private method.
            //Widgets.ThingIconWorker(rect, thing.def, resolvedIcon);
            float num = GenUI.IconDrawScale(thing.def);

            if (num != 1f)
            {
                Vector2 center = rect.center;
                rect.width  *= num;
                rect.height *= num;
                rect.center  = center;
            }
            GUI.DrawTexture(rect, resolvedIcon);
            GUI.color = Color.white;
        }
Esempio n. 9
0
        public Designator_MicroRecipe(RecipeDef recipeDef, BuildableDef thingUser)
        {
            this.recipeDef = recipeDef;

            defaultLabel     = recipeDef.label;
            defaultDesc      = recipeDef.description;
            soundDragSustain = SoundDefOf.Designate_DragStandard;
            soundDragChanged = SoundDefOf.Designate_DragStandard_Changed;
            soundSucceeded   = SoundDefOf.Designate_Claim;
            //useMouseIcon = true;

            try { designationDef = DefDatabase <DesignationDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == recipeDef.defName + "Designation"); }
            catch { Log.Message($"weird thing happened, couldn't load DesignationDef for Designator({this})"); }

            entDef     = thingUser;
            icon       = entDef.uiIcon;
            iconAngle  = entDef.uiIconAngle;
            iconOffset = entDef.uiIconOffset;
            order      = 200f;
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef == null)
            {
                iconProportions = thingDef.graphicData.drawSize.RotatedBy(thingDef.defaultPlacingRot);
                iconDrawScale   = GenUI.IconDrawScale(thingDef);
            }
            else
            {
                iconProportions = new Vector2(1f, 1f);
                iconDrawScale   = 1f;
            }

            TerrainDef terrainDef = entDef as TerrainDef;

            if (terrainDef != null)
            {
                iconTexCoords = new Rect(0f, 0f, TerrainTextureCroppedSize.x / icon.width, TerrainTextureCroppedSize.y / icon.height);
            }

            ResetStuffToDefault();
        }
Esempio n. 10
0
        private void DrawThingDefRow(ref float y, float width, ThingDef thingDef)
        {
            Rect rect = new Rect(0f, y, width, 28f);

            if (Mouse.IsOver(rect))
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1f);
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            if (thingDef.DrawMatSingle != null && thingDef.DrawMatSingle.mainTexture != null)
            {
                if (thingDef.graphicData != null && GenUI.IconDrawScale(thingDef) <= 1.5f)
                {
                    Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thingDef);
                }
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = new Color(0.9f, 0.9f, 0.9f, 1f);
            Rect rect5 = new Rect(36f, y, rect.width - 36f, rect.height);

            Text.WordWrap = false;
            Widgets.Label(rect5, thingDef.LabelCap.Truncate(rect5.width, null));
            Text.WordWrap = true;
            string text2 = thingDef.description;

            if (y > -28f)
            {
                TooltipHandler.TipRegion(rect, string.IsNullOrEmpty(text2) ? "PRFNoDesc".Translate().RawText : text2);
            }
            if (GUI.Button(rect, "", Widgets.EmptyStyle))
            {
                if (SelBuilding.ThingToGenerate != thingDef)
                {
                    SelBuilding.ThingToGenerate = thingDef;
                }
                SoundDefOf.Click.PlayOneShot(SoundInfo.OnCamera());
            }
            Text.Anchor = TextAnchor.UpperLeft;
            y          += 28f;
        }
Esempio n. 11
0
 public override IEnumerable <Gizmo> GetGizmos()
 {
     foreach (Gizmo c in base.GetGizmos())
     {
         yield return(c);
     }
     if (this.CanUnburrowNow)
     {
         yield return(new Command_Action
         {
             defaultLabel = "Unburrow".Translate(),
             defaultDesc = "Unburrow Turret.".Translate(),
             icon = ContentFinder <Texture2D> .Get("UI/Commands/GTMunburrow", true),
             iconAngle = 0,
             iconOffset = Vector2.zero,
             iconDrawScale = GenUI.IconDrawScale(this.def),
             action = delegate
             {
                 this.UnburrowTurret();
             }
         });
     }
 }
Esempio n. 12
0
 public override IEnumerable <Gizmo> CompGetGizmosExtra()
 {
     foreach (Gizmo c in base.CompGetGizmosExtra())
     {
         yield return(c);
     }
     if (this.parent.Faction == Faction.OfPlayer)
     {
         yield return(new Command_Action
         {
             defaultLabel = "burrow".Translate(),
             defaultDesc = "burrow Turret.".Translate(),
             icon = ContentFinder <Texture2D> .Get("UI/Commands/GTMburrow", true),
             iconAngle = 0,
             iconOffset = Vector2.zero,
             iconDrawScale = GenUI.IconDrawScale(parent.def),
             action = delegate
             {
                 this.burrowTurret();
             }
         });
     }
 }
Esempio n. 13
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            foreach (var gizmo in base.CompGetGizmosExtra())
            {
                yield return(gizmo);
            }

            if (nextAmmoItem != null)
            {
                yield return new Command_Action
                       {
                           defaultLabel  = "CommandExtractShell".Translate(),
                           defaultDesc   = "CommandExtractShellDesc".Translate(),
                           icon          = nextAmmoItem.def.uiIcon,
                           iconAngle     = nextAmmoItem.def.uiIconAngle,
                           iconOffset    = nextAmmoItem.def.uiIconOffset,
                           iconDrawScale = GenUI.IconDrawScale(nextAmmoItem.def),
                           action        = delegate
                           {
                               container.TryDrop(nextAmmoItem, parent.Position, parent.Map, ThingPlaceMode.Near, 1,
                                                 out var thing);
                               if (!container.Any)
                               {
                                   nextAmmoItem = null;
                               }
                           }
                       }
            }
            ;

            yield return(new Gizmo_LevelReadout
            {
                Label = "Remaining shells",
                Value = LoadedShells,
                MaxValue = Props.MaxShells
            });
        }
Esempio n. 14
0
 public override IEnumerable <Gizmo> CompGetGizmosExtra()
 {
     foreach (Gizmo gizmo in StorageSettingsClipboard.CopyPasteGizmosFor(settings))
     {
         yield return(gizmo);
     }
     if (loaded)
     {
         if (SoftWarmBedsSettings.manuallyUnmakeBed)
         {
             Props.commandTexture = Props.beddingDef.graphicData.texPath;
             foreach (Gizmo gizmo in base.CompGetGizmosExtra())
             {
                 yield return(gizmo);
             }
         }
         else
         {
             Command_Action unmake = new Command_Action
             {
                 defaultLabel  = Props.commandLabelKey.Translate(),
                 defaultDesc   = Props.commandDescKey.Translate(),
                 icon          = LoadedBedding.uiIcon,
                 iconAngle     = LoadedBedding.uiIconAngle,
                 iconOffset    = LoadedBedding.uiIconOffset,
                 iconDrawScale = GenUI.IconDrawScale(LoadedBedding),
                 action        = delegate()
                 {
                     Unmake();
                 }
             };
             yield return(unmake);
         }
     }
     yield break;
 }
Esempio n. 15
0
        // Token: 0x06007DD8 RID: 32216 RVA: 0x00054920 File Offset: 0x00052B20
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo gizmo in base.GetGizmos())
            {
                yield return(gizmo);
            }
            IEnumerator <Gizmo> enumerator = null;

            if (this.CanExtractShell)
            {
                AERIALChangeableProjectile compChangeableProjectile = this.gun.TryGetComp <AERIALChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].uiIcon,
                    iconAngle = compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].uiIconAngle,
                    iconOffset = compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1].uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(compChangeableProjectile.loadedShells[compChangeableProjectile.loadedShells.Count - 1]),
                    action = delegate()
                    {
                        this.ExtractShell();
                    }
                });
            }
            AERIALChangeableProjectile compChangeableProjectile2 = this.gun.TryGetComp <AERIALChangeableProjectile>();

            if (compChangeableProjectile2 != null)
            {
                StorageSettings storeSettings = compChangeableProjectile2.GetStoreSettings();
                foreach (Gizmo gizmo2 in StorageSettingsClipboard.CopyPasteGizmosFor(storeSettings))
                {
                    yield return(gizmo2);
                }
                enumerator = null;
            }
            if (this.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", true);

                command_VerbTarget.verb       = this.AttackVerb;
                command_VerbTarget.hotKey     = KeyBindingDefOf.Misc4;
                command_VerbTarget.drawRadius = false;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    command_VerbTarget.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }

                yield return(command_VerbTarget);
            }
            if (this.forcedTarget.IsValid)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandStopForceAttack".Translate();
                command_Action.defaultDesc  = "CommandStopForceAttackDesc".Translate();
                command_Action.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt", true);

                command_Action.action = delegate()
                {
                    this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    command_Action.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                command_Action.hotKey = KeyBindingDefOf.Misc5;
                yield return(command_Action);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate()
                    {
                        this.holdFire = !this.holdFire;
                        if (this.holdFire)
                        {
                            this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.holdFire)
                });
            }
            yield break;
            yield break;
        }
Esempio n. 16
0
 protected void DrawEquipmentIcon(Rect rect, EquipmentDatabaseEntry entry)
 {
     GUI.color = entry.color;
     if (entry.thing == null)
     {
         // EdB: Inline copy of static Widgets.ThingIcon(Rect, ThingDef) with the selected
         // color based on the stuff.
         GUI.color = entry.color;
         // EdB: Inline copy of static private method with modifications to keep scaled icons within the
         // bounds of the specified Rect and to draw them using the stuff color.
         //Widgets.ThingIconWorker(rect, thing.def, thingDef.uiIcon);
         float num         = GenUI.IconDrawScale(entry.def);
         Rect  resizedRect = rect;
         if (num != 1f)
         {
             // For items that are going to scale out of the bounds of the icon rect, we need to shrink
             // the bounds a little.
             if (num > 1)
             {
                 resizedRect = rect.ContractedBy(4);
             }
             resizedRect.width  *= num;
             resizedRect.height *= num;
             resizedRect.center  = rect.center;
         }
         GUI.DrawTexture(resizedRect, entry.def.uiIcon);
         GUI.color = Color.white;
     }
     else
     {
         // EdB: Inline copy of static Widgets.ThingIcon(Rect, Thing) with graphics switched to show a side view
         // instead of a front view.
         Thing thing = entry.thing;
         GUI.color = thing.DrawColor;
         Texture resolvedIcon;
         if (!thing.def.uiIconPath.NullOrEmpty())
         {
             resolvedIcon = thing.def.uiIcon;
         }
         else if (thing is Pawn)
         {
             Pawn pawn = (Pawn)thing;
             if (!pawn.Drawer.renderer.graphics.AllResolved)
             {
                 pawn.Drawer.renderer.graphics.ResolveAllGraphics();
             }
             Material matSingle = pawn.Drawer.renderer.graphics.nakedGraphic.MatSide;
             resolvedIcon = matSingle.mainTexture;
             GUI.color    = matSingle.color;
         }
         else
         {
             resolvedIcon = thing.Graphic.ExtractInnerGraphicFor(thing).MatSide.mainTexture;
         }
         // EdB: Inline copy of static private method.
         //Widgets.ThingIconWorker(rect, thing.def, resolvedIcon);
         float num = GenUI.IconDrawScale(thing.def);
         if (num != 1f)
         {
             Vector2 center = rect.center;
             rect.width  *= num;
             rect.height *= num;
             rect.center  = center;
         }
         GUI.DrawTexture(rect, resolvedIcon);
     }
     GUI.color = Color.white;
 }
Esempio n. 17
0
        public void DrawDetailedLegend(Rect canvas, ref Vector2 scrollPos, int?max, bool positiveOnly = false,
                                       bool negativeOnly = false)
        {
            // set sign
            int sign = negativeOnly ? -1 : 1;

            List <Chapter> ChaptersOrdered = _chapters
                                             .Where(chapter => !positiveOnly || chapter.pages[periodShown].Any(i => i > 0))
                                             .Where(chapter => !negativeOnly || chapter.pages[periodShown].Any(i => i < 0))
                                             .OrderByDescending(chapter => chapter.Last(periodShown) * sign).ToList();

            // get out early if no chapters.
            if (ChaptersOrdered.Count == 0)
            {
                GUI.DrawTexture(canvas.ContractedBy(Utilities.Margin), Resources.SlightlyDarkBackground);
                Utilities.Label(canvas, "FM.HistoryNoChapters".Translate(), null, TextAnchor.MiddleCenter,
                                color: Color.grey);
                return;
            }

            // max
            float _max = max ?? (DrawMaxMarkers
                                      ? ChaptersOrdered.Max(chapter => chapter.TrueMax)
                                      : ChaptersOrdered.FirstOrDefault()?.Last(periodShown) * sign)
                         ?? 0;

            // cell height
            var height    = 30f;
            var barHeight = 18f;

            // n rows
            int n = ChaptersOrdered.Count;

            // scrolling region
            Rect viewRect = canvas;

            viewRect.height = n * height;
            if (viewRect.height > canvas.height)
            {
                viewRect.width -= 16f + Utilities.Margin;
                canvas.width   -= Utilities.Margin;
                canvas.height  -= 1f;
            }
            Widgets.BeginScrollView(canvas, ref scrollPos, viewRect);
            for (var i = 0; i < n; i++)
            {
                // set up rects
                var  row  = new Rect(0f, height * i, viewRect.width, height);
                Rect icon = new Rect(Utilities.Margin, height * i, height, height).ContractedBy(Utilities.Margin / 2f);
                // icon is square, size defined by height.
                var bar = new Rect(Utilities.Margin + height, height * i, viewRect.width - height - Utilities.Margin,
                                   height);

                // if icons should not be drawn make the bar full size.
                if (!DrawIcons)
                {
                    bar.xMin -= height + Utilities.Margin;
                }

                // bar details.
                Rect  barBox   = bar.ContractedBy((height - barHeight) / 2f);
                Rect  barFill  = barBox.ContractedBy(2f);
                float maxWidth = barFill.width;
                if (MaxPerChapter)
                {
                    barFill.width *= ChaptersOrdered[i].Last(periodShown) * sign / (float)ChaptersOrdered[i].TrueMax;
                }
                else
                {
                    barFill.width *= ChaptersOrdered[i].Last(periodShown) * sign / _max;
                }

                GUI.BeginGroup(viewRect);

                // if DrawIcons and a thing is set, draw the icon.
                ThingDef thing = ChaptersOrdered[i].ThingCount.thingDef;
                if (DrawIcons && thing != null)
                {
                    // draw the icon in correct proportions
                    float proportion = GenUI.IconDrawScale(thing);
                    Widgets.DrawTextureFitted(icon, thing.uiIcon, proportion);

                    // draw counts in upper left corner
                    if (DrawCounts)
                    {
                        Utilities.LabelOutline(icon, ChaptersOrdered[i].ThingCount.count.ToString(), null,
                                               TextAnchor.UpperLeft, 0f, 0f, GameFont.Tiny, Color.white, Color.black);
                    }
                }

                // if desired, draw ghost bar
                if (DrawMaxMarkers)
                {
                    Rect ghostBarFill = barFill;
                    ghostBarFill.width = MaxPerChapter ? maxWidth : maxWidth * (ChaptersOrdered[i].TrueMax / _max);
                    GUI.color          = new Color(1f, 1f, 1f, .2f);
                    GUI.DrawTexture(ghostBarFill, ChaptersOrdered[i].Texture);   // coloured texture
                    GUI.color = Color.white;
                }

                // draw the main bar.
                GUI.DrawTexture(barBox, Resources.SlightlyDarkBackground);
                GUI.DrawTexture(barFill, ChaptersOrdered[i].Texture); // coloured texture
                GUI.DrawTexture(barFill, Resources.BarShader);        // slightly fancy overlay (emboss).

                // draw on bar info
                if (DrawInfoInBar)
                {
                    string info = ChaptersOrdered[i].label + ": " +
                                  FormatCount(ChaptersOrdered[i].Last(periodShown) * sign);

                    if (DrawMaxMarkers)
                    {
                        info += " / " + FormatCount(ChaptersOrdered[i].TrueMax);
                    }

                    // offset label a bit downwards and to the right
                    Rect rowInfoRect = row;
                    rowInfoRect.y += 3f;
                    rowInfoRect.x += Utilities.Margin * 2;

                    // x offset
                    float xOffset = DrawIcons && thing != null ? height + Utilities.Margin * 2 : Utilities.Margin * 2;

                    Utilities.LabelOutline(rowInfoRect, info, null, TextAnchor.MiddleLeft, xOffset, 0f, GameFont.Tiny,
                                           Color.white, Color.black);
                }

                // are we currently showing this line?
                bool shown = _chaptersShown.Contains(ChaptersOrdered[i]);

                // tooltip on entire row
                string tooltip = ChaptersOrdered[i].label + ": " +
                                 FormatCount(Mathf.Abs(ChaptersOrdered[i].Last(periodShown)));
                tooltip += "FM.HistoryClickToEnable".Translate(shown ? "hide" : "show", ChaptersOrdered[i].label);
                TooltipHandler.TipRegion(row, tooltip);

                // handle input
                if (Widgets.ButtonInvisible(row))
                {
                    if (Event.current.button == 0)
                    {
                        if (shown)
                        {
                            _chaptersShown.Remove(ChaptersOrdered[i]);
                        }
                        else
                        {
                            _chaptersShown.Add(ChaptersOrdered[i]);
                        }
                    }
                    else if (Event.current.button == 1)
                    {
                        _chaptersShown.Clear();
                        _chaptersShown.Add(ChaptersOrdered[i]);
                    }
                }

                // UI feedback for disabled row
                if (!shown)
                {
                    GUI.DrawTexture(row, Resources.SlightlyDarkBackground);
                }

                GUI.EndGroup();
            }

            Widgets.EndScrollView();
        }
Esempio n. 18
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())
            {
                yield return(c);
            }
            if (this.CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    action = delegate
                    {
                        this.$this.ExtractShell();
                    }
                });
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget();
                attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                attack.verb   = this.AttackVerb;
                attack.hotKey = KeyBindingDefOf.Misc4;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                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.$this.ResetForcedTarget();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        this.$this.holdFire = !this.$this.holdFire;
                        if (this.$this.holdFire)
                        {
                            this.$this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.$this.holdFire)
                });
            }
        }
Esempio n. 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);
        }
Esempio n. 20
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 (CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = gun.TryGetComp <CompChangeableProjectile>();
                yield return((Gizmo) new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    action = delegate
                    {
                        ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_018d: stateMachine*/)._0024this.ExtractShell();
                    }
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget
                {
                    defaultLabel = "CommandSetForceAttackTarget".Translate(),
                    defaultDesc  = "CommandSetForceAttackTargetDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack"),
                    verb         = AttackVerb,
                    hotKey       = KeyBindingDefOf.Misc4
                };
                if (base.Spawned && IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return((Gizmo)attack);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (forcedTarget.IsValid)
            {
                Command_Action stop = new Command_Action
                {
                    defaultLabel = "CommandStopForceAttack".Translate(),
                    defaultDesc  = "CommandStopForceAttackDesc".Translate(),
                    icon         = ContentFinder <Texture2D> .Get("UI/Commands/Halt"),
                    action       = delegate
                    {
                        ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0333: stateMachine*/)._0024this.ResetForcedTarget();
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                    }
                };
                if (!forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return((Gizmo)stop);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (CanToggleHoldFire)
            {
                yield return((Gizmo) new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire"),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.holdFire = !((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.holdFire;
                        if (((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.holdFire)
                        {
                            ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_040f: stateMachine*/)._0024this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0426: stateMachine*/)._0024this.holdFire)
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            yield break;
IL_0460:
            /*Error near IL_0461: Unexpected return in MoveNext()*/;
        }
Esempio n. 21
0
        public static PurposeInfo Make(LocalTargetInfo targetInfo)
        {
            //reports of nullrefs in here for somereason.
            try
            {
                PurposeInfo purposeInfo = new PurposeInfo();
                if (targetInfo.IsValid)
                {
                    purposeInfo.pos = targetInfo.CenterVector3;
                }
                if (targetInfo.Thing is Thing target)
                {
                    target = MinifyUtility.GetInnerIfMinified(target);
                    BuildableDef def = target.def;

                    purposeInfo.pos   = target.DrawPos;
                    purposeInfo.color = target.DrawColor;

                    if (target is Pawn || target is Corpse)
                    {
                        Pawn pawn = target as Pawn;
                        if (pawn == null)
                        {
                            pawn = ((Corpse)target).InnerPawn;
                        }
                        if (!pawn.RaceProps.Humanlike)
                        {
                            //This seems unnecessary
                            //if (!pawn.Drawer.renderer.graphics.AllResolved)
                            //{
                            //	pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                            //}
                            Material matSingle = pawn.Drawer.renderer.graphics.nakedGraphic.MatSingle;
                            purposeInfo.icon  = matSingle.mainTexture;
                            purposeInfo.color = matSingle.color;
                        }
                        else
                        {
                            purposeInfo.icon = PortraitsCache.Get(pawn, Vector2.one * Gizmo.Height, Rot4.South, cameraZoom: 1.5f);
                        }
                        purposeInfo.proportions = new Vector2(purposeInfo.icon.width, purposeInfo.icon.height);
                    }
                    else
                    {
                        if (target is IConstructible buildThing)
                        {
                            def = target.def.entityDefToBuild;
                            if (buildThing.EntityToBuildStuff() != null)
                            {
                                purposeInfo.color = buildThing.EntityToBuildStuff().stuffProps.color;
                            }
                            else
                            {
                                purposeInfo.color = def.uiIconColor;
                            }
                        }

                        purposeInfo.icon = def.uiIcon;

                        if (def is ThingDef td)
                        {
                            purposeInfo.proportions = td.graphicData.drawSize;
                            purposeInfo.scale       = GenUI.IconDrawScale(td);
                        }

                        if (def is TerrainDef)
                        {
                            //private static readonly Vector2 TerrainTextureCroppedSize = new Vector2(64f, 64f);
                            purposeInfo.texCoords = new Rect(0f, 0f, 64f / purposeInfo.icon.width, 64f / purposeInfo.icon.height);
                        }
                        else if (def.uiIconPath.NullOrEmpty())
                        {
                            Material iconMat = def.graphic.MatSingle;
                            purposeInfo.texCoords = new Rect(iconMat.mainTextureOffset, iconMat.mainTextureScale);
                        }
                    }
                }
                return(purposeInfo);
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Draw extra information on GUI for Transferable <paramref name="trad"/>
        /// </summary>
        /// <param name="trad"></param>
        /// <param name="idRect"></param>
        /// <param name="labelColor"></param>
        public static void DrawVehicleTransferableInfo(Transferable trad, Rect idRect, Color labelColor)
        {
            if (!trad.HasAnyThing && trad.IsThing)
            {
                return;
            }
            if (Mouse.IsOver(idRect))
            {
                Widgets.DrawHighlight(idRect);
            }
            Rect rect = new Rect(0f, 0f, 27f, 27f);

            //Draw Vehicle Icon
            if (trad.AnyThing is VehiclePawn vehicle)
            {
                try
                {
                    Texture2D vehicleIcon    = VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.East);
                    Rect      texCoords      = new Rect(0, 0, 1, 1);
                    Vector2   texProportions = vehicle.VehicleDef.graphicData.drawSize;
                    float     x = texProportions.x;
                    texProportions.x = texProportions.y;
                    texProportions.y = x;
                    Widgets.DrawTextureFitted(rect, vehicleIcon, GenUI.IconDrawScale(vehicle.VehicleDef), texProportions,
                                              texCoords, 0, vehicle.VehicleGraphic.MatAt(Rot8.East, vehicle.pattern));
                    if (vehicle.CompCannons is CompCannons comp)
                    {
                        //REDO
                        //foreach (VehicleTurret turret in comp.Cannons)
                        //{
                        //	if (turret.NoGraphic)
                        //	{
                        //		continue;
                        //	}
                        //	Vector2 drawSize = turret.turretDef.graphicData.drawSize;
                        //	//Rect turretRect = new Rect(0, 0, rect.width / drawSize.x,);
                        //	Widgets.DrawTextureFitted(rect, turret.CannonTexture, 1, drawSize, texCoords, Rot8.East.AsAngle + turret.defaultAngleRotated, turret.CannonMaterial);
                        //}
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce($"Unable to draw {vehicle.Label} for vehicle transferable item. Exception = \"{ex.Message}\"", vehicle.GetHashCode() ^ "TransferableIcon".GetHashCode());
                }
            }

            if (trad.IsThing)
            {
                //Widgets.InfoCardButton(40f, 0f, trad.AnyThing);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect2 = new Rect(40f, 0f, idRect.width - 80f, idRect.height);

            Text.WordWrap = false;
            GUI.color     = labelColor;
            Widgets.Label(rect2, trad.LabelCap);
            GUI.color     = Color.white;
            Text.WordWrap = true;
            if (Mouse.IsOver(idRect))
            {
                Transferable localTrad = trad;
                TooltipHandler.TipRegion(idRect, new TipSignal(delegate()
                {
                    if (!localTrad.HasAnyThing && localTrad.IsThing)
                    {
                        return(string.Empty);
                    }
                    string text           = localTrad.LabelCap;
                    string tipDescription = localTrad.TipDescription;
                    if (!tipDescription.NullOrEmpty())
                    {
                        text = text + ": " + tipDescription;
                    }
                    return(text);
                }, localTrad.GetHashCode()));
            }
        }
Esempio n. 23
0
        private void DrawVehicleSelect(Rect rect)
        {
            Text.Anchor = TextAnchor.MiddleLeft;

            Rect viewRect = new Rect(0f, rect.yMin, rect.width - ButtonPadding * 2, rect.yMax);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true);
            float num  = scrollPosition.y - 30f;
            float num2 = scrollPosition.y + rect.height;
            float num3 = 30f;

            for (int i = 0; i < availableVehicles.Count; i++)
            {
                VehiclePawn vehicle = availableVehicles[i];

                Rect iconRect = new Rect(5f, num3 + 5f, 30f, 30f);
                Rect rowRect  = new Rect(iconRect.x, iconRect.y, rect.width, 30f);

                if (i % 2 == 1)
                {
                    Widgets.DrawLightHighlight(rowRect);
                }
                rowRect.x = iconRect.width + 10f;

                if (vehicle.VehicleDef.properties.generateThingIcon)
                {
                    Rect    texCoords      = new Rect(0, 0, 1, 1);
                    Vector2 texProportions = vehicle.VehicleDef.graphicData.drawSize;
                    float   x = texProportions.x;
                    texProportions.x = texProportions.y;
                    texProportions.y = x;
                    Widgets.DrawTextureFitted(iconRect, VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.East), GenUI.IconDrawScale(vehicle.VehicleDef), texProportions,
                                              texCoords, 0, vehicle.VehicleGraphic.MatAt(Rot8.East, vehicle.pattern));
                }
                else
                {
                    Widgets.ButtonImageFitted(iconRect, VehicleTex.CachedTextureIcons[vehicle.VehicleDef]);
                }

                Widgets.Label(rowRect, vehicle.LabelShortCap);

                bool flag = storedVehicles.Contains(vehicle);

                Vector2 checkposition = new Vector2(rect.width - iconRect.width * 1.5f, rowRect.y + 5f);
                Widgets.Checkbox(checkposition, ref flag);
                if (flag && !storedVehicles.Contains(vehicle))
                {
                    storedVehicles.Add(vehicle);
                }
                else if (!flag && storedVehicles.Contains(vehicle))
                {
                    storedVehicles.Remove(vehicle);
                }

                num3 += rowRect.height;
            }

            Widgets.EndScrollView();
            Text.Anchor = TextAnchor.UpperLeft;
        }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo c in base.GetGizmos())             // added
            {
                yield return(c);
            }

            // added
            if (this.def.defName == "AvaliTurretLarge")
            {
                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(-1f);
                    },
                    defaultLabel = "-1",
                    defaultDesc = "CommandDecreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc5,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DecreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(-0.1f);
                    },
                    defaultLabel = "-0.1",
                    defaultDesc = "CommandDecreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc4,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DecreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        turretBurstCooldownTime = defaultDelay;
                        def.building.turretBurstCooldownTime = turretBurstCooldownTime;
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                        MoteMaker.ThrowText(this.TrueCenter() + new Vector3(0.5f, 0f, 0.5f), this.Map, turretBurstCooldownTime.ToString(), Color.white, -1f);
                    },
                    defaultLabel = "CommandDefaultTurretShootDelay".Translate(),
                    defaultDesc = "CommandDefaultTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc1,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/DefaultDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(0.1f);
                    },
                    defaultLabel = "+0.1",
                    defaultDesc = "CommandIncreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc2,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/IncreaseDelay", true)
                });

                yield return(new Command_Action
                {
                    action = delegate
                    {
                        InterfaceChangeTurretShootDelay(1f);
                    },
                    defaultLabel = "+1",
                    defaultDesc = "CommandIncreaseTurretShootDelayDesc".Translate(),
                    hotKey = KeyBindingDefOf.Misc3,
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/IncreaseDelay", true)
                });
            }
            // added

            if (this.CanExtractShell)
            {
                CompChangeableProjectile changeableProjectile = this.gun.TryGetComp <CompChangeableProjectile>();
                yield return(new Command_Action
                {
                    defaultLabel = "CommandExtractShell".Translate(),
                    defaultDesc = "CommandExtractShellDesc".Translate(),
                    icon = changeableProjectile.LoadedShell.uiIcon,
                    iconAngle = changeableProjectile.LoadedShell.uiIconAngle,
                    iconOffset = changeableProjectile.LoadedShell.uiIconOffset,
                    iconDrawScale = GenUI.IconDrawScale(changeableProjectile.LoadedShell),
                    alsoClickIfOtherInGroupClicked = false,
                    action = delegate
                    {
                        GenPlace.TryPlaceThing(changeableProjectile.RemoveShell(), this.Position, this.Map, ThingPlaceMode.Near, null, null);
                    }
                });
            }
            if (this.CanSetForcedTarget)
            {
                Command_VerbTarget attack = new Command_VerbTarget();
                attack.defaultLabel = "CommandSetForceAttackTarget".Translate();
                attack.defaultDesc  = "CommandSetForceAttackTargetDesc".Translate();
                attack.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Attack", true);

                attack.verb   = this.AttackVerb;
                attack.hotKey = KeyBindingDefOf.Misc4;
                if (base.Spawned && this.IsMortarOrProjectileFliesOverhead && base.Position.Roofed(base.Map))
                {
                    attack.Disable("CannotFire".Translate() + ": " + "Roofed".Translate().CapitalizeFirst());
                }
                yield return(attack);
            }
            if (this.forcedTarget.IsValid)
            {
                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.Tick_Low.PlayOneShotOnCamera(null);
                };
                if (!this.forcedTarget.IsValid)
                {
                    stop.Disable("CommandStopAttackFailNotForceAttacking".Translate());
                }
                stop.hotKey = KeyBindingDefOf.Misc5;
                yield return(stop);
            }
            if (this.CanToggleHoldFire)
            {
                yield return(new Command_Toggle
                {
                    defaultLabel = "CommandHoldFire".Translate(),
                    defaultDesc = "CommandHoldFireDesc".Translate(),
                    icon = ContentFinder <Texture2D> .Get("UI/Commands/HoldFire", true),
                    hotKey = KeyBindingDefOf.Misc6,
                    toggleAction = delegate
                    {
                        this.holdFire = !this.holdFire;
                        if (this.holdFire)
                        {
                            this.ResetForcedTarget();
                        }
                    },
                    isActive = (() => this.holdFire)
                });
            }
            yield break;
        }