public StaticProps(BinaryReader reader, long length, int version) { var startPosition = reader.BaseStream.Position; var modelCount = reader.ReadInt32(); Models = new List <string>(modelCount); for (var i = 0; i < modelCount; i++) { var bytes = reader.ReadBytes(128); string entry = Encoding.ASCII.GetString(bytes); Models.Add(entry.Replace("\0", string.Empty).Trim()); } var leafCount = reader.ReadInt32(); Leafs = new List <ushort>(leafCount); for (var i = 0; i < leafCount; i++) { Leafs.Add(reader.ReadUInt16()); } var remainingLength = length - reader.BaseStream.Position + startPosition; var propCount = reader.ReadInt32(); Props = new List <StaticProp>(propCount); for (int i = 0; i < propCount; i++) { Props.Add(StaticProp.Read(reader, version)); } }
public static StaticProp Read(BinaryReader reader, int version) { var start = reader.BaseStream.Position; var staticProp = new StaticProp(); staticProp.Origin = reader.ReadStruct <Vector3>(); staticProp.Angles = reader.ReadStruct <Vector3>(); staticProp.PropType = reader.ReadUInt16(); staticProp.FirstLeaf = reader.ReadUInt16(); staticProp.LeafCount = reader.ReadUInt16(); staticProp.Solid = reader.ReadByte() == 1; staticProp.Flags = (StaticPropFlags)reader.ReadByte(); staticProp.Skin = reader.ReadInt32(); staticProp.FadeMinDistance = reader.ReadSingle(); staticProp.FadeMaxDistance = reader.ReadSingle(); staticProp.LightingOrigin = reader.ReadStruct <Vector3>(); if (version >= 5) { staticProp.ForcedFadeScale = reader.ReadSingle(); } if (version == 6 || version == 7) { staticProp.MinDxLevel = reader.ReadUInt16(); staticProp.MaxDxLevel = reader.ReadUInt16(); } if (version >= 8) { staticProp.MinCpuLevel = reader.ReadByte(); staticProp.MaxCpuLevel = reader.ReadByte(); staticProp.MinGpuLevel = reader.ReadByte(); staticProp.MaxGpuLevel = reader.ReadByte(); } if (version >= 7) { staticProp.DiffuseModulation = reader.ReadUInt32(); } if (version >= 10) { staticProp.Unknown = reader.ReadSingle(); } if (version >= 9) { staticProp.DisableX360 = reader.ReadInt32() == 1; } var structLength = reader.BaseStream.Position - start; return(staticProp); }