Пример #1
0
        //public void AddWormholePair( WormholeLink link ) {
        //	this.Links.Add( link );
        //	WormholesWorld.PortalCount++;
        //}


        public void FinishSettingUpWormholes()
        {
            if (this.WormholesFinishedSpawning)
            {
                return;
            }

            if (WormholeManager.ForceRegenWormholes)
            {
                ErrorLogger.Log("  Regenerating ALL portals.");
                this.Links = new List <WormholeLink>(WormholeManager.PortalCount);
            }

            for (int i = 0; i < WormholeManager.PortalCount; i++)
            {
                // Skip already-loaded wormholes
                if (i < this.Links.Count && this.Links[i] != null)
                {
                    continue;
                }

                var link = this.CreateRandomWormholePair(WormholeLink.GetColor(i));
                this.Links.Add(link);
            }

            this.WormholesFinishedSpawning = true;
        }
Пример #2
0
        private void DrawFullMap(SpriteBatch sb)
        {
            this.UI.Update();

            WormholesWorld  myworld  = ModContent.GetInstance <WormholesWorld>();
            WormholesPlayer myplayer = Main.LocalPlayer.GetModPlayer <WormholesPlayer>();

            if (!WormholesConfig.Instance.DisableNaturalWormholes)
            {
                if (myworld.Wormholes != null)
                {
                    for (int i = 0; i < myworld.Wormholes.Links.Count; i++)
                    {
                        WormholeLink link = myworld.Wormholes.Links[i];
                        if (link == null)
                        {
                            break;
                        }

                        this.UI.DrawFullscreenMap(link, sb);
                    }
                }
            }

            if (myplayer.MyPortal != null)
            {
                this.UI.DrawFullscreenMap(myplayer.MyPortal, sb);
            }
        }
Пример #3
0
        //public void AddWormholePair( WormholeLink link ) {
        //	this.Links.Add( link );
        //	WormholesWorld.PortalCount++;
        //}


        public void FinishSettingUpWormholes()
        {
            if (this.WormholesFinishedSpawning)
            {
                return;
            }

            if (WormholeManager.ForceRegenWormholes)
            {
                LogHelpers.Log("  Regenerating ALL portals.");
                this.Links = new List <WormholeLink>(WormholeManager.PortalCount);
            }

            for (int i = 0; i < WormholeManager.PortalCount; i++)
            {
                // Skip already-loaded wormholes
                if (i < this.Links.Count && this.Links[i] != null)
                {
                    continue;
                }

                WormholeLink link = this.CreateRandomWormholePair(WormholeLink.GetColor(i));
                if (link == null)
                {
                    LogHelpers.Alert("Not enough space to create the indicated quantity of wormholes (made " + i + " of " + WormholeManager.PortalCount + ")");
                    break;
                }

                this.Links.Add(link);
            }

            this.WormholesFinishedSpawning = true;
        }
Пример #4
0
        private void DrawFullMap(SpriteBatch sb)
        {
            this.UI.Update();

            WormholesWorld  modworld       = this.GetModWorld <WormholesWorld>();
            WormholesPlayer curr_modplayer = Main.player[Main.myPlayer].GetModPlayer <WormholesPlayer>(this);

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

                        this.UI.DrawFullscreenMap(link, sb);
                    }
                }
            }

            if (curr_modplayer.MyPortal != null)
            {
                this.UI.DrawFullscreenMap(curr_modplayer.MyPortal, sb);
            }
        }
