Exemplo n.º 1
0
        public List <GameObject> GetItemsBetweenZ(int z0, int z1)
        {
            List <GameObject> items = _itemsAtZ;

            _itemsAtZ.Clear();

            for (int i = 0; i < ObjectsOnTiles.Count; i++)
            {
                if (MathHelper.InRange(ObjectsOnTiles[i].Position.Z, z0, z1))
                {
                    if (ObjectsOnTiles[i] is IDynamicItem)
                    {
                        items.Add(ObjectsOnTiles[i]);
                    }
                }
            }

            return(items);
        }
Exemplo n.º 2
0
        public static bool IsPointInCorpse(Item corpse, int xx, int yy)
        {
            if (corpse == null || World.CorpseManager.Exists(corpse.Serial, 0))
            {
                return(false);
            }

            byte dir    = (byte)((byte)corpse.Layer & 0x7F & 7);
            bool mirror = false;

            AnimationsLoader.Instance.GetAnimDirection(ref dir, ref mirror);
            AnimationsLoader.Instance.Direction = dir;
            byte animIndex = (byte)corpse.AnimIndex;

            for (int i = -1; i < Constants.USED_LAYER_COUNT; i++)
            {
                Layer layer = i == -1 ? Layer.Mount : LayerOrder.UsedLayers[dir, i];

                ushort graphic;
                ushort color = 0;

                if (layer == Layer.Invalid)
                {
                    graphic = corpse.GetGraphicForAnimation();
                    AnimationsLoader.Instance.AnimGroup = AnimationsLoader.Instance.GetDieGroupIndex(graphic, corpse.UsedLayer);
                }
                else if (corpse.HasEquipment && MathHelper.InRange(corpse.Amount, 0x0190, 0x0193) ||
                         MathHelper.InRange(corpse.Amount, 0x00B7, 0x00BA) ||
                         MathHelper.InRange(corpse.Amount, 0x025D, 0x0260) ||
                         MathHelper.InRange(corpse.Amount, 0x029A, 0x029B) ||
                         MathHelper.InRange(corpse.Amount, 0x02B6, 0x02B7) ||
                         corpse.Amount == 0x03DB || corpse.Amount == 0x03DF || corpse.Amount == 0x03E2 || corpse.Amount == 0x02E8 || corpse.Amount == 0x02E9)
                {
                    Item itemEquip = corpse.Equipment[(int)layer];

                    if (itemEquip == null)
                    {
                        continue;
                    }

                    graphic = itemEquip.ItemData.AnimID;

                    if (AnimationsLoader.Instance.EquipConversions.TryGetValue(corpse.Amount, out Dictionary <ushort, EquipConvData> map))
                    {
                        if (map.TryGetValue(graphic, out EquipConvData data))
                        {
                            graphic = data.Graphic;
                        }
                    }
                }
                else
                {
                    continue;
                }


                byte animGroup = AnimationsLoader.Instance.AnimGroup;

                AnimationGroup gr = layer == Layer.Invalid
                                        ? AnimationsLoader.Instance.GetCorpseAnimationGroup(ref graphic, ref animGroup, ref color)
                                        : AnimationsLoader.Instance.GetBodyAnimationGroup(ref graphic, ref animGroup, ref color);

                AnimationDirection direction = gr.Direction[AnimationsLoader.Instance.Direction];

                if (direction == null || ((direction.FrameCount == 0 || direction.Frames == null) && !AnimationsLoader.Instance.LoadDirectionGroup(ref direction)))
                {
                    continue;
                }

                int fc = direction.FrameCount;

                if (fc > 0 && animIndex >= fc)
                {
                    animIndex = (byte)(fc - 1);
                }

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

                    if (frame == null || frame.IsDisposed)
                    {
                        continue;
                    }

                    int       drawCenterY = frame.CenterY;
                    const int drawX       = -22;
                    int       drawY       = drawCenterY - 22;
                    drawY -= 3;
                    int x = drawX + frame.CenterX;
                    int y = -drawY - (frame.Height + frame.CenterY) + drawCenterY;

                    if (mirror)
                    {
                        x = xx + x + 44 - TranslatedMousePositionByViewport.X;
                    }
                    else
                    {
                        x = TranslatedMousePositionByViewport.X - xx + x;
                    }

                    y = TranslatedMousePositionByViewport.Y - yy + y;

                    if (frame.Contains(x, y))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        private bool DrawCorpse(UltimaBatcher2D batcher, int posX, int posY, Vector3 hueVec, float depth)
        {
            if (IsDestroyed || World.CorpseManager.Exists(Serial, 0))
            {
                return(false);
            }

            posX += 22;
            posY += 22;

            byte direction = (byte)((byte)Layer & 0x7F & 7);

            AnimationsLoader.Instance.GetAnimDirection(ref direction, ref IsFlipped);

            byte   animIndex = (byte)AnimIndex;
            ushort graphic   = GetGraphicForAnimation();

            AnimationsLoader.Instance.ConvertBodyIfNeeded(ref graphic);
            byte group = AnimationsLoader.Instance.GetDieGroupIndex(graphic, UsedLayer);

            bool ishuman = MathHelper.InRange(Amount, 0x0190, 0x0193) || MathHelper.InRange(Amount, 0x00B7, 0x00BA) || MathHelper.InRange(Amount, 0x025D, 0x0260) || MathHelper.InRange(Amount, 0x029A, 0x029B) || MathHelper.InRange(Amount, 0x02B6, 0x02B7) || Amount == 0x03DB || Amount == 0x03DF || Amount == 0x03E2 || Amount == 0x02E8 || Amount == 0x02E9;

            DrawLayer
            (
                batcher,
                posX,
                posY,
                this,
                Layer.Invalid,
                animIndex,
                ishuman,
                Hue,
                IsFlipped,
                hueVec.Z,
                group,
                direction,
                hueVec,
                depth
            );

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

                DrawLayer
                (
                    batcher,
                    posX,
                    posY,
                    this,
                    layer,
                    animIndex,
                    ishuman,
                    0,
                    IsFlipped,
                    hueVec.Z,
                    group,
                    direction,
                    hueVec,
                    depth
                );
            }

            return(true);
        }