예제 #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
        //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;
        }
예제 #3
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);
        }