コード例 #1
0
ファイル: World.cs プロジェクト: Alword/Bost
 public BlockState this[Int3 location]
 {
     get {
         Int3 chunkSectionKey = location.GetChunk();
         Int2 chunkKey        = new Int2(chunkSectionKey.X, chunkSectionKey.Z);
         if (Chunks.ContainsKey(chunkKey))
         {
             ChunkColumn  chunk   = Chunks[chunkKey];
             ChunkSection section = chunk[chunkSectionKey.Y];
             if (section == null)
             {
                 return(new BlockState());
             }
             else
             {
                 Int3    bp = location.InChunkBlock();
                 BlockId id = section.GetBlock(bp.X, bp.Y, bp.Z);
                 return(GlobalPalette.GetState(id.StateId));
             }
         }
         else
         {
             return(new BlockState());
         }
     }
 }
コード例 #2
0
 public void Read(ref byte[] data)
 {
     idToState = new Dictionary <uint, BlockState>();
     stateToId = new Dictionary <BlockState, uint>();
     // Palette Length
     McVarint.TryParse(ref data, out int length);
     // Palette
     for (uint id = 0; id < length; id++)
     {
         McVarint.TryParse(ref data, out int stateId);
         BlockState state = GlobalPalette.GetState((uint)stateId);
         idToState[id]    = state;
         stateToId[state] = id;
     }
 }
コード例 #3
0
ファイル: BlockId.cs プロジェクト: Alword/Bost
 public override string ToString()
 {
     return($"{StateId} {GlobalPalette.GetState(StateId).Name}");
 }
コード例 #4
0
ファイル: DirectPalette.cs プロジェクト: Alword/Bost
		public BlockState StateForId(uint id)
		{
			return GlobalPalette.GetState(id);
		}
コード例 #5
0
ファイル: DirectPalette.cs プロジェクト: Alword/Bost
		public uint IdForState(BlockState state)
		{
			return GlobalPalette.GetId(state).StateId;
		}