Example #1
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
#if !ORIONSORT
            ShadowZDepth = spriteBatch.GetZ();
#endif
            Mobile mobile = (Mobile)GameObject;
            bool   mirror = false;
            byte   dir    = (byte)mobile.GetDirectionForAnimation();
            Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped = mirror;
            int mountOffset = 0;
            SetupLayers(dir, ref mobile, ref mountOffset);
            ref TextureAnimationFrame bodyFrame = ref _frames[0].Frame;
Example #2
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
#if !ORIONSORT
            PreDraw(position);
#endif

            if (GameObject.IsDisposed)
            {
                return(false);
            }
            Item item = (Item)GameObject;
#if !ORIONSORT
            spriteBatch.GetZ();
#endif
            byte dir    = (byte)((byte)item.Layer & 0x7F & 7);
            bool mirror = false;
            Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped            = mirror;
            Animations.Direction = dir;
            byte animIndex = (byte)GameObject.AnimIndex;

            for (int i = 0; i < LayerOrder.USED_LAYER_COUNT; i++)
            {
                Layer layer = LayerOrder.UsedLayers[dir, i];

                if (layer == Layer.Mount)
                {
                    continue;
                }
                Graphic graphic;
                Hue     color;

                if (layer == Layer.Invalid)
                {
                    graphic = item.DisplayedGraphic;
                    Animations.AnimGroup = Animations.GetDieGroupIndex(item.GetMountAnimation(), item.UsedLayer);
                    color = GameObject.Hue;
                }
                else
                {
                    Item itemEquip = item.Equipment[(int)layer];

                    if (itemEquip == null)
                    {
                        continue;
                    }
                    graphic = itemEquip.ItemData.AnimID;

                    if (Animations.EquipConversions.TryGetValue(itemEquip.Graphic, out Dictionary <ushort, EquipConvData> map))
                    {
                        if (map.TryGetValue(itemEquip.ItemData.AnimID, out EquipConvData data))
                        {
                            graphic = data.Graphic;
                        }
                    }

                    color = itemEquip.Hue;
                }

                Animations.AnimID = graphic;
                ref AnimationDirection direction = ref Animations.DataIndex[Animations.AnimID].Groups[Animations.AnimGroup].Direction[Animations.Direction];

                if (direction.FrameCount == 0 && !Animations.LoadDirectionGroup(ref direction))
                {
                    return(false);
                }
                direction.LastAccessTime = CoreGame.Ticks;
                int fc = direction.FrameCount;
                if (fc > 0 && animIndex >= fc)
                {
                    animIndex = (byte)(fc - 1);
                }

                if (animIndex < direction.FrameCount)
                {
                    TextureAnimationFrame frame = direction.Frames[animIndex];

                    if (frame == null || frame.IsDisposed)
                    {
                        return(false);
                    }
                    int       drawCenterY = frame.CenterY;
                    const int drawX       = -22;
                    int       drawY       = drawCenterY + GameObject.Position.Z * 4 - 22 - 3;
                    int       x           = drawX + frame.CenterX;
                    int       y           = -drawY - (frame.Height + frame.CenterY) + drawCenterY;
                    Texture   = frame;
                    Bounds    = new Rectangle(x, -y, frame.Width, frame.Height);
                    HueVector = RenderExtentions.GetHueVector(color);
                    base.Draw(spriteBatch, position, objectList);
                    Pick(frame.ID, Bounds, position, objectList);
                }
            }