public override int GetHashCode() { int hashCode = 0; unchecked { hashCode += 1000000007 * PlayerCoords.GetHashCode(); if (BoxesCoords != null) { foreach (var boxCoords in BoxesCoords) { hashCode = 1000000009 * hashCode + boxCoords.GetHashCode(); } } } return(hashCode); }
private void PaintInternal() { try { mNeedsRepaint = false; if (mHud == null || mHud.Lost) { if (mHud != null) { mHud.Dispose(); } mHud = Manager.Host.Render.CreateHud( new Rectangle(Location.X, Location.Y, CanvasWidth, CanvasHeight)); mHud.Alpha = Alpha; mHud.Enabled = Visible; } if (!IsHudVisible()) { mHud.Enabled = false; return; } double arrowAngleRadians = PlayerCoords.AngleTo(DestinationCoords) - PlayerHeadingRadians; while (arrowAngleRadians < 0) { arrowAngleRadians += 2 * Math.PI; } int imageFrame; if (mNeedToCalculateImageRotations) { imageFrame = 1; Graphics g = Graphics.FromImage(mArrowImages[1]); g.Clear(Clear); g.TranslateTransform(mArrowImages[0].Width / 2, mArrowImages[0].Height / 2); g.RotateTransform((float)(arrowAngleRadians * 180.0 / Math.PI)); g.TranslateTransform(-mArrowImages[0].Width / 2, -mArrowImages[0].Height / 2); g.DrawImage(mArrowImages[0], 0, 0, mArrowImages[0].Width, mArrowImages[0].Height); } else { imageFrame = ((int)(arrowAngleRadians / (2 * Math.PI) * mArrowImages.Length)) % mArrowImages.Length; } mArrowRect.Y = 1; mArrowRect.X = (CanvasWidth - mArrowRect.Width) / 2; Rectangle distRect = new Rectangle(1, mArrowRect.Height, CanvasWidth - 2, TextSize + 2); if (ShowDestinationOver) { mArrowRect.Y += 2 * TextSize; distRect.Y += 2 * TextSize; } //mImageFrame = newImageFrame; mHud.Clear(); // Draw move border if (mMouseHovering) { Rectangle r = new Rectangle(mArrowRect.Location, mArrowRect.Size); mHud.Fill(r, Color.Gold); r = new Rectangle(r.X + 1, r.Y + 1, r.Width - 2, r.Height - 2); mHud.Clear(r); } mHud.BeginRender(); // Draw close button if (mMouseHovering && ShowCloseButton) { Bitmap closeBox = Icons.Window.CloseBox; mCloseBoxRect = new Rectangle(mArrowRect.Right - closeBox.Width - 2, mArrowRect.Top + 2, closeBox.Width, closeBox.Height); mHud.DrawImage(Icons.Window.CloseBox, mCloseBoxRect); } else { mCloseBoxRect = Rectangle.Empty; } mRoutePrevRect = mRouteNextRect = new Rectangle(-1, -1, 0, 0); if (ShowDestinationOver || ShowDistanceUnder) { mHud.BeginText(HudFont, TextSize, TextBold ? FontWeight.Bold : FontWeight.Normal, false); if (ShowDestinationOver) { if (HasDestinationLocation) { string locationName = DestinationLocation.Name; if (HasRoute) { // Left and Right arrows on each end if (RouteIndex > 0) { locationName = "\u25C4 " + locationName; } if (RouteIndex < Route.Count - 1) { locationName += " \u25BA"; } SizeF sz = mFontMeasure.MeasureString(locationName, mFont); mRoutePrevRect = mRouteNextRect = new Rectangle(-1, -1, 0, 0); float width = 0.2f * sz.Width; if (RouteIndex > 0) { mRoutePrevRect = Rectangle.Round(new RectangleF( Location.X + (CanvasWidth - 0.9f * sz.Width) / 2.0f, Location.Y - 1, width, TextSize + 2)); } if (RouteIndex < Route.Count - 1) { mRouteNextRect = Rectangle.Round(new RectangleF( Location.X + (CanvasWidth + 0.9f * sz.Width) / 2.0f - width, Location.Y - 1, width, TextSize + 2)); } } WriteText(locationName, WriteTextFormats.Center, new Rectangle(1, 1, CanvasWidth - 2, TextSize + 2)); } else if (HasDestinationObject) { WriteText(DestinationObject.Name + (DestinationObject.IsValid ? "" : " (out of range)"), WriteTextFormats.Center, new Rectangle(1, 1, CanvasWidth - 2, TextSize + 2)); } WriteText(DestinationCoords.ToString(), WriteTextFormats.Center, new Rectangle(1, TextSize, CanvasWidth - 2, TextSize + 2)); } if (ShowDistanceUnder) { double dist = PlayerCoords.DistanceTo(DestinationCoords); WriteText(dist.ToString("0.00"), WriteTextFormats.Center, distRect); } mHud.EndText(); } mHud.DrawImage(mArrowImages[imageFrame], mArrowRect); mHud.EndRender(); mHud.Enabled = true; mLastDisplayedDestinationCoords = DestinationCoords; } catch (Exception ex) { Util.HandleException(ex); } }