예제 #1
0
        private void DropBomb()
        {
            for (int i = 0; i < (bombType == BombingType.precise ? this.precisionBombingNumBombs : 1); ++i)
            {
                if (innerContainer.Any(x => ((ActiveDropPod)x)?.Contents.innerContainer.Any(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)) ?? false))
                {
                    ActiveDropPod srts = (ActiveDropPod)innerContainer.First();

                    Thing thing = srts?.Contents.innerContainer.FirstOrDefault(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName));
                    if (thing is null)
                    {
                        return;
                    }

                    Thing thing2 = srts?.Contents.innerContainer.Take(thing, 1);

                    IntVec3 bombPos = bombCells[0];
                    if (bombType == BombingType.carpet)
                    {
                        bombCells.RemoveAt(0);
                    }
                    int timerTickExplode = 20 + Rand.Range(0, 5); //Change later to allow release timer
                    if (SRTSHelper.CEModLoaded)
                    {
                        goto Block_CEPatched;
                    }
                    FallingBomb bombThing = new FallingBomb(thing2, thing2.TryGetComp <CompExplosive>(), this.Map, this.def.skyfaller.shadow);
                    bombThing.HitPoints      = int.MaxValue;
                    bombThing.ticksRemaining = timerTickExplode;

                    IntVec3 c = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                 where x.InBounds(this.Map)
                                 select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);
                    bombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c) * -10);
                    bombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c) / bombThing.ticksRemaining;
                    Thing t = GenSpawn.Spawn(bombThing, c, this.Map);
                    GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(t, thing2.TryGetComp <CompExplosive>().Props.explosiveDamageType, null);
                    continue;

                    Block_CEPatched :;
                    ThingComp     CEComp      = (thing2 as ThingWithComps)?.AllComps.Find(x => x.GetType().Name == "CompExplosiveCE");
                    FallingBombCE CEbombThing = new FallingBombCE(thing2, CEComp.props, CEComp, this.Map, this.def.skyfaller.shadow);
                    CEbombThing.HitPoints      = int.MaxValue;
                    CEbombThing.ticksRemaining = timerTickExplode;
                    IntVec3 c2 = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                  where x.InBounds(this.Map)
                                  select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);
                    CEbombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c2) * -10);
                    CEbombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c2) / CEbombThing.ticksRemaining;
                    Thing CEt = GenSpawn.Spawn(CEbombThing, c2, this.Map);
                    //GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(CEt, DamageDefOf., null); /*Is GenExplosion CE compatible?*/
                }
            }
            if (bombType == BombingType.precise && bombCells.Any())
            {
                bombCells.Clear();
            }
        }
예제 #2
0
 public override void CompTick()
 {
     base.CompTick();
     if (this.TargetLured)
     {
         if (SPExtra.Distance(this.Pawn.Position, targetHunted.Position) <= this.Props.directAttackRange)
         {
             this.targetLured = false;
         }
     }
 }
예제 #3
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     if (!respawningAfterLoad)
     {
         this.ticksToExit = Mathf.CeilToInt((float)SPExtra.Distance(new IntVec3(map.Size.x / 2, map.Size.y, map.Size.z / 2), this.Position) * 2 / this.speed);
     }
     if (sound != null)
     {
         sound.PlayOneShotOnCamera(this.Map);
     }
 }
예제 #4
0
        public static IntVec3 RandomEdgeCell(Rot4 dir, Map map, Predicate <IntVec3> validator)
        {
            List <IntVec3> cellsToCheck = dir.IsValid ? CellRect.WholeMap(map).GetEdgeCells(dir).ToList() : CellRect.WholeMap(map).EdgeCells.ToList();

            for (;;)
            {
                IntVec3 rCell = SPExtra.PopRandom(ref cellsToCheck);
                if (validator(rCell))
                {
                    return(rCell);
                }
                if (cellsToCheck.Count <= 0)
                {
                    Log.Warning("Failed to find edge cell at " + dir.AsInt);
                    break;
                }
            }
            return(CellFinder.RandomEdgeCell(map));
        }
