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 SideDef FromData(byte[] data, int offset, TextureLookup textures, Sector[] sectors) { var textureOffset = BitConverter.ToInt16(data, offset); var rowOffset = BitConverter.ToInt16(data, offset + 2); var topTextureName = DoomInterop.ToString(data, offset + 4, 8); var bottomTextureName = DoomInterop.ToString(data, offset + 12, 8); var middleTextureName = DoomInterop.ToString(data, offset + 20, 8); var sectorNum = BitConverter.ToInt16(data, offset + 28); return(new SideDef( Fixed.FromInt(textureOffset), Fixed.FromInt(rowOffset), textures.GetNumber(topTextureName), textures.GetNumber(bottomTextureName), textures.GetNumber(middleTextureName), sectorNum != -1 ? sectors[sectorNum] : null)); }