public TextureAnimation(TextureLookup textures, FlatLookup flats) { try { Console.Write("Load texture animation info: "); var list = new List <TextureAnimationInfo>(); foreach (var animDef in DoomInfo.TextureAnimation) { int picNum; int basePic; if (animDef.IsTexture) { if (textures.GetNumber(animDef.StartName) == -1) { continue; } picNum = textures.GetNumber(animDef.EndName); basePic = textures.GetNumber(animDef.StartName); } else { if (flats.GetNumber(animDef.StartName) == -1) { continue; } picNum = flats.GetNumber(animDef.EndName); basePic = flats.GetNumber(animDef.StartName); } var anim = new TextureAnimationInfo( animDef.IsTexture, picNum, basePic, picNum - basePic + 1, animDef.Speed); if (anim.NumPics < 2) { throw new Exception("Bad animation cycle from " + animDef.StartName + " to " + animDef.EndName + "!"); } list.Add(anim); } animations = list.ToArray(); Console.WriteLine("OK"); } catch (Exception e) { Console.WriteLine("Failed"); ExceptionDispatchInfo.Throw(e); } }
public static Sector FromData(byte[] data, int offset, int number, FlatLookup flats) { var floorHeight = BitConverter.ToInt16(data, offset); var ceilingHeight = BitConverter.ToInt16(data, offset + 2); var floorFlatName = DoomInterop.ToString(data, offset + 4, 8); var ceilingFlatName = DoomInterop.ToString(data, offset + 12, 8); var lightLevel = BitConverter.ToInt16(data, offset + 20); var special = BitConverter.ToInt16(data, offset + 22); var tag = BitConverter.ToInt16(data, offset + 24); return(new Sector( number, Fixed.FromInt(floorHeight), Fixed.FromInt(ceilingHeight), flats.GetNumber(floorFlatName), flats.GetNumber(ceilingFlatName), lightLevel, (SectorSpecial)special, tag)); }