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


C# Stream.WriteNoAlloc方法代码示例

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


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

示例1: WriteTo

 public void WriteTo(Stream stream)
 {
     stream.WriteNoAlloc(Seed);
     stream.WriteNoAlloc(Radius);
     stream.WriteNoAlloc(DeviationScale);
     stream.WriteNoAlloc(AveragePlanetRadius);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:MyCsgShapePlanet.cs

示例2:

        void IMyStorageDataProvider.WriteTo(Stream stream)
        {
            stream.WriteNoAlloc(m_state.Version);
            stream.WriteNoAlloc(m_state.Generator);
            stream.WriteNoAlloc(m_state.Seed);
            stream.WriteNoAlloc(m_state.Size);
            stream.WriteNoAlloc(m_state.IsPlanet);

            if (m_state.IsPlanet == 1)
            { // DA: Try to reduce saved data for planets to just seed, as is done for normal asteroids.
                if (m_materialLayers != null)
                {
                    stream.WriteNoAlloc(m_materialLayers.Length);
                    for (int i = 0; i < m_materialLayers.Length; ++i)
                    {
                        stream.WriteNoAlloc(m_materialLayers[i].StartHeight);
                        stream.WriteNoAlloc(m_materialLayers[i].EndHeight);
                        stream.WriteNoAlloc(m_materialLayers[i].MaterialName);
                        stream.WriteNoAlloc(m_materialLayers[i].StartAngle);
                        stream.WriteNoAlloc(m_materialLayers[i].EndAngle);
                        stream.WriteNoAlloc(m_materialLayers[i].HeightStartDeviation);
                        stream.WriteNoAlloc(m_materialLayers[i].AngleStartDeviation);
                        stream.WriteNoAlloc(m_materialLayers[i].HeightEndDeviation);
                        stream.WriteNoAlloc(m_materialLayers[i].AngleEndDeviation);
                    }
                }
                else
                {
                    stream.WriteNoAlloc((int)0);
                }

                stream.WriteNoAlloc(m_shapeAttributes.Seed);
                stream.WriteNoAlloc(m_shapeAttributes.Radius);
                stream.WriteNoAlloc(m_shapeAttributes.NoiseFrequency);
                stream.WriteNoAlloc(m_shapeAttributes.DeviationScale);
                stream.WriteNoAlloc(m_shapeAttributes.NormalNoiseFrequency);
                stream.WriteNoAlloc(m_shapeAttributes.LayerDeviationNoiseFreqeuncy);
                stream.WriteNoAlloc(m_shapeAttributes.LayerDeviationSeed);

                stream.WriteNoAlloc(m_hillAttributes.BlendTreshold);
                stream.WriteNoAlloc(m_hillAttributes.Treshold);
                stream.WriteNoAlloc(m_hillAttributes.SizeRatio);
                stream.WriteNoAlloc(m_hillAttributes.NumNoises);
                stream.WriteNoAlloc(m_hillAttributes.Frequency);

                stream.WriteNoAlloc(m_canyonAttributes.BlendTreshold);
                stream.WriteNoAlloc(m_canyonAttributes.Treshold);
                stream.WriteNoAlloc(m_canyonAttributes.SizeRatio);
                stream.WriteNoAlloc(m_canyonAttributes.NumNoises);
                stream.WriteNoAlloc(m_canyonAttributes.Frequency);
            }
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:52,代码来源:MyCompositeShapeProvider.cs

示例3: WriteTo

        public void WriteTo(Stream stream)
        {
            if (Layers != null)
            {
                stream.WriteNoAlloc(Layers.Length);
                for (int i = 0; i < Layers.Length; ++i)
                {
                    stream.WriteNoAlloc(Layers[i].StartHeight);
                    stream.WriteNoAlloc(Layers[i].EndHeight);
                    stream.WriteNoAlloc(Layers[i].StartAngle);
                    stream.WriteNoAlloc(Layers[i].EndAngle);
                    stream.WriteNoAlloc(Layers[i].HeightStartDeviation);
                    stream.WriteNoAlloc(Layers[i].AngleStartDeviation);
                    stream.WriteNoAlloc(Layers[i].HeightEndDeviation);
                    stream.WriteNoAlloc(Layers[i].AngleEndDeviation);
                    stream.WriteNoAlloc(Layers[i].MaterialDefinition.Id.SubtypeName);
                }
            }
            else
            {
                stream.WriteNoAlloc((int)0);
            }

            if (OreProbabilities != null)
            {
                stream.WriteNoAlloc(OreProbabilities.Length);
                for (int i = 0; i < OreProbabilities.Length; ++i)
                {
                    stream.WriteNoAlloc(OreProbabilities[i].CummulativeProbability);
                    stream.WriteNoAlloc(OreProbabilities[i].OreName);
                }
            }
            else
            {
                stream.WriteNoAlloc((int)0);
            }

            stream.WriteNoAlloc(OreStartDepth);
            stream.WriteNoAlloc(OreEndDepth);
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:40,代码来源:MyCsgShapePlanet.cs

示例4:

 void IMyStorageDataProvider.WriteTo(Stream stream)
 {
     stream.WriteNoAlloc(m_state.Version);
     stream.WriteNoAlloc(m_state.Generator);
     stream.WriteNoAlloc(m_state.Seed);
     stream.WriteNoAlloc(m_state.Size);
     stream.WriteNoAlloc(m_state.UnusedCompat);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:8,代码来源:MyCompositeShapeProvider.cs

示例5: SaveVoxelMaterial

        private void SaveVoxelMaterial(Stream stream, MyVoxelMaterialDefinition cellMaterial)
        {
            var encoding = Encoding.UTF8;

            // Old file format stored material index as byte. Replaces old index with 0xFF, followed by number of bytes for name and then name itself.
            // Names are limited to 256 bytes of UTF8 text.
            //compressFile.Add((byte)cellMaterial.Index);
            int byteLength = encoding.GetByteCount(cellMaterial.Id.SubtypeName);
            Trace.Assert(0 < byteLength && byteLength < MAX_ENCODED_NAME_LENGTH, "Length of encoded voxel material name must fit inside single byte.");
            int written = encoding.GetBytes(cellMaterial.Id.SubtypeName, 0, cellMaterial.Id.SubtypeName.Length, m_encodedNameBuffer, 0);
            Debug.Assert(written == byteLength);

            stream.WriteNoAlloc((byte)0xFF); // special value replacing old index.
            stream.WriteNoAlloc((byte)byteLength);
            stream.Write(m_encodedNameBuffer, 0, byteLength);
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:16,代码来源:MyCellStorage.cs

示例6: SaveInternal

        protected override void SaveInternal(Stream stream)
        {
            //  Size of this voxel map (in voxels)
            stream.WriteNoAlloc(Size.X);
            stream.WriteNoAlloc(Size.Y);
            stream.WriteNoAlloc(Size.Z);

            //  Size of data cell in voxels, doesn't have to be same as current size specified by our constants.
            stream.WriteNoAlloc(MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS);
            stream.WriteNoAlloc(MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS);
            stream.WriteNoAlloc(MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS);

            Vector3I cellCoord;
            for (cellCoord.X = 0; cellCoord.X < DataCellsCount.X; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < DataCellsCount.Y; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < DataCellsCount.Z; cellCoord.Z++)
                    {
                        MyVoxelContentCell voxelCell = GetContentCell(ref cellCoord);
                        if (voxelCell == null)
                        {
                            stream.WriteNoAlloc((byte)MyVoxelRangeType.FULL);
                        }
                        else
                        {
                            stream.WriteNoAlloc((byte)voxelCell.CellType);

                            //  If we are here, cell is empty or mixed. If empty, we don't need to save each individual voxel.
                            //  But if it is mixed, we will do it here.
                            if (voxelCell.CellType == MyVoxelRangeType.MIXED)
                            {
                                Vector3I voxelCoordInCell;
                                for (voxelCoordInCell.X = 0; voxelCoordInCell.X < MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.X++)
                                {
                                    for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Y++)
                                    {
                                        for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Z++)
                                        {
                                            stream.WriteNoAlloc(voxelCell.GetContent(ref voxelCoordInCell));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Save material cells
            for (cellCoord.X = 0; cellCoord.X < DataCellsCount.X; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < DataCellsCount.Y; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < DataCellsCount.Z; cellCoord.Z++)
                    {
                        var matCell = GetMaterialCell(ref cellCoord);

                        Vector3I voxelCoordInCell = new Vector3I(0, 0, 0);

                        bool isWholeMaterial = matCell.IsSingleMaterial;
                        stream.WriteNoAlloc((byte)(isWholeMaterial ? 1 : 0));
                        if (isWholeMaterial)
                        {
                            var cellMaterial = matCell.GetMaterial(ref voxelCoordInCell);
                            SaveVoxelMaterial(stream, cellMaterial);
                        }
                        else
                        {
                            const byte INDESTRUCTIBLE_CONTENT = 0;
                            for (voxelCoordInCell.X = 0; voxelCoordInCell.X < MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.X++)
                            {
                                for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Y++)
                                {
                                    for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; voxelCoordInCell.Z++)
                                    {
                                        var cellMaterial = matCell.GetMaterial(ref voxelCoordInCell);
                                        SaveVoxelMaterial(stream, cellMaterial);
                                        stream.WriteNoAlloc(INDESTRUCTIBLE_CONTENT);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:87,代码来源:MyCellStorage.cs

示例7:

        void IMyStorageDataProvider.WriteTo(Stream stream)
        {
            stream.WriteNoAlloc(m_state.Version);
            stream.WriteNoAlloc(m_state.Generator);
            stream.WriteNoAlloc(m_state.Seed);
            stream.WriteNoAlloc(m_state.Size);
            stream.WriteNoAlloc(m_state.IsPlanet);

            if (m_state.IsPlanet == 1)
            { // DA: Try to reduce saved data for planets to just seed, as is done for normal asteroids.

                m_materialAttributes.WriteTo(stream);
                m_shapeAttributes.WriteTo(stream);
                m_hillAttributes.WriteTo(stream);
                m_canyonAttributes.WriteTo(stream);          
            }
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:17,代码来源:MyCompositeShapeProvider.cs


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