コード例 #1
0
ファイル: VoxelWiring.cs プロジェクト: VonZeeple/Signals
 static internal VoxelWiring deserialize(byte[] data)
 {
     using (MemoryStream ms = new MemoryStream(data))
     {
         BinaryReader reader = new BinaryReader(ms);
         VoxelWiring  wire   = new VoxelWiring(16, 16);
         try
         {
             int num_networks = reader.ReadInt32();
             for (int i = 0; i < num_networks; i++)
             {
                 int      id     = reader.ReadInt32();
                 int      size   = reader.ReadInt32();
                 byte     state  = reader.ReadByte();
                 ushort[] voxels = new ushort[size];
                 for (int j = 0; j < size; j++)
                 {
                     voxels[j] = reader.ReadUInt16();
                 }
                 wire.networks.Add(id, new VoxelWire(id, voxels));
                 wire.networks[id].state = state;
             }
         }
         catch (Exception e)
         {
         }
         return(wire);
     }
 }
コード例 #2
0
        //Get info for the itemblock
        public static void GetCircuitInfo(StringBuilder dsc, ITreeAttribute tree)
        {
            int n_voxels = VoxelWiring.GetNumberOfVoxelsFromBytes(tree.GetBytes("wiring"));

            dsc.AppendLine(Lang.Get("Wire voxels: {0}", n_voxels));
            //TODO: number of each components
            //TODO: implement circuit naming
        }
コード例 #3
0
 public VoxelCircuit(int sizex, int sizey, int sizez, BlockEntity blockEntity)
 {
     SIZEX  = sizex;
     SIZEY  = sizey;
     SIZEZ  = sizez;
     myBE   = blockEntity;
     wiring = new VoxelWiring(sizex, sizey);
 }
コード例 #4
0
        public void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldForResolving)
        {
            if (tree == null)
            {
                return;
            }
            Byte[] bytes = tree.GetBytes("wiring");
            if (bytes != null)
            {
                wiring = VoxelWiring.deserialize(bytes);
            }
            AvailableWireVoxels = tree.TryGetInt("availableWireVoxels").GetValueOrDefault(0);

            ComponentsFromTree(ref components, tree.GetTreeAttribute("components"), worldForResolving);
            selectionBoxesDidChanged = true;
        }