当前位置: 首页>>代码示例>>C#>>正文


C# World.Init方法代码示例

本文整理汇总了C#中SMP.World.Init方法的典型用法代码示例。如果您正苦于以下问题:C# World.Init方法的具体用法?C# World.Init怎么用?C# World.Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMP.World的用法示例。


在下文中一共展示了World.Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadLVL


//.........这里部分代码省略.........
                                    w.chunkData.Add(new Point(x, z), c);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(ex.ToString());
                        }
                    });
                }
                else{
                    for (int i = 0; i < chunkcount; i++)
                    {
                        try
                        {
                            int block = (int)i * 32776;
                            int x = BitConverter.ToInt32(bytes, 0 + block);
                            int z = BitConverter.ToInt32(bytes, 4 + block);
                            Chunk c = new Chunk(x, z);
                            Array.Copy(bytes, 8 + block, c.blocks, 0, 32768);
                            c.RecalculateLight();
                            c.SpreadLight();
                            lock (w.chunkData)
                                if (!w.chunkData.ContainsKey(new Point(x, z)))
                                    w.chunkData.Add(new Point(x, z), c);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(ex.ToString());
                        }
                    }
                }
            }*/

            try
            {
                using (StreamReader sw = new StreamReader(filename + "/" + filename + ".ini"))
                {
                    w.seed = long.Parse(sw.ReadLine());
                    w.SpawnX = int.Parse(sw.ReadLine());
                    w.SpawnY = int.Parse(sw.ReadLine());
                    w.SpawnZ = int.Parse(sw.ReadLine());
                    w.ChunkLimit = int.Parse(sw.ReadLine());
                    w.time = long.Parse(sw.ReadLine());
                    w.dimension = sbyte.Parse(sw.ReadLine());
                    w.moonPhase = byte.Parse(sw.ReadLine());
                }
            }
            catch { /*Logger.Log("Error loading world configuration!");*/ }

            w.physics = new Physics(w);
            w.generator = new GenStandard(w, true);
            w.chunkManager = new WorldChunkManager(w);

            int cursorH = 22 + w.name.Length;
            float count = 0, total = (Server.ViewDistance * 2 + 1) * (Server.ViewDistance * 2 + 1);
            Console.SetCursorPosition(cursorH, Console.CursorTop - 1);
            Console.Write("0%");

            object derpLock = new object();
            try
            {
                Parallel.For(((int)w.SpawnX >> 4) - Server.ViewDistance, ((int)w.SpawnX >> 4) + Server.ViewDistance + 1, x =>
                {
                    Parallel.For(((int)w.SpawnZ >> 4) - Server.ViewDistance, ((int)w.SpawnZ >> 4) + Server.ViewDistance + 1, z =>
                    {
                        w.LoadChunk(x, z, false, false);
                        lock (derpLock)
                        {
                            Console.SetCursorPosition(cursorH, Console.CursorTop);
                            count++; Console.Write((int)((count / total) * 100) + "%");
                        }
                    });
                });
            }
            catch (NotImplementedException)
            {
                for (int x = ((int)w.SpawnX >> 4) - Server.ViewDistance; x < ((int)w.SpawnX >> 4) + Server.ViewDistance + 1; x++)
                {
                    for (int z = ((int)w.SpawnZ >> 4) - Server.ViewDistance; z < ((int)w.SpawnZ >> 4) + Server.ViewDistance + 1; z++)
                    {
                        w.LoadChunk(x, z, false, false);
                        Console.SetCursorPosition(cursorH, Console.CursorTop);
                        count++; Console.Write((int)((count / total) * 100) + "%");
                    }
                }
            }

            Console.WriteLine();

            World.worlds.Add(w);
            Logger.Log(filename + " Loaded.");
            Logger.Log("Look distance = " + Server.ViewDistance);

            w.Init();
            w.physics.Start();

            if (World.WorldLoad != null)
                World.WorldLoad(w);

            return w;
        }
开发者ID:Nerketur,项目名称:ForgeCraft,代码行数:101,代码来源:World.cs


注:本文中的SMP.World.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。