예제 #5
0
        public static IntVec3 RandomEdgeCell(Rot4 dir, Map map, Predicate <IntVec3> validator, List <IntVec3> excludeCells = null, Pawn pawn = null)
        {
            List <IntVec3> cellsToCheck = dir.IsValid ? CellRect.WholeMap(map).GetEdgeCells(dir).ToList() : CellRect.WholeMap(map).EdgeCells.ToList();

            cellsToCheck.Shuffle();
            for (;;)
            {
                IntVec3 rCell = pawn is null?SPExtra.PopRandom(ref cellsToCheck) : pawn.ClampToMap(SPExtra.PopRandom(ref cellsToCheck), map, pawn.def.size.z > 4 ? (int)Math.Ceiling(pawn.def.size.z / 2d) : 3);

                if (validator(rCell) && (excludeCells is null || !excludeCells.Contains(rCell)) && (pawn is null || pawn.PawnOccupiedCells(rCell, dir.Opposite).All(x => validator(x))))
                {
                    return(rCell);
                }
                if (cellsToCheck.Count <= 0)
                {
                    Log.Warning("Failed to find edge cell at " + dir.AsInt);
                    break;
                }
            }
            return(CellFinder.RandomEdgeCell(map));
        }
예제 #6
0
        public static int PushSettlementToCoast(int tileID, Faction faction)
        {
            List <int>  neighbors = new List <int>();
            Stack <int> stack     = new Stack <int>();

            stack.Push(tileID);
            Stack <int> stackFull        = stack;
            List <int>  newTilesSearch   = new List <int>();
            List <int>  allSearchedTiles = new List <int>()
            {
                tileID
            };
            int searchTile;
            int searchedRadius = 0;

            if (Find.World.CoastDirectionAt(tileID).IsValid)
            {
                if (Find.WorldGrid[tileID].biome.canBuildBase && !(faction is null))
                {
                    ShipHarmony.tiles.Add(new Pair <int, int>(tileID, 0));
                }
                return(tileID);
            }

            while (searchedRadius < RimShipMod.mod.settings.CoastRadius)
            {
                for (int j = 0; j < stackFull.Count; j++)
                {
                    searchTile = stack.Pop();
                    SPExtra.GetList <int>(Find.WorldGrid.tileIDToNeighbors_offsets, Find.WorldGrid.tileIDToNeighbors_values, searchTile, neighbors);
                    int count = neighbors.Count;
                    for (int i = 0; i < count; i++)
                    {
                        if (allSearchedTiles.Any(x => x == neighbors[i]))
                        {
                            continue;
                        }
                        newTilesSearch.Add(neighbors[i]);
                        allSearchedTiles.Add(neighbors[i]);
                        if (Find.World.CoastDirectionAt(neighbors[i]).IsValid)
                        {
                            if (Find.WorldGrid[neighbors[i]].biome.canBuildBase && Find.WorldGrid[neighbors[i]].biome.implemented && Find.WorldGrid[neighbors[i]].hilliness != Hilliness.Impassable)
                            {
                                if (ShipHarmony.debug && !(faction is null))
                                {
                                    DebugDrawSettlement(tileID, neighbors[i]);
                                }
                                if (!(faction is null))
                                {
                                    ShipHarmony.tiles.Add(new Pair <int, int>(neighbors[i], searchedRadius));
                                }
                                return(neighbors[i]);
                            }
                        }
                    }
                }
                stack.Clear();
                stack     = new Stack <int>(newTilesSearch);
                stackFull = stack;
                newTilesSearch.Clear();
                searchedRadius++;
            }
            return(tileID);
        }
