private short GetBuildingZ(int x, int y, ShpFile shp, ShpFile.ShpImage img, GameObject obj) { if (_noBuildingZAvailable) { return(0); } else if (BuildingZ == null) { if (_config.Engine < EngineType.YurisRevenge) { BuildingZ = _vfs.Open <ShpFile>("buildngz.shp"); } else // Yuri's Revenge uses .sha as a file extension for this { BuildingZ = _vfs.Open <ShpFile>("buildngz.sha"); } if (BuildingZ != null) { BuildingZ.Initialize(); } else { _noBuildingZAvailable = true; } } var zImg = BuildingZ.GetImage(0); byte[] zData = zImg.GetImageData(); // center x x += zImg.Width / 2 - shp.Width / 2 + img.X; // correct for foundation x -= (obj.Drawable.Foundation.Width - obj.Drawable.Foundation.Height) * 30; // add zshapepointmove x += obj.Drawable.Props.ZShapePointMove.X; // align y on bottom y += zImg.Height - shp.Height; // add zshapepointmove y -= obj.Drawable.Props.ZShapePointMove.Y; x = Math.Min(zImg.Width - 1, Math.Max(0, x)); y = Math.Min(zImg.Height - 1, Math.Max(0, y)); return((short)(-64 + zData[y * zImg.Width + x])); }
private static byte GetBuildingZ(int x, int y, ShpFile shp, ShpFile.ShpImage img, GameObject obj, DrawProperties props) { if (BuildingZ == null) { BuildingZ = VFS.Open <ShpFile>("buildngz.shp"); BuildingZ.Initialize(); } var zImg = BuildingZ.GetImage(0); byte[] zData = zImg.GetImageData(); // center x x += zImg.Width / 2; x += obj.Drawable.Foundation.Width * Drawable.TileHeight / 2; // align y y += zImg.Height - shp.Height; // y += props.ZAdjust; return(zData[y * zImg.Width + x]); }