Пример #1
0
        public void DrawRecorderItem(ref RecorderFrameItem frame)
        {
            MTSpriteBatchItem batchItem = this._batcher.CreateBatchItem();

            batchItem.Depth = frame.depth;
            if (frame.texture == (short)-1)
            {
                batchItem.Texture = DuckGame.Graphics.blankWhiteSquare.nativeObject as Texture2D;
            }
            else
            {
                Tex2D tex2DfromIndex = Content.GetTex2DFromIndex(frame.texture);
                if (tex2DfromIndex == null)
                {
                    return;
                }
                batchItem.Texture = tex2DfromIndex.nativeObject as Texture2D;
            }
            if (batchItem.Texture == null)
            {
                return;
            }
            float num1 = (float)Math.Abs(frame.texW);
            float num2 = (float)Math.Abs(frame.texH);

            this._texCoordTL.x = (float)((double)frame.texX / (double)batchItem.Texture.Width + 9.99999974737875E-06);
            this._texCoordTL.y = (float)((double)frame.texY / (double)batchItem.Texture.Height + 9.99999974737875E-06);
            this._texCoordBR.x = (float)(((double)frame.texX + (double)num1) / (double)batchItem.Texture.Width - 9.99999974737875E-06);
            this._texCoordBR.y = (float)(((double)frame.texY + (double)num2) / (double)batchItem.Texture.Height - 9.99999974737875E-06);
            if (frame.texH < (short)0)
            {
                float y = this._texCoordBR.y;
                this._texCoordBR.y = this._texCoordTL.y;
                this._texCoordTL.y = y;
            }
            if (frame.texW < (short)0)
            {
                float x = this._texCoordBR.x;
                this._texCoordBR.x = this._texCoordTL.x;
                this._texCoordTL.x = x;
            }
            Vec2 vec2 = frame.bottomRight.Rotate(-frame.rotation, frame.topLeft);

            batchItem.Set(frame.topLeft.x, frame.topLeft.y, 0.0f, 0.0f, vec2.x - frame.topLeft.x, vec2.y - frame.topLeft.y, (float)Math.Sin((double)frame.rotation), (float)Math.Cos((double)frame.rotation), frame.color, this._texCoordTL, this._texCoordBR);
        }
        public void Render(ref RecorderFrame lerpFrame, float dist)
        {
            bool flag = false;

            DuckGame.Graphics.Clear(Color.Lerp(this.backgroundColor, lerpFrame.backgroundColor, dist) * DuckGame.Graphics.fade);
            for (int key = 0; key < this.currentObject; ++key)
            {
                if (this._states.ContainsKey(key))
                {
                    if (flag)
                    {
                        DuckGame.Graphics.screen.End();
                    }
                    RecorderFrameStateChange state = this._states[key];
                    if (lerpFrame.HasStateWithIndex(state.stateIndex))
                    {
                        lerpFrame.GetStateWithIndex(state.stateIndex);
                    }
                    flag = true;
                    DuckGame.Graphics.SetScissorRectangle(state.scissor);
                    DuckGame.Graphics.screen.Begin(state.sortMode, state.blendState, state.samplerState, state.depthStencilState, state.rasterizerState, Content.GetMTEffectFromIndex(state.effectIndex), state.camera);
                }
                RecorderFrameItem lerpTo = this.objects[key];
                lerpFrame.sortedObjects.TryGetValue(lerpTo.spriteThingDraw, out lerpTo);
                if ((double)(lerpTo.topLeft - this.objects[key].topLeft).lengthSq > 2048.0)
                {
                    lerpTo = this.objects[key];
                }
                DuckGame.Graphics.DrawRecorderItemLerped(ref this.objects[key], ref lerpTo, dist);
            }
            if (!flag)
            {
                return;
            }
            DuckGame.Graphics.screen.End();
        }