예제 #7
0
        public static bool TryFindRandomReachableCellNear(IntVec3 root, Map map, float radius, TraverseParms traverseParms, Predicate <IntVec3> validator, out IntVec3 result,
                                                          Predicate <WaterRegion> regionValidator, int maxRegions = 999999)
        {
            if (map is null)
            {
                Log.ErrorOnce("Tried to find reachable cell using SPExtended in a null map", 61037855, false);
                result = IntVec3.Invalid;
                return(false);
            }
            WaterRegion region = WaterGridsUtility.GetRegion(root, map, RegionType.Set_Passable);

            if (region is null)
            {
                result = IntVec3.Invalid;
                return(false);
            }
            Rot4 dir = Find.World.CoastDirectionAt(map.Tile).IsValid ? Find.World.CoastDirectionAt(map.Tile) : Find.WorldGrid[map.Tile].Rivers?.Any() ?? false?SPExtra.RiverDirection(map) : Rot4.Invalid;

            result = CellFinderExtended.RandomEdgeCell(dir, map, (IntVec3 c) => GenGridShips.Standable(c, map, MapExtensionUtility.GetExtensionToMap(map)) && !c.Fogged(map));
            return(true);
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), GizmoSize);
            bool flag = false;

            Rect      gizmoRect = new Rect(rect.x + 3.5f, rect.y, rect.width / 2, rect.height).ContractedBy(7);
            Texture2D badTex    = icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            var gizmoColor  = GUI.color;
            var ammoColor   = GUI.color;
            var reloadColor = GUI.color;


            Material material = (!disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, AmmoBG, material, default);
            Rect ammoRect   = new Rect(gizmoRect.x + gizmoRect.width + 7, gizmoRect.y, gizmoRect.width, (gizmoRect.height / 2) - 3.5f);
            Rect reloadRect = new Rect(gizmoRect.x + gizmoRect.width + 7, ammoRect.y + ammoRect.height + 7, gizmoRect.width, (gizmoRect.height / 2) - 3.5f);

            MouseoverSounds.DoRegion(gizmoRect, SoundDefOf.Mouseover_Command);
            MouseoverSounds.DoRegion(ammoRect, SoundDefOf.Mouseover_Command);
            MouseoverSounds.DoRegion(reloadRect, SoundDefOf.Mouseover_Command);

            if (Mouse.IsOver(gizmoRect))
            {
                flag = true;
                if (!disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            GenUI.DrawTextureWithMaterial(gizmoRect, BGTex, material, default);
            GUI.color = gizmoColor;
            if (cannon.cannonDef.ammoAllowed?.Any() ?? false)
            {
                if (Mouse.IsOver(ammoRect))
                {
                    flag = true;
                    if (!disabled)
                    {
                        GUI.color = GenUI.MouseoverColor;
                    }
                }
                GenUI.DrawTextureWithMaterial(ammoRect, BGTex, material, default);
                GUI.color = ammoColor;
                if (Mouse.IsOver(reloadRect))
                {
                    flag = true;
                    if (!disabled)
                    {
                        GUI.color = GenUI.MouseoverColor;
                    }
                }
                GenUI.DrawTextureWithMaterial(reloadRect, BGTex, material, default);
                GUI.color = reloadColor;
                Rect reloadLabel = new Rect(reloadRect.x + 10, reloadRect.y + reloadRect.height / 4, reloadRect.width - 10, reloadRect.height / 1.5f);
                Widgets.Label(reloadLabel, "Extract".Translate());
            }
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(gizmoRect, badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords, iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            bool    flag3   = false;
            bool    flag4   = false;
            KeyCode keyCode = (hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(gizmoRect, false))
            {
                flag2 = true;
            }
            if (Widgets.ButtonInvisible(ammoRect, false))
            {
                flag3 = true;
            }
            if (Widgets.ButtonInvisible(reloadRect, false))
            {
                flag4 = false;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(gizmoRect, tip);
            }
            if (cannon.cooldownTicks > 0)
            {
                float percent = cannon.cooldownTicks / (float)cannon.MaxTicks;
                SPExtra.VerticalFillableBar(gizmoRect, percent, FillableBar, ClearBar);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(gizmoRect)))
            {
                UIHighlighter.HighlightOpportunity(gizmoRect, HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            if (flag3)
            {
                //Change later
                cannon.ReloadCannon(cannon.pawn.inventory.innerContainer.FirstOrDefault(x => cannon.cannonDef.ammoAllowed.Contains(x.def)).def);
            }
            if (flag4)
            {
                cannon.TryRemoveShell();
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
예제 #9
0
        private bool TooCloseToVoice()
        {
            if (targetHunted is null)
            {
                this.ResetVoices();
                return(true);
            }
            else if (targetHunted.Downed || targetHunted.Dead)
            {
                return(true);
            }

            return(targetHunted.CanSee(this.Pawn) && this.WithinVoiceRange(this.targetHunted.Position) && SPExtra.Distance(this.Pawn.Position, this.targetHunted.Position) <= this.Props.directAttackRange);
        }
예제 #10
0
 private bool WithinVoiceRange(IntVec3 targetPos)
 {
     return(SPExtra.Distance(this.Pawn.Position, targetPos) <= this.Props.voiceRange);
 }
예제 #11
0
        private void DropBomb()
        {
            for (int i = 0; i < (bombType == BombingType.precise ? this.precisionBombingNumBombs : 1); ++i)
            {
                if (innerContainer.Any(x => ((ActiveDropPod)x)?.Contents.innerContainer.Any(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)) ?? false))
                {
                    ActiveDropPod srts = (ActiveDropPod)innerContainer.First();

                    Thing thing = srts?.Contents.innerContainer.FirstOrDefault(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName));
                    if (thing is null)
                    {
                        return;
                    }

                    Thing thing2 = srts?.Contents.innerContainer.Take(thing, 1);

                    IntVec3 bombPos = bombCells[0];
                    if (bombType == BombingType.carpet)
                    {
                        bombCells.RemoveAt(0);
                    }
                    int timerTickExplode = 20 + Rand.Range(0, 5); //Change later to allow release timer
                    if (SRTSHelper.CEModLoaded)
                    {
                        goto Block_CEPatched;
                    }
                    FallingBomb bombThing = new FallingBomb(thing2, thing2.TryGetComp <CompExplosive>(), this.Map, this.def.skyfaller.shadow);
                    bombThing.HitPoints      = int.MaxValue;
                    bombThing.ticksRemaining = timerTickExplode;

                    IntVec3 c = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                 where x.InBounds(this.Map)
                                 select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);
                    bombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c) * -10);
                    bombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c) / bombThing.ticksRemaining;
                    Thing t = GenSpawn.Spawn(bombThing, c, this.Map);
                    GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(t, thing2.TryGetComp <CompExplosive>().Props.explosiveDamageType, null);
                    continue;

                    Block_CEPatched :;
                    // Replaced referencing the projectile trough the detonateProjectile property of the item's def with referencing trough AmmoSetDef. The reason is taht not all mortar shells had detonateProjectile. Don't ask how I came up with this.
                    ProjectileCE_Explosive bombCE = (ProjectileCE_Explosive)ThingMaker.MakeThing((thing2.def as AmmoDef).AmmoSetDefs.Find(set => set.ammoTypes.Any()).ammoTypes.Find(link => link.ammo == (thing2.def as AmmoDef)).projectile, null);
                    //ProjectileCE_Explosive bombCE = (ProjectileCE_Explosive)ThingMaker.MakeThing((AccessTools.Field(thing2.def.GetType(), "detonateProjectile").GetValue(thing2.def) as ThingDef), null);

                    /*ThingComp CEComp = (thing2 as ThingWithComps)?.AllComps.Find(x => x.GetType().Name == "CompExplosiveCE");
                     * FallingBombCE CEbombThing = new FallingBombCE(thing2, CEComp.props, CEComp, this.Map, this.def.skyfaller.shadow);
                     * CEbombThing.HitPoints = int.MaxValue;
                     * CEbombThing.ticksRemaining = timerTickExplode;*/
                    IntVec3 c2 = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true)
                                  where x.InBounds(this.Map)
                                  select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f);

                    /*CEbombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c2) * -10);
                     * CEbombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c2) / CEbombThing.ticksRemaining;
                     * Thing CEt = GenSpawn.Spawn(CEbombThing, c2, this.Map);*/
                    //Basically Im stea- "borrrowing" code from Verb_LaunchProjectileCE.
                    GenSpawn.Spawn(bombCE, this.DrawPosCell, this.Map);
                    bombCE.canTargetSelf        = false;
                    bombCE.minCollisionDistance = 1;
                    bombCE.intendedTarget       = null;
                    bombCE.AccuracyFactor       = 1f;
                    bombCE.Launch(this,
                                  this.DrawPosCell.ToIntVec2.ToVector2(),
                                  0f,
                                  this.angle + UnityEngine.Random.Range(-60f, 60f),
                                  5f,
                                  (float)SPExtra.Distance(this.DrawPosCell, c2),
                                  this);
                    //GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(CEt, DamageDefOf., null); /*Is GenExplosion CE compatible?*/
                }
            }
            if (bombType == BombingType.precise && bombCells.Any())
            {
                bombCells.Clear();
            }
        }
예제 #12
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), GizmoSize);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag = true;
                if (!this.disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            Texture2D badTex = this.icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            Material material = (!this.disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, Command.BGTex, material, default(Rect));
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Rect outerRect = rect;

            outerRect.position += new Vector2(this.iconOffset.x * outerRect.size.x, this.iconOffset.y * outerRect.size.y);
            GUI.color           = this.IconDrawColor;
            Widgets.DrawTextureFitted(outerRect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (this.hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = this.LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        this.disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (this.cannon.cooldownTicks > 0)
            {
                float percent = (float)this.cannon.cooldownTicks / (float)this.cannon.MaxTicks;
                SPExtra.VerticalFillableBar(rect, percent, FillableBar, ClearBar);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(this.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(this.TutorTagSelect);
                return(result);
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }