Exemplo n.º 1
0
        ////////////////

        public WormholeManager(WormholesMod mymod)
        {
            switch (WorldHelpers.GetSize())
            {
            case WorldSize.SubSmall:
                WormholeManager.PortalCount = mymod.Config.Data.TinyWorldPortals;
                break;

            case WorldSize.Small:
                WormholeManager.PortalCount = mymod.Config.Data.SmallWorldPortals;
                break;

            case WorldSize.Medium:
                WormholeManager.PortalCount = mymod.Config.Data.MediumWorldPortals;
                break;

            case WorldSize.Large:
                WormholeManager.PortalCount = mymod.Config.Data.LargeWorldPortals;
                break;

            case WorldSize.SuperLarge:
                WormholeManager.PortalCount = mymod.Config.Data.HugeWorldPortals;
                break;
            }

            this.Links = new List <WormholeLink>(WormholeManager.PortalCount);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        ////////////////

        public WormholesMod() : base()
        {
            WormholesMod.Instance = this;
        }
Exemplo n.º 4
0
 public override void Unload()
 {
     WormholesMod.Instance = null;
 }
Exemplo n.º 5
0
 internal WormholeModContext(WormholesMod mymod)
 {
     this.MyMod = mymod;
 }