unsafe void DrawAnimation(AnimationData data, int texId, int size)
        {
            TerrainAtlas1D atlas  = game.TerrainAtlas1D;
            int            index  = atlas.Get1DIndex(texId);
            int            rowNum = atlas.Get1DRowId(texId);
            byte *         temp   = stackalloc byte[size * size * 4];

            animPart.SetData(size, size, size * 4, (IntPtr)temp, false);

            if (data == null)
            {
                lavaAnim.Tick((int *)temp, size);
            }
            else
            {
                FastBitmap.MovePortion(data.FrameX + data.State * size,
                                       data.FrameY, 0, 0, animsBuffer, animPart, size);
            }
            api.UpdateTexturePart(atlas.TexIds[index], 0, rowNum * game.TerrainAtlas.elementSize, animPart);
        }
示例#2
0
        unsafe void ApplyAnimation(AnimationData data)
        {
            data.Tick--;
            if (data.Tick >= 0)
            {
                return;
            }
            data.CurrentState++;
            data.CurrentState %= data.StatesCount;
            data.Tick          = data.TickDelay;

            TerrainAtlas1D atlas  = game.TerrainAtlas1D;
            int            texId  = (data.TileY << 4) | data.TileX;
            int            index  = atlas.Get1DIndex(texId);
            int            rowNum = atlas.Get1DRowId(texId);

            int        size = data.FrameSize;
            byte *     temp = stackalloc byte[size * size * 4];
            FastBitmap part = new FastBitmap(size, size, size * 4, (IntPtr)temp);

            FastBitmap.MovePortion(data.FrameX + data.CurrentState * size, data.FrameY, 0, 0, fastBmp, part, size);
            api.UpdateTexturePart(atlas.TexIds[index], 0, rowNum * game.TerrainAtlas.elementSize, part);
        }