• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UniversalCoords类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: StructBlock

 public StructBlock(int worldX, int worldY, int worldZ, byte type, byte metaData, WorldManager world)
 {
     Type = type;
     Coords = UniversalCoords.FromWorld(worldX, worldY, worldZ);
     MetaData = metaData;
     World = world;
 }
开发者ID:IdentErr,项目名称:c-raft,代码行数:7,代码来源:BlockBase.cs


示例2: fixed

        internal unsafe byte this[UniversalCoords coords]
        {
            get
            {
                fixed (byte* types = Types)
                    return types[coords.SectionPackedCoords];
            }
            set
            {
                fixed (byte* types = Types)
                {
                    byte oldValue = types[coords.SectionPackedCoords];
                    if (oldValue != value)
                    {
                        //if (value != (byte)BlockData.Blocks.Air)
                        types[coords.SectionPackedCoords] = value;
                        if (value == (byte)BlockData.Blocks.Air)
                        {
                            if (_NonAirBlocks > 0)
                                --_NonAirBlocks;
                        }
                        else
                            ++_NonAirBlocks;

                    }
                }
            }
        }
开发者ID:Twurlerz,项目名称:K-Craft,代码行数:28,代码来源:Section.cs


示例3: Open

        /// <summary>
        /// Opens the Workbench and specifies where items should be dropped if exiting the workbench with items still in it.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public virtual void Open(UniversalCoords coords)
        {
            _useProvidedDropCoordinates = true;
            _DropCoords = coords;

            this.Open();
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:13,代码来源:WorkbenchInterface.cs


示例4: Interact

        public void Interact(EntityBase entity, StructBlock block)
        {
            Player player = entity as Player;
            if (player == null)
                return;
            if (player.CurrentInterface != null)
                return;

            byte? blockId = block.World.GetBlockId(block.Coords);

            if (blockId == null || !BlockHelper.Instance((byte)blockId).IsAir)
            {
                // Cannot open a chest if no space is above it
                return;
            }

            Chunk chunk = GetBlockChunk(block);

            // Double chest?
            if (chunk.IsNSEWTo(block.Coords, block.Type))
            {
                // 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;
                chunk.ForNSEW(block.Coords, (uc) =>
                {
                    nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
                    nsewBlockPositions[nsewCount] = uc;
                    nsewCount++;
                });

                if ((byte)nsewBlocks[0] == block.Type) // North
                {
                    player.CurrentInterface = new LargeChestInterface(block.World, nsewBlockPositions[0], block.Coords);
                }
                else if ((byte)nsewBlocks[2] == block.Type) // East
                {
                    player.CurrentInterface = new LargeChestInterface(block.World, nsewBlockPositions[2], block.Coords);
                }
                else if ((byte)nsewBlocks[1] == block.Type) // South
                {
                    player.CurrentInterface = new LargeChestInterface(block.World, block.Coords, nsewBlockPositions[1]);
                }
                else if ((byte)nsewBlocks[3] == block.Type) // West
                {
                    player.CurrentInterface = new LargeChestInterface(block.World, block.Coords, nsewBlockPositions[3]);
                }
            }
            else
            {
                player.CurrentInterface = new SmallChestInterface(block.World, block.Coords);
            }

            player.CurrentInterface.Associate(player);
            player.CurrentInterface.Open();
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:57,代码来源:BlockChest.cs


示例5: BlockPathWeight

 protected override double BlockPathWeight(UniversalCoords coords)
 {
     if (this.World.GetBlockId(coords.WorldX, coords.WorldY - 1, coords.WorldZ) == (byte)BlockData.Blocks.Grass)
     {
         return 10.0;
     }
     else
     {
         return this.World.GetBlockLightBrightness(coords) - 0.5; // stay out of lower half of brightness spectrum
     }
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:11,代码来源:Animal.cs


示例6: Remove

        public bool Remove(UniversalCoords coords)
		{
            Chunk chunk;
            Interlocked.Increment(ref Changes);
            
            bool result = Chunks.TryRemove(coords.ChunkPackedCoords, out chunk);

            if(result)
                chunk.Dispose();

            return result;
		}
开发者ID:TheaP,项目名称:c-raft,代码行数:12,代码来源:ChunkSet.cs


示例7: 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


示例8:

		public Chunk this[UniversalCoords coords]
		{
			get
			{
                Chunk chunk;
                Chunks.TryGetValue(coords.ChunkPackedCoords, out chunk);
				return chunk;
			}
			private set
			{
                Chunks.AddOrUpdate(coords.ChunkPackedCoords, value, (key, oldValue) => value);
			}
		}
开发者ID:TheaP,项目名称:c-raft,代码行数:13,代码来源:ChunkSet.cs


示例9: 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


示例10: CheckOffset

        private int CheckOffset(UniversalCoords start, Size size)
        {
            for (int x = start.WorldX; x < start.WorldX + size.Width; x++)
            {
                for (int y = start.WorldY; y < start.WorldY + size.Height; y++)
                {
                    for (int z = start.WorldZ; z < start.WorldZ + size.Width; z++)
                    {
                        StructBlock block = World.GetBlock(x, y, z);
                        if (block.Type <= 0)
                            continue;

                        BlockBase blockClass = BlockHelper.Instance(block.Type);
                        if (blockClass is BlockBaseDoor)
                        {
                            if (!((BlockBaseDoor)blockClass).IsOpen(block))
                            {
                                return 0;
                            }
                            continue;
                        }
                        if (blockClass.IsSolid)
                        {
                            return 0;
                        }
                        if (blockClass.IsLiquid)
                        {
                            if (!blockClass.IsOpaque) // Water
                            {
                                return -1;
                            }
                            else // Lava
                            {
                                return -2;
                            }
                        }
                    }
                }
            }

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


示例11: DropItem

        /// <summary>
        /// Drops an item at the given location.
        /// </summary>
        /// <param name="world">The world in which the coordinates reside.</param>
        /// <param name="coords">The target coordinate</param>
        /// <param name="stack">The stack to be dropped</param>
        /// <param name="velocity">An optional velocity (the velocity will be clamped to -0.4 and 0.4 on each axis)</param>
        /// <returns>The entity ID of the item drop.</returns>
        public int DropItem(IWorldManager world, UniversalCoords coords, IItemInventory stack, Vector3 velocity = new Vector3())
        {
            if (ItemHelper.IsVoid(stack))
                return -1;

            int entityId = AllocateEntity();

            bool sendVelocity = false;
            if (velocity != Vector3.Origin)
            {
                velocity = new Vector3(velocity.X.Clamp(-0.4, 0.4), velocity.Y.Clamp(-0.4, 0.4), velocity.Z.Clamp(-0.4, 0.4));
                sendVelocity = true;
            }

            AddEntity(new ItemEntity(this, entityId)
            {
                World = world as WorldManager,
                Position = new AbsWorldCoords(new Vector3(coords.WorldX + 0.5, coords.WorldY, coords.WorldZ + 0.5)), // Put in the middle of the block (ignoring Y)
                ItemId = stack.Type,
                Count = stack.Count,
                Velocity = velocity,
                Durability = stack.Durability
            });

            if (sendVelocity)
                SendPacketToNearbyPlayers(world as WorldManager, coords, new EntityVelocityPacket { EntityId = entityId, VelocityX = (short)(velocity.X * 8000), VelocityY = (short)(velocity.Y * 8000), VelocityZ = (short)(velocity.Z * 8000) });

            return entityId;
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:37,代码来源:Server.cs


示例12: GetNearbyLivings

 public IEnumerable<ILivingEntity> GetNearbyLivings(IWorldManager world, UniversalCoords coords)
 {
     return GetNearbyLivingsInternal(world as WorldManager, coords);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:4,代码来源:Server.cs


示例13: foreach

        /*public IEnumerable<IEntityBase> GetNearbyLivings(IWorldManager world, AbsWorldCoords coords)
        {
            int radius = ChraftConfig.SightRadius << 4;
            foreach (EntityBase entity in GetEntities())
            {
                if (!(entity is LivingEntity))
                    continue;

                if (entity.World == world && Math.Abs(coords.X - entity.Position.X) <= radius && Math.Abs(coords.Y - entity.Position.Y) <= radius && Math.Abs(coords.Z - entity.Position.Z) <= radius)
                    yield return (entity as LivingEntity);
            }
        }*/

        internal IEnumerable<LivingEntity> GetNearbyLivingsInternal(WorldManager world, UniversalCoords coords)
        {
            int radius = ChraftConfig.MaxSightRadius;
            foreach (EntityBase entity in GetEntities())
            {
                if (!(entity is LivingEntity))
                    continue;
                int entityChunkX = (int)Math.Floor(entity.Position.X) >> 4;
                int entityChunkZ = (int)Math.Floor(entity.Position.Z) >> 4;

                if (entity.World == world && Math.Abs(coords.ChunkX - entityChunkX) <= radius && Math.Abs(coords.ChunkZ - entityChunkZ) <= radius)
                    yield return (entity as LivingEntity);
            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:27,代码来源:Server.cs


示例14: GetNearbyEntitiesDict

        /// <summary>
        /// Yields an enumerable of nearby entities, including players.  Thread-safe.
        /// </summary>
        /// <param name="world">The world containing the coordinates.</param>
        /// <param name="x">The center X coordinate.</param>
        /// <param name="y">The center Y coordinate.</param>
        /// <param name="z">The center Z coordinate.</param>
        /// <returns>A lazy enumerable of nearby entities.</returns>
        public Dictionary<int, IEntityBase> GetNearbyEntitiesDict(IWorldManager world, UniversalCoords coords)
        {
            int radius = ChraftConfig.MaxSightRadius;

            Dictionary<int, IEntityBase> dict = new Dictionary<int, IEntityBase>();

            foreach (EntityBase e in GetEntities())
            {
                int entityChunkX = (int)Math.Floor(e.Position.X) >> 4;
                int entityChunkZ = (int)Math.Floor(e.Position.Z) >> 4;

                if (e.World == world && Math.Abs(coords.ChunkX - entityChunkX) <= radius && Math.Abs(coords.ChunkZ - entityChunkZ) <= radius)
                {
                    dict.Add(e.EntityId, e);
                }
            }

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


示例15: SetSkyLight

 public void SetSkyLight(UniversalCoords coords, byte value)
 {
     SkyLight.setNibble(coords.BlockPackedCoords, value);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:4,代码来源:Chunk.cs


示例16: GetDoubleChestCoords

        public static UniversalCoords[] GetDoubleChestCoords(WorldManager world, UniversalCoords coords)
        {
            Chunk chunk = world.GetChunk(coords) as Chunk;
            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:TheaP,项目名称:c-raft,代码行数:42,代码来源:ContainerFactory.cs


示例17: Destroy

 public static void Destroy(WorldManager world, UniversalCoords coords)
 {
     PersistentContainer container = Instance(world, coords);
     if (container == null)
         return;
     Chunk chunk = world.GetChunk(coords) as Chunk;
     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:TheaP,项目名称:c-raft,代码行数:14,代码来源:ContainerFactory.cs


示例18: RecalculateHeight

 public void RecalculateHeight(UniversalCoords coords)
 {
     RecalculateHeight(coords.BlockX, coords.BlockZ);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:4,代码来源:Chunk.cs


示例19: Chunk

 public Chunk(WorldManager world, UniversalCoords coords, int maxSections) : this(world, coords)
 {
     _Sections = new Section[maxSections];
     _MaxSections = maxSections;
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:5,代码来源:Chunk.cs


示例20: IsAir

 public bool IsAir(UniversalCoords coords)
 {
     Section section = _Sections[coords.BlockY >> 4];
     return BlockHelper.Instance.IsAir(section[coords.BlockPackedCoords]);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:5,代码来源:Chunk.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LSL_Types.LSLString类代码示例发布时间:2022-05-24
下一篇:
C# UnityEngine.Vector2类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap