public static void DrawTexture(SpriteBatch sb, CustomEntity ent, Texture2D tex, int frameCount, Color color, float scale, float rotation = 0f, Vector2 origin = default(Vector2))
        {
            var core         = ent.Core;
            var worldScrRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight);

            if (!core.Hitbox.Intersects(worldScrRect))
            {
                return;
            }

            var scrScrPos = core.position - Main.screenPosition;
            var texRect   = new Rectangle(0, 0, tex.Width, tex.Height / frameCount);

            SpriteEffects dir = DrawsInGameEntityComponent.GetOrientation(core);

            sb.Draw(tex, scrScrPos, texRect, color, rotation, origin, scale, dir, 1f);

            if (ModHelpersMod.Instance.Config.DebugModeCustomEntityInfo)
            {
                var rect = new Rectangle(
                    (int)(core.position.X - Main.screenPosition.X - ((float)origin.X * scale)),
                    (int)(core.position.Y - Main.screenPosition.Y - ((float)origin.Y * scale)),
                    (int)((float)core.width * scale),
                    (int)((float)core.height * scale)
                    );
                HudHelpers.DrawBorderedRect(sb, null, Color.Red, rect, 1);
            }
        }
Esempio n. 2
0
        public void Draw(SpriteBatch sb)
        {
            foreach (var elem in this.Elements)
            {
                elem.Recalculate();
            }

            var   boxColor     = new Color(256, 0, 32);
            var   boxEdgeColor = new Color(255, 224, 224);
            float colorMul     = 0.25f;

            if (this.IsHovingBox)
            {
                this.ExtendTextUI.TextColor = Color.White;
                colorMul = 0.3f;
            }
            else
            {
                this.ExtendTextUI.TextColor = AnimatedColors.Air.CurrentColor;
            }

            //var rect = new Rectangle( Main.screenWidth - 252, 4, 248, (this.IsExtended ? 104 : 40) );
            var rect = this.GetInnerBox();

            HudHelpers.DrawBorderedRect(sb, boxColor * colorMul, boxEdgeColor * colorMul, rect, 4);

            if (this.SupportUrlUI != null)
            {
                this.SupportUrlUI.Theme.UrlColor    = Color.Lerp(UITheme.Vanilla.UrlColor, AnimatedColors.Ether.CurrentColor, 0.25f);
                this.SupportUrlUI.Theme.UrlLitColor = Color.Lerp(UITheme.Vanilla.UrlLitColor, AnimatedColors.Strobe.CurrentColor, 0.5f);
                this.SupportUrlUI.Theme.UrlLitColor = Color.Lerp(this.SupportUrlUI.Theme.UrlLitColor, AnimatedColors.DiscoFast.CurrentColor, 0.75f);
                this.SupportUrlUI.RefreshTheme();
            }

            foreach (var elem in this.Elements)
            {
                if (elem is UIWebUrl)
                {
                    continue;
                }
                elem.Draw(sb);
            }
            foreach (var elem in this.Elements.Reverse())
            {
                if (!(elem is UIWebUrl))
                {
                    continue;
                }
                elem.Draw(sb);
            }

            Vector2 bonus = Main.DrawThickCursor(false);

            Main.DrawCursor(bonus, false);
        }
        ////////////////

        public override void Draw(SpriteBatch sb)
        {
            Rectangle rect = this.GetOuterDimensions().ToRectangle();

            rect.X      += 4;
            rect.Y      += 4;
            rect.Width  -= 4;
            rect.Height -= 5;

            HudHelpers.DrawBorderedRect(sb, this.GetBgColor(), this.GetEdgeColor(), rect, 2);

            base.Draw(sb);
        }
Esempio n. 4
0
        public override void PostDraw(SpriteBatch sb, CustomEntity ent)
        {
            var train_comp = ent.GetComponentByType <TrainBehaviorEntityComponent>();
            var mouse_comp = ent.GetComponentByType <TrainMouseInteractionEntityComponent>();

            if (this.IsMinecartIconHovering)
            {
                return;
            }
            if (!mouse_comp.IsMouseHovering)
            {
                return;
            }
            if (train_comp.IsMountedBy != -1)
            {
                return;
            }
            if (ent.MyOwnerPlayerWho != Main.myPlayer)
            {
                return;
            }

            var text_pos = new Vector2(
                Main.mouseX + 16,
                Main.mouseY + 16
                );
            var pos = new Vector2(
                Main.mouseX - this.TrainIcon.Width,
                Main.mouseY - this.TrainIcon.Height
                );
            float         scale = 1.5f + ((this.PulseScaleAnimation > 0 ? this.PulseScaleAnimation : -this.PulseScaleAnimation) / 240f);
            SpriteEffects dir   = DrawsInGameEntityComponent.GetOrientation(ent.Core);

            if (this.PulseScaleAnimation >= 26)
            {
                this.PulseScaleAnimation = -this.PulseScaleAnimation;
            }
            else
            {
                this.PulseScaleAnimation++;
            }

            sb.Draw(this.TrainIcon, pos, null, Color.White, 0f, default(Vector2), scale, dir, 1f);

            HudHelpers.DrawGlowingString(ent.Core.DisplayName, text_pos, 1f);
        }