Пример #5
0
        public void DrawOverlayMap(WormholeLink link, SpriteBatch sb)
        {
            if (!link.IsCharted(Main.LocalPlayer) && !WormholesConfig.Instance.DebugModeMapCheat)
            {
                return;
            }

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

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

            var lPosData = HUDMapHelpers.GetOverlayMapPositionAsScreenPosition(lRect);

            if (lPosData.IsOnScreen)
            {
                Color lColor = link.LeftPortal.BaseColor * Main.mapOverlayAlpha;
                sb.Draw(tex, (Vector2)lPosData.Item1, this.TexAnim.Frame, lColor, 0f, new Vector2(), scale, SpriteEffects.None, 1f);
            }

            var rPosData = HUDMapHelpers.GetOverlayMapPositionAsScreenPosition(rRect);

            if (rPosData.IsOnScreen)
            {
                Color rColor = link.RightPortal.BaseColor * Main.mapOverlayAlpha;
                sb.Draw(tex, rPosData.Item1, this.TexAnim.Frame, rColor, 0f, new Vector2(), scale, SpriteEffects.None, 1f);
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
        /////////////////

        public bool Load(WormholesMod mymod, TagCompound tags)
        {
            if (mymod.Config.Data.DisableNaturalWormholes)
            {
                return(false);
            }
            if (!tags.ContainsKey("wormhole_count"))
            {
                return(false);
            }

            int holes = tags.GetInt("wormhole_count");

            if (holes == 0)
            {
                return(false);
            }

            if (mymod.IsDebugInfoMode())
            {
                LogHelpers.Log("Loading world ids (" + Main.netMode + "): " + holes);
            }

            int[] worm_l_x = tags.GetIntArray("wormhole_left_x");
            int[] worm_l_y = tags.GetIntArray("wormhole_left_y");
            int[] worm_r_x = tags.GetIntArray("wormhole_right_x");
            int[] worm_r_y = tags.GetIntArray("wormhole_right_y");

            for (int i = 0; i < holes && i < worm_l_x.Length && i < WormholeManager.PortalCount; i++)
            {
                if (i < this.Links.Count && this.Links[i] != null)
                {
                    this.Links[i].Close();
                }

                string id = tags.GetString("wormhole_id_" + i);
                if (mymod.IsDebugInfoMode())
                {
                    LogHelpers.Log("  world load id: " + id + " (" + i + ")");
                }

                Vector2 pos_l = new Vector2(worm_l_x[i], worm_l_y[i]);
                Vector2 pos_r = new Vector2(worm_r_x[i], worm_r_y[i]);

                var link = new WormholeLink(id, WormholeLink.GetColor(i), pos_l, pos_r);

                // Failsafe against glitched portals
                if (link.IsMisplaced)
                {
                    ErrorLogger.Log("Found bad portal. " + i + " " + worm_l_x[i] + "," + worm_l_y[i]
                                    + " : " + worm_r_x[i] + "," + worm_r_y[i]);
                    WormholeManager.ForceRegenWormholes = true;
                    break;
                }

                this.Links.Insert(i, link);
            }
            return(true);
        }
Пример #8
0
        public static void RemoveWormhole(WormholeLink link)
        {
            var myworld = ModContent.GetInstance <WormholesWorld>();

            if (myworld.Wormholes.Links.Remove(link))
            {
                link.Close();
            }
        }
Пример #9
0
        public static void RemoveWormhole(WormholeLink link)
        {
            var myworld = WormholesMod.Instance.GetModWorld <WormholesWorld>();

            if (myworld.Wormholes.Links.Remove(link))
            {
                link.Close();
            }
        }
Пример #10
0
        public void Reroll(WormholeLink link)
        {
            Vector2 rand_pos1, rand_pos2;

            do
            {
                rand_pos1 = this.GetRandomClearMapPos();
                rand_pos2 = this.GetRandomClearMapPos();
            } while(Vector2.Distance(rand_pos1, rand_pos2) < 2048);

            link.ChangePosition(rand_pos1, rand_pos2);
        }
Пример #11
0
        /////////////////

        public void RunAll(Player player)
        {
            var mymod = WormholesMod.Instance;
            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>(mymod).MyPortal;

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

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

                    if (is_upon_a_portal)
                    {
                        break;
                    }
                }
            }

            if (town_portal != null)
            {
                town_portal.UpdateInteractions(player, (block_countdown > 0 || is_upon_a_portal), out is_upon_my_portal);
                town_portal.UpdateBehavior(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]--;
            }
        }
Пример #12
0
        ////////////////

        private void DrawMiniMap(SpriteBatch sb)
        {
            this.UI.Update();

            WormholesWorld  modworld       = this.GetModWorld <WormholesWorld>();
            WormholesPlayer curr_modplayer = Main.player[Main.myPlayer].GetModPlayer <WormholesPlayer>(this);

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

                        if (Main.mapStyle == 1)
                        {
                            this.UI.DrawMiniMap(this.Context, link, sb);
                        }
                        else
                        {
                            this.UI.DrawOverlayMap(this.Context, link, sb);
                        }
                    }
                }
            }

            if (curr_modplayer.MyPortal != null)
            {
                if (Main.mapStyle == 1)
                {
                    this.UI.DrawMiniMap(this.Context, curr_modplayer.MyPortal, sb);
                }
                else
                {
                    this.UI.DrawOverlayMap(this.Context, curr_modplayer.MyPortal, sb);
                }
            }
        }
Пример #13
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);
            }
        }
Пример #14
0
        public void DrawAll(WormholeLink townPortal)
        {
            if (!WormholesConfig.Instance.DisableNaturalWormholes)
            {
                for (int i = 0; i < this.Links.Count; i++)
                {
                    WormholeLink link = this.Links[i];
                    if (link == null)
                    {
                        break;
                    }

                    link.DrawForMe();
                }
            }
            if (townPortal != null)
            {
                townPortal.DrawForMe();
            }
        }
Пример #15
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);
        }
Пример #16
0
        ////////////////

        public static void RandomizeWormhole(WormholeLink link)
        {
            var myworld = ModContent.GetInstance <WormholesWorld>();

            myworld.Wormholes.Reroll(link);
        }
Пример #17
0
        ////////////////

        public static void RandomizeWormhole(WormholeLink link)
        {
            var myworld = WormholesMod.Instance.GetModWorld <WormholesWorld>();

            myworld.Wormholes.Reroll(link);
        }