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


C# World.WorldManager类代码示例

本文整理汇总了C#中Chraft.World.WorldManager的典型用法代码示例。如果您正苦于以下问题:C# WorldManager类的具体用法?C# WorldManager怎么用?C# WorldManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GenerateB

 public override void GenerateB(WorldManager world, int i, int j, int k, int l, byte[] abyte0)
 {
     int i1 = rand.nextInt(rand.nextInt(rand.nextInt(40) + 1) + 1);
     if (rand.nextInt(15) != 0)
     {
         i1 = 0;
     }
     for (int j1 = 0; j1 < i1; j1++)
     {
         double d = i * 16 + rand.nextInt(16);
         double d1 = rand.nextInt(rand.nextInt(120) + 8);
         double d2 = j * 16 + rand.nextInt(16);
         int k1 = 1;
         if (rand.nextInt(4) == 0)
         {
             UnknownA(k, l, abyte0, d, d1, d2);
             k1 += rand.nextInt(4);
         }
         for (int l1 = 0; l1 < k1; l1++)
         {
             float f = rand.nextFloat() * 3.141593F * 2.0F;
             float f1 = ((rand.nextFloat() - 0.5F) * 2.0F) / 8F;
             float f2 = rand.nextFloat() * 2.0F + rand.nextFloat();
             UnknownB(k, l, abyte0, d, d1, d2, f2, f, f1, 0, 0, 1.0D);
         }
     }
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:27,代码来源:MapGenCaves.cs

示例2: SpawnMobs

        public static void SpawnMobs(WorldManager world, bool spawnHostileMobs, bool spawnPeacefulMobs)
        {
            var players = world.Server.GetAuthenticatedClients().Where(c => c.Owner.World == world).Select(c => c.Owner).ToArray();
            HashSet<int> chunksToSpawnIn = new HashSet<int>();

            #region Get a list of all chunks within 8 chunks of any players
            foreach (var player in players)
            {
                UniversalCoords coord = UniversalCoords.FromAbsWorld(player.Position);

                for (int x = -MaxSpawnDistance; x <= MaxSpawnDistance; x++)
                {
                    for (int z = -MaxSpawnDistance; z <= MaxSpawnDistance; z++)
                    {
                        chunksToSpawnIn.Add(UniversalCoords.FromChunkToPackedChunk(coord.ChunkX + x, coord.ChunkZ + z));
                    }
                }
            }
            #endregion

            // Get a list of Mob entities outside of the loop so we only get it once
            Mob[] mobEntities = world.GetEntities().Where(e => e is Mob).Select((e) => e as Mob).ToArray();

            // TODO: need to use Biome to get the list of mob types available for each category
            // TODO: make the maximum count of mobs per category configurable
            if (spawnHostileMobs)
            {
                DoSpawn(world, chunksToSpawnIn, mobEntities, Monsters, MaxMonsters);
            }
            if (spawnPeacefulMobs)
            {
                DoSpawn(world, chunksToSpawnIn, mobEntities, Creatures, MaxCreatures);
                DoSpawn(world, chunksToSpawnIn, mobEntities, WaterCreatures, MaxWaterCreatures, true);
            }
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:35,代码来源:WorldMobSpawner.cs

示例3: ChunkBase

 internal ChunkBase(WorldManager world, int x, int z)
 {
     World = world;
     X = x;
     Z = z;
     _UpdateTimer = new Timer(UpdateBlocksToNearbyPlayers, null, Timeout.Infinite, Timeout.Infinite);
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:7,代码来源:ChunkBase.cs

示例4: ProvideChunk

        public Chunk ProvideChunk(int x, int z, WorldManager world)
        {
            Chunk chunk = new Chunk(world, UniversalCoords.FromChunk(x, z));
            InitGen();

            byte[] data = new byte[32768];
            #if PROFILE
            Stopwatch watch = new Stopwatch();
            watch.Start();
            #endif
            GenerateTerrain(chunk, data, x, z);
            GenerateFlora(chunk, data, x, z);
            chunk.SetAllBlocks(data);

            chunk.RecalculateHeight();
            chunk.LightToRecalculate = true;
            #if PROFILE
            watch.Stop();

            _World.Logger.Log(Logger.LogLevel.Info, "Chunk {0} {1}, {2}", false, x, z, watch.ElapsedMilliseconds);
            #endif

            _World.AddChunk(chunk);
            chunk.MarkToSave();

            return chunk;
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:27,代码来源:CustomGenerator.cs

示例5: Ocelot

 internal Ocelot(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
     Data.IsSitting = false;
     Data.IsTamed = false;
     Data.IsAggressive = false;
     FishUntilTamed = Server.Rand.Next(20);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:8,代码来源:Ocelot.cs

示例6: Wolf

 internal Wolf(WorldManager world, int entityId, MetaData data = null)
     : base(world, entityId, MobType.Wolf, data)
 {
     Data.IsSitting = false;
     Data.IsTamed = false;
     Data.IsAggressive = false;
     BonesUntilTamed = Server.Rand.Next(10); // How many bones required to tame this wolf?
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:8,代码来源:Wolf.cs

示例7: Mob

 protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world.Server, entityId, data)
 {
     this.Type = type;
     this.World = world;
     this.MobUpdateFrequency = 1;
     this.Speed = 0.7;
 }
开发者ID:dekema2,项目名称:c-raft,代码行数:8,代码来源:Mob.cs

示例8: StopBurning

 public static void StopBurning(WorldManager world, UniversalCoords coords)
 {
     string id = String.Format("{0}-{1},{2},{3}", world.Name, coords.WorldX, coords.WorldY, coords.WorldZ);
     lock (_staticLock)
     {
         if (_furnaceInstances.ContainsKey(id))
             _furnaceInstances[id].StopBurning();
     }
 }
开发者ID:IdentErr,项目名称:c-raft,代码行数:9,代码来源:FurnaceInterface.cs

示例9: Mob

        public Vector3 gotoPos; // Location entity should move towards

        #endregion Fields

        #region Constructors

        protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
            : base(world.Server, entityId)
        {
            if (data == null)
                data = new MetaData();
            this.Data = data;
            this.Type = type;
            this.World = world;
            this.Health = this.MaxHealth;
        }
开发者ID:Smjert,项目名称:c-raft,代码行数:16,代码来源:Mob.cs

示例10: Instance

        public static PersistentContainer Instance(WorldManager world, UniversalCoords coords)
        {
            PersistentContainer container;
            Chunk chunk = world.GetChunk(coords) as Chunk;
            if (chunk == null)
                return null; 
            BlockData.Blocks block = chunk.GetType(coords);
            if (!chunk.Containers.ContainsKey(coords.BlockPackedCoords))
            {
                switch (block)
                {
                    case BlockData.Blocks.Furnace:
                    case BlockData.Blocks.Burning_Furnace:
                        container = new FurnaceContainer();
                        container.Initialize(world, coords);
                        (container as FurnaceContainer).StartBurning();
                        break;
                    case BlockData.Blocks.Dispenser:
                        container = new DispenserContainer();
                        container.Initialize(world, coords);
                        break;
                    case BlockData.Blocks.Chest:
                        // Double chest?
                        if (IsDoubleChest(chunk, coords))
                        {
                            UniversalCoords[] doubleChestCoords = GetDoubleChestCoords(world, coords);
                            if (doubleChestCoords == null)
                                return null;
                            chunk.Containers.TryRemove(doubleChestCoords[0].BlockPackedCoords, out container);
                            chunk.Containers.TryRemove(doubleChestCoords[1].BlockPackedCoords, out container);

                            container = new LargeChestContainer(doubleChestCoords[1]);
                            container.Initialize(world, doubleChestCoords[0]);
                            chunk.Containers.TryAdd(doubleChestCoords[0].BlockPackedCoords, container);
                            chunk.Containers.TryAdd(doubleChestCoords[1].BlockPackedCoords, container);
                        }
                        else
                        {
                            container = new SmallChestContainer();
                            container.Initialize(world, coords);
                        }
                        break;
                    default:
                        return null;
                }
                chunk.Containers.TryAdd(coords.BlockPackedCoords, container);
            }
            else
            {
                chunk.Containers.TryGetValue(coords.BlockPackedCoords, out container);
            }
            return container;
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:53,代码来源:ContainerFactory.cs

示例11: Destroy

 public static void Destroy(WorldManager world, UniversalCoords coords)
 {
     PersistentContainer container = Instance(world, coords);
     if (container == null)
         return;
     Chunk chunk = world.GetChunk(coords);
     if (chunk == null)
         return;
     PersistentContainer unused;
     container.Destroy();
     chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
     if (container is LargeChestContainer)
         chunk.Containers.TryRemove((container as LargeChestContainer).SecondCoords.BlockPackedCoords, out unused);
 }
开发者ID:dekema2,项目名称:c-raft,代码行数:14,代码来源:ContainerFactory.cs

示例12: Initialize

 public virtual void Initialize(WorldManager world, UniversalCoords coords)
 {
     World = world;
     Coords = coords;
     Slots = new ItemInventory[SlotsCount];
     DataFile = string.Format("x{0}y{1}z{2}.dat", Coords.WorldX, Coords.WorldY, Coords.WorldZ);
     string chunkFolder = string.Format("x{0}z{1}", Coords.ChunkX, Coords.ChunkZ);
     ContainerFolder = Path.Combine(DataPath, chunkFolder);
     if (!Directory.Exists(ContainerFolder))
     {
         Directory.CreateDirectory(ContainerFolder);
     }
     Load();
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:14,代码来源:PersistentContainer.cs

示例13: GenerateA

 public virtual void GenerateA(ChunkGenerator gen, WorldManager world, int x, int z, byte[] data)
 {
     int radius = field_947_a;
     rand.setSeed(world.GetSeed());
     long l = (rand.nextLong() / 2L) * 2L + 1L;
     long l1 = (rand.nextLong() / 2L) * 2L + 1L;
     for (int ix = x - radius; ix <= x + radius; ix++)
     {
         for (int iz = z - radius; iz <= z + radius; iz++)
         {
             rand.setSeed((long)ix * l + (long)iz * l1 ^ world.GetSeed());
             GenerateB(world, ix, iz, x, z, data);
         }
     }
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:15,代码来源:MapGenBase.cs

示例14: Chunk

        internal Chunk(WorldManager world, int x, int z)
            : base(world, x, z)
        {
            /*using(StreamWriter sw  = new StreamWriter("chunkStack.log", true))
                {
                    sw.WriteLine("Instance: {0}, {1}, Thread: {2}", X, Z, Thread.CurrentThread.ManagedThreadId);

                    StackTrace stackTrace = new StackTrace();           // get call stack
                    StackFrame[] stackFrames = stackTrace.GetFrames();  // get method calls (frames)

                    // write call stack method names
                    foreach (StackFrame stackFrame in stackFrames)
                    {
                        sw.WriteLine(stackFrame.GetMethod().ReflectedType.FullName + "." + stackFrame.GetMethod().Name + " line: {0}", stackFrame.GetFileLineNumber());   // write method name
                    }
                    sw.WriteLine("\r\n");
                }*/
        }
开发者ID:StianLohna,项目名称:c-raft,代码行数:18,代码来源:Chunk.cs

示例15: GetDoubleChestCoords

        public static UniversalCoords[] GetDoubleChestCoords(WorldManager world, UniversalCoords coords)
        {
            Chunk chunk = world.GetChunk(coords);
            if (chunk == null || !IsDoubleChest(chunk, coords))
                return null;
            // Is this chest the "North or East", or the "South or West"
            BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
            UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
            int nsewCount = 0;
            byte? blockId;
            chunk.ForNSEW(coords, uc =>
            {
                blockId = world.GetBlockId(uc) ?? 0;
                nsewBlocks[nsewCount] = (BlockData.Blocks)blockId;
                nsewBlockPositions[nsewCount] = uc;
                nsewCount++;
            });
            UniversalCoords firstCoords;
            UniversalCoords secondCoords;

            if ((byte)nsewBlocks[0] == (byte)BlockData.Blocks.Chest) // North
            {
                firstCoords = nsewBlockPositions[0];
                secondCoords = coords;
            }
            else if ((byte)nsewBlocks[2] == (byte)BlockData.Blocks.Chest) // East
            {
                firstCoords = nsewBlockPositions[2];
                secondCoords = coords;
            }
            else if ((byte)nsewBlocks[1] == (byte)BlockData.Blocks.Chest) // South
            {
                firstCoords = coords;
                secondCoords = nsewBlockPositions[1];
            }
            else// if ((byte)nsewBlocks[3] == (byte)BlockData.Blocks.Chest) // West
            {
                firstCoords = coords;
                secondCoords = nsewBlockPositions[3];
            }
            return new UniversalCoords[] { firstCoords, secondCoords };
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:42,代码来源:ContainerFactory.cs


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