Esempio n. 1
0
        public void DrawOverlayMap(WormholeModContext ctx, WormholeLink link, SpriteBatch sb)
        {
            var mymod = ctx.MyMod;

            if (!link.IsCharted(Main.LocalPlayer) && !mymod.IsDebugWormholeViewMode())
            {
                return;
            }

            float     scale = Main.mapOverlayScale / 1.5f;
            Texture2D tex   = WormholesUI.Tex;

            Rectangle l_rect = new Rectangle((int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height);
            Rectangle r_rect = new Rectangle((int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height);

            Vector2?l_pos = HudMapHelpers.GetOverlayMapPosition(l_rect);

            if (l_pos != null)
            {
                Color l_color = link.LeftPortal.BaseColor * Main.mapOverlayAlpha;
                sb.Draw(tex, (Vector2)l_pos, this.TexAnim.Frame, l_color, 0f, new Vector2(), scale, SpriteEffects.None, 1f);
            }

            Vector2?r_pos = HudMapHelpers.GetOverlayMapPosition(r_rect);

            if (r_pos != null)
            {
                Color r_color = link.RightPortal.BaseColor * Main.mapOverlayAlpha;
                sb.Draw(tex, (Vector2)r_pos, this.TexAnim.Frame, r_color, 0f, new Vector2(), scale, SpriteEffects.None, 1f);
            }
        }
Esempio n. 2
0
        public void UpdateBehavior(WormholeModContext ctx, Player player)
        {
            if (this.IsClosed)
            {
                return;
            }
            if (Main.myPlayer != player.whoAmI)
            {
                return;
            }

            if (Main.netMode != 2)                  // Not server
            {
                int l_open_anim = this.LeftPortal.GetOpenAnimation();
                int r_open_anim = this.RightPortal.GetOpenAnimation();
                if (l_open_anim > r_open_anim)
                {
                    this.LeftPortal.AnimateOpen(r_open_anim);
                }
                else if (l_open_anim < r_open_anim)
                {
                    this.RightPortal.AnimateOpen(l_open_anim);
                }

                this.LeftPortal.SoundFX(ctx);
                this.RightPortal.SoundFX(ctx);
            }
        }
Esempio n. 3
0
 public void ApplyChaosHit(WormholeModContext ctx)
 {
     if (Main.netMode == 0)                      // Single
     {
         var mngr = ctx.MyMod.GetModWorld <WormholesWorld>().Wormholes;
         mngr.Reroll(this);
     }
     else                        // Non-single
     {
         ClientPacketHandlers.SendWormholeRerollRequestViaClient(ctx.MyMod, this.ID);
     }
 }
Esempio n. 4
0
        private void Teleport(WormholeModContext ctx, Player player, Vector2 dest)
        {
            WormholesPlayer myplayer = player.GetModPlayer <WormholesPlayer>(ctx.MyMod);

            if (myplayer.MyPortal == null || (myplayer.MyPortal != null && this.ID != myplayer.MyPortal.ID))
            {
                myplayer.ChartedLinks.Add(this.ID);
            }

            PlayerHelpers.Teleport(player, dest);

            if (player.FindBuffIndex(88) != -1)
            {
                int def = player.statDefense;
                player.statDefense = 0;
                var dmg = player.Hurt(PlayerDeathReason.ByOther(13), player.statLifeMax2 / 7, 0);
                player.statDefense = def;
            }

            player.AddBuff(164, (int)(60f * 2.5f));      // Distorted
            player.AddBuff(88, 60 * 10);                 // Chaos State

            float vel_x = player.velocity.X * 3;
            float vel_y = player.velocity.Y * 3;

            if (vel_x > 0 && vel_x < 1)
            {
                vel_x = 1;
            }
            else if (vel_x < 0 && vel_x > 1)
            {
                vel_x = -1;
            }
            if (vel_y > 0 && vel_y < 1)
            {
                vel_y = 1;
            }
            else if (vel_y < 0 && vel_y > 1)
            {
                vel_y = -1;
            }

            for (int i = 0; i < 24; i++)
            {
                Dust.NewDust(player.position, player.width, player.height, 245, vel_x, vel_y);
            }

            //Main.PlaySound( 2, player.position, 100 );
            var snd = SoundID.Item100.WithVolume(ctx.MyMod.Config.Data.WormholeEntrySoundVolume);

            Main.PlaySound(snd, player.position);
        }
Esempio n. 5
0
        public void SoundFX(WormholeModContext ctx)
        {
            if (this.IsClosed)
            {
                return;
            }

            // Loop audio
            if (this.SoundLoopTimer++ > 12)
            {
                Main.PlaySound(SoundID.Item24.WithVolume(ctx.MyMod.Config.Data.WormholeSoundVolume), this.Pos);
                this.SoundLoopTimer = 0;
            }
        }
Esempio n. 6
0
        /////////////////

        public void RunAll(WormholeModContext ctx, Player player)
        {
            int who = player.whoAmI;

            if (!this.BlockPortalCountdown.Keys.Contains(who))
            {
                this.BlockPortalCountdown[who] = 0;
            }

            bool         is_upon_a_portal  = false;
            bool         is_upon_my_portal = false;
            int          block_countdown   = this.BlockPortalCountdown[who];
            WormholeLink town_portal       = player.GetModPlayer <WormholesPlayer>(ctx.MyMod).MyPortal;

            if (!ctx.MyMod.Config.Data.DisableNaturalWormholes)
            {
                for (int i = 0; i < this.Links.Count; i++)
                {
                    WormholeLink link = this.Links[i];
                    if (link == null)
                    {
                        break;
                    }

                    link.UpdateInteractions(ctx, player, (block_countdown > 0), out is_upon_a_portal);
                    link.UpdateBehavior(ctx, player);

                    if (is_upon_a_portal)
                    {
                        break;
                    }
                }
            }

            if (town_portal != null)
            {
                town_portal.UpdateInteractions(ctx, player, (block_countdown > 0 || is_upon_a_portal), out is_upon_my_portal);
                town_portal.UpdateBehavior(ctx, player);
            }

            if ((is_upon_a_portal || is_upon_my_portal) && block_countdown == 0)
            {
                this.BlockPortalCountdown[who] = 120;
            }
            if ((!is_upon_a_portal && !is_upon_my_portal && block_countdown > 0) || block_countdown > 1)
            {
                this.BlockPortalCountdown[who]--;
            }
        }
Esempio n. 7
0
        public void TeleportToRight(WormholeModContext ctx, Player player)
        {
            // Clients and single only
            if (Main.netMode == 2)
            {
                return;
            }
            if (this.IsClosed)
            {
                return;
            }

            Vector2 dest = new Vector2(
                this.RightPortal.Pos.X + (WormholePortal.Width / 2) - player.width,
                this.RightPortal.Pos.Y + (WormholePortal.Height / 2) - player.height);

            this.Teleport(ctx, player, dest);
        }
Esempio n. 8
0
        ////////////////

        public void DrawForMe(WormholeModContext ctx)
        {
            // Clients and single only
            if (Main.netMode == 2)
            {
                return;
            }
            if (this.IsClosed)
            {
                return;
            }

            this.LeftPortal.DrawForMe();
            this.RightPortal.DrawForMe();

            this.LeftPortal.LightFX(ctx);
            this.RightPortal.LightFX(ctx);
        }
Esempio n. 9
0
        public void DrawAll(WormholeModContext ctx, WormholeLink town_portal)
        {
            if (!ctx.MyMod.Config.Data.DisableNaturalWormholes)
            {
                for (int i = 0; i < this.Links.Count; i++)
                {
                    WormholeLink link = this.Links[i];
                    if (link == null)
                    {
                        break;
                    }

                    link.DrawForMe(ctx);
                }
            }
            if (town_portal != null)
            {
                town_portal.DrawForMe(ctx);
            }
        }
Esempio n. 10
0
        public void LightFX(WormholeModContext ctx)
        {
            if (this.IsClosed)
            {
                return;
            }
            if (Main.rand == null)
            {
                return;
            }

            int x = (int)((this.Pos.X + (WormholePortal.Width / 2)) / 16f);
            int y = (int)((this.Pos.Y + (WormholePortal.Height / 2)) / 16f);

            float flicker_scale = 0.5f + ctx.MyMod.Config.Data.WormholeLightScale * Main.rand.NextFloat();
            float r             = flicker_scale * this.BaseColor.R / 255f;
            float g             = flicker_scale * this.BaseColor.G / 255f;
            float b             = flicker_scale * this.BaseColor.B / 255f;

            // Emit light
            Lighting.AddLight(x, y, r, g, b);
        }
Esempio n. 11
0
        public void DrawFullscreenMap(WormholeModContext ctx, WormholeLink link, SpriteBatch sb)
        {
            var mymod = ctx.MyMod;

            if (!link.IsCharted(Main.LocalPlayer) && !mymod.IsDebugWormholeViewMode())
            {
                return;
            }

            float     scale = Main.mapFullscreenScale / 1.5f;
            Texture2D tex   = WormholesUI.Tex;

            Rectangle l_rect = new Rectangle((int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height);
            Vector2   l_pos  = HudMapHelpers.GetFullMapPosition(l_rect);

            sb.Draw(tex, l_pos, this.TexAnim.Frame, link.LeftPortal.BaseColor, 0f, new Vector2 {
            }, scale, SpriteEffects.None, 1f);

            Rectangle r_rect = new Rectangle((int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height);
            Vector2   r_pos  = HudMapHelpers.GetFullMapPosition(r_rect);

            sb.Draw(tex, r_pos, this.TexAnim.Frame, link.RightPortal.BaseColor, 0f, new Vector2 {
            }, scale, SpriteEffects.None, 1f);
        }
Esempio n. 12
0
        ////////////////

        public void UpdateInteractions(WormholeModContext ctx, Player player, bool is_obstructed, out bool is_upon_portal)
        {
            is_upon_portal = false;
            if (this.IsClosed)
            {
                return;
            }

            int side = this.DetectCollision(player.getRect());

            if (!is_obstructed)
            {
                if (side == 1)
                {
                    this.TeleportToLeft(ctx, player);
                }
                else if (side == -1)
                {
                    this.TeleportToRight(ctx, player);
                }
            }

            is_upon_portal = side != 0;
        }