public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag) { if (Entity.IsDisposed) { return(false); } // get a z index underneath all this mobile's sprite layers. We will place the shadow on this z index. DrawShadowZDepth = spriteBatch.GetNextUniqueZ(); // get running moving and sitting booleans, which are used when drawing mobiles but not corpses. bool isRunning = false, isMoving = false, isSitting = false; if (Entity is Mobile) { isRunning = (Entity as Mobile).IsRunning; isMoving = (Entity as Mobile).IsMoving; isSitting = (Entity as Mobile).IsSitting; } // flip the facing (anim directions are reversed from the client-server protocol's directions). DrawFlip = (MirrorFacingForDraw(Facing) > 4) ? true : false; InternalSetupLayers(); int drawCenterY = m_MobileLayers[0].Frame.Center.Y; int drawX, drawY; if (DrawFlip) { drawX = -IsometricRenderer.TILE_SIZE_INTEGER_HALF + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); } else { drawX = -IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); } if (isSitting) { drawX -= 1; drawY -= 6 + (Entity as Mobile).ChairData.SittingPixelOffset; if (Facing == Direction.North || Facing == Direction.West) { drawY -= 16; } } IsShadowCastingView = !isSitting; // get the maximum y-extent of this object so we can correctly place overheads. int yOffset = 0; for (int i = 0; i < m_LayerCount; i++) { if (m_MobileLayers[i].Frame != null) { float x = (drawX + m_MobileLayers[i].Frame.Center.X); float y = -drawY - (m_MobileLayers[i].Frame.Texture.Height + m_MobileLayers[i].Frame.Center.Y) + drawCenterY; if (yOffset > y) { yOffset = (int)y; } DrawTexture = m_MobileLayers[i].Frame.Texture; DrawArea = new Rectangle((int)x, (int)-y, DrawTexture.Width, DrawTexture.Height); HueVector = Utility.GetHueVector(m_MobileLayers[i].Hue); base.Draw(spriteBatch, drawPosition, mouseOverList, map, roofHideFlag); } } Vector3 overheadDrawPosition = new Vector3(drawPosition.X + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF), drawPosition.Y - (int)((Entity.Position.Z_offset + Entity.Z) * 4), drawPosition.Z); if (m_MobileLayers[0].Frame != null) { yOffset = m_MobileLayers[0].Frame.Texture.Height + drawY - (int)((Entity.Z + Entity.Position.Z_offset) * 4); } else { yOffset = -(yOffset + IsometricRenderer.TILE_SIZE_INTEGER); } // this is where we would draw the reverse of the chair texture. bool isMounted = (Entity is Mobile) ? (Entity as Mobile).IsMounted ? true : false : false; DrawOverheads(spriteBatch, overheadDrawPosition, mouseOverList, map, isMounted ? yOffset + 16 : yOffset); return(true); }
// ============================================================================================================ // draw // ============================================================================================================ public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag) { if (Entity.IsDisposed) { return(false); } // get a z index underneath all this mobile's sprite layers. We will place the shadow on this z index. DrawShadowZDepth = spriteBatch.GetNextUniqueZ(); // get running moving and sitting booleans, which are used when drawing mobiles but not corpses. bool isRunning = false, isMoving = false, isSitting = false; if (Entity is Mobile) { isRunning = (Entity as Mobile).IsRunning; isMoving = (Entity as Mobile).IsMoving; isSitting = (Entity as Mobile).IsSitting; } // flip the facing (anim directions are reversed from the client-server protocol's directions). DrawFlip = (MirrorFacingForDraw(Facing) > 4); InternalSetupLayers(); if (_mobileLayers[0].Frame == null) { _mobileLayers[0].Frame = AnimationFrame.NullFrame; } var drawCenterY = _mobileLayers[0].Frame.Center.y; int drawX; int drawY; if (DrawFlip) { drawX = -IsometricRenderer.TILE_SIZE_INTEGER_HALF + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); } else { drawX = -IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF); } if (isSitting) { drawX -= 1; drawY -= 6 + (Entity as Mobile).ChairData.SittingPixelOffset; if (Facing == Direction.North || Facing == Direction.West) { drawY -= 16; } } IsShadowCastingView = !isSitting; var yOffset = 0; for (var i = 0; i < _layerCount; i++) { if (_mobileLayers[i].Frame != null) { var frame = _mobileLayers[i].Frame; var x = (drawX + frame.Center.x); var y = -drawY - (frame.Texture.Height + frame.Center.y) + drawCenterY; if (yOffset > y) { yOffset = y; } DrawTexture = frame.Texture; DrawArea = new RectInt(x, -y, DrawTexture.Width, DrawTexture.Height); HueVector = Utility.GetHueVector(_mobileLayers[i].Hue); base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag); MobilePick(mouseOver, drawPosition, DrawArea, frame); } } var overheadDrawPosition = new Vector3(drawPosition.x + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF), drawPosition.y - (int)((Entity.Position.Z_offset + Entity.Z) * 4), drawPosition.z); if (_mobileLayers[0].Frame != null) { yOffset = _mobileLayers[0].Frame.Texture.Height + drawY - (int)((Entity.Z + Entity.Position.Z_offset) * 4); } else { yOffset = -(yOffset + IsometricRenderer.TILE_SIZE_INTEGER); } // this is where we would draw the reverse of the chair texture. var isMounted = Entity is Mobile && (Entity as Mobile).IsMounted; DrawOverheads(spriteBatch, overheadDrawPosition, mouseOver, map, isMounted ? yOffset + 16 : yOffset); return(true); }