コード例 #1
0
ファイル: StructureWriter.cs プロジェクト: ChadSki/Assembly
        public void VisitBasicField(string name, StructureValueType type, int offset)
        {
            // Skip over the field if it isn't in the value collection
            if (type == StructureValueType.Asciiz)
            {
                if (!_collection.HasString(name))
                {
                    return;
                }
            }
            else if (!_collection.HasInteger(name))
            {
                return;
            }

            SeekWriter(offset);
            switch (type)
            {
            case StructureValueType.Byte:
                _writer.WriteByte((byte)_collection.GetInteger(name));
                _offset++;
                break;

            case StructureValueType.SByte:
                _writer.WriteSByte((sbyte)_collection.GetInteger(name));
                _offset++;
                break;

            case StructureValueType.UInt16:
                _writer.WriteUInt16((ushort)_collection.GetInteger(name));
                _offset += 2;
                break;

            case StructureValueType.Int16:
                _writer.WriteInt16((short)_collection.GetInteger(name));
                _offset += 2;
                break;

            case StructureValueType.UInt32:
                _writer.WriteUInt32(_collection.GetInteger(name));
                _offset += 4;
                break;

            case StructureValueType.Int32:
                _writer.WriteInt32((int)_collection.GetInteger(name));
                _offset += 4;
                break;

            case StructureValueType.Asciiz:
                _writer.WriteAscii(_collection.GetString(name));
                _offset = _writer.Position;
                break;

            case StructureValueType.Float32:
                _writer.WriteFloat(_collection.GetFloat(name));
                _offset += 4;
                break;
            }
        }
コード例 #2
0
 private void Load(StructureValueCollection values)
 {
     MinX = values.GetFloat("min x");
     MaxX = values.GetFloat("max x");
     MinY = values.GetFloat("min y");
     MaxY = values.GetFloat("max y");
     MinZ = values.GetFloat("min z");
     MaxZ = values.GetFloat("max z");
     MinU = values.GetFloat("min u");
     MaxU = values.GetFloat("max u");
     MinV = values.GetFloat("min v");
     MaxV = values.GetFloat("max v");
 }
コード例 #3
0
ファイル: BoundingBox.cs プロジェクト: ChadSki/Assembly
 /// <summary>
 ///     Deserializes a bounding box from a set of values read from a structure.
 /// </summary>
 /// <param name="values">The values to use.</param>
 /// <returns>The bounding box.</returns>
 public static BoundingBox Deserialize(StructureValueCollection values)
 {
     var result = new BoundingBox();
     result.MinX = values.GetFloat("min x");
     result.MaxX = values.GetFloat("max x");
     result.MinY = values.GetFloat("min y");
     result.MaxY = values.GetFloat("max y");
     result.MinZ = values.GetFloat("min z");
     result.MaxZ = values.GetFloat("max z");
     result.MinU = values.GetFloat("min u");
     result.MaxU = values.GetFloat("max u");
     result.MinV = values.GetFloat("min v");
     result.MaxV = values.GetFloat("max v");
     result.Unknown1 = (int) values.GetIntegerOrDefault("unknown 1", 3);
     result.Unknown2 = (int) values.GetIntegerOrDefault("unknown 2", 0);
     result.Unknown3 = (int) values.GetIntegerOrDefault("unknown 3", 0);
     result.Unknown4 = (int) values.GetIntegerOrDefault("unknown 4", 0);
     return result;
 }