Example #1
0
 public void SetZoom(WorldZoom zoom)
 {
     Zoom = zoom;
     if (Camera != null)
     {
         Camera.Zoom = zoom;
     }
 }
Example #2
0
        public void InitiateSmoothZoom(WorldZoom zoom)
        {
            SmoothZoomTimer = 0;
            var curScale  = (1 << (3 - (int)State.Zoom));
            var zoomScale = (1 << (3 - (int)zoom));

            SmoothZoomFrom    = (float)zoomScale / curScale;
            State.PreciseZoom = SmoothZoomFrom;
        }
Example #3
0
        public override Texture2D DrawFrame(World world)
        {
            if (LastZoom != world.State.Zoom)
            {
                LastZoom = world.State.Zoom;
                RecalculateTarget();
            }
            var GD    = GameFacade.GraphicsDevice;
            var batch = new SpriteBatch(GD);

            GD.SetRenderTarget(Texture);
            GD.Clear(Color.Transparent);
            batch.Begin();

            if (BGSprite != null)
            {
                batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);
            }

            Texture2D main   = null;
            Vector2   offset = new Vector2();

            if (Sprite != null)
            {
                var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                main   = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                offset = new Vector2(0, 4);
            }
            else if (AlgTex != null)
            {
                main   = AlgTex;
                offset = new Vector2(0, -6);
            }
            offset /= ZoomToDiv[(int)LastZoom];

            if (main != null)
            {
                batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);
            }

            if (Headline.Operand.Crossed)
            {
                Texture2D Cross = Sprites.Get <SPR>(67).Frames[ZoomFrame].GetTexture(GD);
                batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 2), Color.White);
            }



            batch.End();
            GD.SetRenderTarget(null);

            return(Texture);
        }
Example #4
0
        public void InitiateSmoothZoom(WorldZoom zoom)
        {
            if (!WorldConfig.Current.SmoothZoom)
            {
                return;
            }
            SmoothZoomTimer = 0;
            var curScale  = (1 << (3 - (int)State.Zoom));
            var zoomScale = (1 << (3 - (int)zoom));

            SmoothZoomFrom    = (float)zoomScale / curScale;
            State.PreciseZoom = SmoothZoomFrom;
        }
Example #5
0
        public void SetTargetZoom(WorldZoom zoom)
        {
            switch (zoom)
            {
            case WorldZoom.Near:
                TargetZoom = 1f; break;

            case WorldZoom.Medium:
                TargetZoom = 0.5f; break;

            case WorldZoom.Far:
                TargetZoom = 0.25f; break;
            }
            LastZoom = World.State.Zoom;
        }
Example #6
0
        public UIHeadlineRenderer(VMRuntimeHeadline headline)
            : base(headline)
        {
            if (Sprites == null)
            {
                Sprites = new Files.Formats.IFF.IffFile(Content.Content.Get().GetPath("objectdata/globals/sprites.iff"));
                WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
            }

            if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
                Sprite = Sprites.Get<SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));

            if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
                BGSprite = Sprites.Get<SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));

            LastZoom = WorldZoom.Near;
            RecalculateTarget();
        }
        public UIHeadlineRenderer(VMRuntimeHeadline headline) : base(headline)
        {
            if (Sprites == null)
            {
                Sprites = new FSO.Files.Formats.IFF.IffFile(FSO.Content.Content.Get().GetPath("objectdata/globals/sprites.iff"));
                WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
            }

            if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
            {
                Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
            }

            if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
            {
                BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
            }

            LastZoom = WorldZoom.Near;
            RecalculateTarget();
        }
Example #8
0
        public UIHeadlineRenderer(VMRuntimeHeadline headline) : base(headline)
        {
            if (Sprites == null)
            {
                var content = FSO.Content.Content.Get();
                Sprites = new FSO.Files.Formats.IFF.IffFile(
                    content.TS1?
                    Path.Combine(content.TS1BasePath, "GameData/Sprites.iff") :
                    content.GetPath("objectdata/globals/sprites.iff")
                    );
            }

            if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
            {
                Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
            }

            if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
            {
                BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
            }

            LastZoom = WorldZoom.Near;
        }
 void ucp_OnZoomChanged(WorldZoom zoom)
 {
     World.State.Zoom = zoom;
     //Scene.Zoom = zoom;
 }
        public override Texture2D DrawFrame(World world)
        {
            if (LastZoom != world.State.Zoom || Texture == null)
            {
                Invalidated = true;
                LastZoom    = world.State.Zoom;
                RecalculateTarget();
                if (Texture == null)
                {
                    return(null);
                }
            }
            var GD    = GameFacade.GraphicsDevice;
            var batch = GameFacade.Screens.SpriteBatch;

            if (DrawSkill)
            {
                ProcessSkill();
            }
            else if (Headline.Anim % 15 == 0 && Sprite != null && Sprite.Frames.Count > 3)
            {
                Invalidated = true;
            }

            if (Invalidated) //todo: logic for drawing skills less often
            {
                GD.SetRenderTarget(Texture);
                GD.Clear(Color.Transparent);
                batch.Begin();

                if (BGSprite != null)
                {
                    batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);
                }

                Texture2D main   = null;
                Vector2   offset = new Vector2();
                if (Sprite != null)
                {
                    var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                    main   = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                    offset = new Vector2(0, 4);
                }
                else if (AlgTex != null)
                {
                    main   = AlgTex;
                    offset = new Vector2(0, -6);
                }
                offset /= ZoomToDiv[(int)LastZoom];

                if (main != null && Texture != null)
                {
                    batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);
                }

                if (Headline.Operand.Crossed)
                {
                    Texture2D Cross = Sprites.Get <SPR>(0x67).Frames[ZoomFrame].GetTexture(GD);
                    batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 4), Color.White);
                }

                if (DrawSkill)
                {
                    batch.Draw(WhitePx, new Rectangle(88, 4, 71, 41), new Color(92, 92, 92));
                    var font = GameFacade.MainFont.GetNearest(14).Font;

                    Vector2 fontOrigin = font.MeasureString(SkillString) / 2;
                    batch.DrawString(font, SkillString, new Vector2(88 + 35, 15) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);

                    fontOrigin = font.MeasureString(SpeedString) / 2;
                    batch.DrawString(font, SpeedString, new Vector2(88 + 35, 34) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);
                }

                batch.End();
                GD.SetRenderTarget(null);
                Invalidated = false;
            }

            return(Texture);
        }
Example #11
0
        public void DrawFloor(GraphicsDevice gd, Effect e, WorldZoom zoom, WorldRotation rot, List <Texture2D> roommaps, HashSet <sbyte> floors, EffectPass pass,
                              Matrix?lightWorld = null, WorldState state = null, int minFloor = 0)
        {
            var parallax = WorldConfig.Current.Complex;
            //assumes the effect and all its parameters have been set up already
            //we just need to get the right texture and offset
            var flrContent = Content.Content.Get().WorldFloors;

            e.Parameters["TexOffset"].SetValue(new Vector2());// TexOffset[zoom]*-1f);
            var tmat = TexMat[rot];

            e.Parameters["TexMatrix"].SetValue(tmat);

            var f = 0;

            foreach (var floor in Floors)
            {
                if (!floors.Contains((sbyte)(f++)))
                {
                    continue;
                }

                Matrix worldmat;
                if (lightWorld == null)
                {
                    worldmat = Matrix.CreateTranslation(0, 2.95f * (f - 1) * 3 - Bp.BaseAlt * Bp.TerrainFactor * 3, 0);
                }
                else
                {
                    worldmat = Matrix.CreateScale(1, 0, 1) * Matrix.CreateTranslation(0, 1f * (f - (1 + minFloor)), 0) * lightWorld.Value;
                    e.Parameters["DiffuseColor"].SetValue(new Vector4(1, 1, 1, 1) * (float)(6 - (f - (minFloor))) / 5f);
                }

                e.Parameters["World"].SetValue(worldmat);
                e.Parameters["Level"].SetValue((float)(f - ((lightWorld == null)?0.999f:1f)));
                if (roommaps != null)
                {
                    e.Parameters["RoomMap"].SetValue(roommaps[f - 1]);
                }
                foreach (var type in floor.GroupForTileType)
                {
                    bool water = false;
                    var  dat   = type.Value.GPUData;
                    if (dat == null)
                    {
                        continue;
                    }
                    gd.Indices = dat;

                    var       id         = type.Key;
                    var       doubleDraw = false;
                    Texture2D SPR        = null;
                    Texture2D pSPR       = null;

                    if (id == 0)
                    {
                        e.Parameters["UseTexture"].SetValue(false);
                        e.Parameters["IgnoreColor"].SetValue(false);
                        e.Parameters["GrassShininess"].SetValue(0.02f);// (float)0.25);
                    }
                    else
                    {
                        e.Parameters["GrassShininess"].SetValue((id >= 65503)?0.02f:0f);
                        if (id >= 65503)
                        {
                            if (id == 65503)
                            {
                                water = true;
                                var airTiles = TextureGenerator.GetAirTiles(gd);
                                switch (zoom)
                                {
                                case WorldZoom.Far:
                                    SPR = airTiles[2];
                                    break;

                                case WorldZoom.Medium:
                                    SPR = airTiles[1];
                                    break;

                                case WorldZoom.Near:
                                    SPR = airTiles[0];
                                    break;
                                }
                            }
                            else
                            {
                                e.Parameters["Water"].SetValue(true);
                                var pool = id >= 65520;
                                water = true;
                                if (!pool)
                                {
                                    e.Parameters["UseTexture"].SetValue(false);
                                    e.Parameters["IgnoreColor"].SetValue(false);

                                    //quickly draw under the water
                                    pass.Apply();
                                    gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, type.Value.GeomForOffset.Count * 2);

                                    e.Parameters["UseTexture"].SetValue(true);
                                    e.Parameters["IgnoreColor"].SetValue(true);
                                    if (lightWorld == null)
                                    {
                                        e.Parameters["World"].SetValue(worldmat * Matrix.CreateTranslation(0, 0.05f, 0));
                                    }
                                    id -= 65504;
                                }
                                else
                                {
                                    id -= 65520;
                                }

                                e.Parameters["TexMatrix"].SetValue(CounterTexMat[rot]);

                                var roti = (int)rot;
                                roti = (4 - roti) % 4;
                                id   = (ushort)(((id << roti) & 15) | (id >> (4 - roti)));
                                //pools & water are drawn with special logic, and may also be drawn slightly above the ground.

                                int baseSPR;
                                int frameNum = 0;
                                if (state != null)
                                {
                                    if (PoolReplace != null && pool)
                                    {
                                        SPR = PoolReplace[id];
                                        if (parallax)
                                        {
                                            pSPR = PoolReplaceParallax[id];
                                        }
                                    }
                                    else
                                    {
                                        switch (zoom)
                                        {
                                        case WorldZoom.Far:
                                            baseSPR  = (pool) ? 0x400 : 0x800;
                                            frameNum = (pool) ? 0 : 2;
                                            SPR      = state._2D.GetTexture(flrContent.GetGlobalSPR((ushort)(baseSPR + id)).Frames[frameNum]);
                                            break;

                                        case WorldZoom.Medium:
                                            baseSPR  = (pool) ? 0x410 : 0x800;
                                            frameNum = (pool) ? 0 : 1;
                                            SPR      = state._2D.GetTexture(flrContent.GetGlobalSPR((ushort)(baseSPR + id)).Frames[frameNum]);
                                            break;

                                        default:
                                            baseSPR = (pool) ? 0x420 : 0x800;
                                            SPR     = state._2D.GetTexture(flrContent.GetGlobalSPR((ushort)(baseSPR + id)).Frames[frameNum]);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            var flr = flrContent.Get(id);

                            if (flr == null)
                            {
                                continue;
                            }

                            if (state != null)
                            {
                                switch (zoom)
                                {
                                case WorldZoom.Far:
                                    SPR = state._2D.GetTexture(flr.Far.Frames[0]);
                                    break;

                                case WorldZoom.Medium:
                                    SPR = state._2D.GetTexture(flr.Medium.Frames[0]);
                                    break;

                                default:
                                    SPR = state._2D.GetTexture(flr.Near.Frames[0]);
                                    break;
                                }
                            }
                        }

                        //e.Parameters["UseTexture"].SetValue(SPR != null);
                    }

                    e.Parameters["BaseTex"].SetValue(SPR);
                    if (SPR != null && SPR.Name == null)
                    {
                        doubleDraw = true;
                        SPR.Name   = Alt.ToString();
                    }
                    if (pSPR != null)
                    {
                        var parallaxPass = e.CurrentTechnique.Passes[4];
                        e.Parameters["ParallaxTex"].SetValue(pSPR);
                        e.Parameters["ParallaxUVTexMat"].SetValue(new Vector4(0.7071f, -0.7071f, 0.7071f, 0.7071f));
                        e.Parameters["ParallaxHeight"].SetValue(0.1f);
                        parallaxPass.Apply();
                    }
                    else
                    {
                        pass.Apply();
                    }
                    if (Alt && !FSOEnvironment.DirectX)
                    {
                        //opengl bug workaround. For some reason, the texture is set to clamp mode by some outside force on first draw.
                        //Monogame then thinks the texture is wrapping.
                        gd.SamplerStates[1] = CustomWrap;
                    }
                    gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, type.Value.GeomForOffset.Count * 2);
                    //gd.SamplerStates[1] = SamplerState.LinearWrap;

                    if (id == 0)
                    {
                        e.Parameters["UseTexture"].SetValue(true);
                        e.Parameters["IgnoreColor"].SetValue(true);
                    }
                    if (water)
                    {
                        e.Parameters["World"].SetValue(worldmat);
                        e.Parameters["TexMatrix"].SetValue(tmat);
                        e.Parameters["Water"].SetValue(false);
                    }
                }
            }
            e.Parameters["Water"].SetValue(false);
            Alt = !Alt;
        }
        public override Texture2D DrawFrame(World world)
        {
            if (!Inited)
            {
                if (Sprites == null)
                {
                    Sprites = new Files.Formats.IFF.IffFile(Content.Content.Get().GetPath("objectdata/globals/sprites.iff"));
                    WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
                }

                if (Headline.Operand.Group != VMSetBalloonHeadlineOperandGroup.Algorithmic)
                {
                    Sprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)Headline.Operand.Group] + Headline.Index));
                }

                if (Headline.Operand.Type != 255 && Headline.Operand.Type != 3)
                {
                    BGSprite = Sprites.Get <SPR>((ushort)(GroupOffsets[(int)VMSetBalloonHeadlineOperandGroup.Balloon] + Headline.Operand.Type));
                }

                LastZoom = WorldZoom.Near;
                RecalculateTarget();
                Inited = true;
            }

            if (LastZoom != world.State.Zoom || Texture == null)
            {
                Invalidated = true;
                LastZoom    = world.State.Zoom;
                RecalculateTarget();
                if (Texture == null)
                {
                    return(null);
                }
            }
            var GD    = GameFacade.GraphicsDevice;
            var batch = GameFacade.Screens.SpriteBatch;

            if (DrawSkill)
            {
                ProcessSkill();
            }
            else if (Headline.Anim % 15 == 0 && Sprite != null && Sprite.Frames.Count > 3)
            {
                Invalidated = true;
            }

            if (Invalidated) //todo: logic for drawing skills less often
            {
                GD.SetRenderTarget(Texture);
                GD.Clear(Color.Transparent);
                batch.Begin();

                if (BGSprite != null)
                {
                    batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);
                }

                Texture2D main   = null;
                Vector2   offset = new Vector2();
                if (Sprite != null)
                {
                    var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                    main   = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                    offset = new Vector2(0, 4);
                }
                else if (AlgTex != null)
                {
                    main   = AlgTex;
                    offset = new Vector2(0, -6);
                }
                offset /= ZoomToDiv[(int)LastZoom];

                if (main != null && Texture != null)
                {
                    batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);
                }

                if (Headline.Operand.Crossed)
                {
                    Texture2D Cross = Sprites.Get <SPR>(0x67).Frames[ZoomFrame].GetTexture(GD);
                    batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 4), Color.White);
                }

                if (DrawSkill)
                {
                    batch.Draw(WhitePx, new Rectangle(88, 4, 71, 41), new Color(92, 92, 92));
                    var vfont = GameFacade.VectorFont;
                    batch.End();

                    Vector2 fontOrigin = vfont.MeasureString(SkillString) / 2;
                    vfont.Draw(GD, SkillString, new Vector2(88 + 35, 15) - fontOrigin * 0.72f, new Color(255, 249, 157), new Vector2(0.72f), null);
                    //batch.DrawString(font, SkillString, new Vector2(88 + 35, 15) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);

                    fontOrigin = vfont.MeasureString(SpeedString) / 2;
                    vfont.Draw(GD, SpeedString, new Vector2(88 + 35, 34) - fontOrigin * 0.72f, new Color(255, 249, 157), new Vector2(0.72f), null);
                    //batch.DrawString(font, SpeedString, new Vector2(88 + 35, 34) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);
                }
                else
                {
                    batch.End();
                }
                GD.SetRenderTarget(null);
                Invalidated = false;
            }

            return(Texture);
        }
Example #13
0
        public override Texture2D DrawFrame(World world)
        {
            if (LastZoom != world.State.Zoom || Texture == null)
            {
                if (WhitePx == null)
                {
                    WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
                }
                Invalidated = true;
                LastZoom    = world.State.Zoom;
                RecalculateTarget();
                if (Texture == null)
                {
                    return(null);
                }
            }
            var GD    = GameFacade.GraphicsDevice;
            var batch = GameFacade.Screens.SpriteBatch;

            if (DrawSkill)
            {
                ProcessSkill();
            }
            else if (Headline.Anim % 15 == 0 && Sprite != null && Sprite.Frames.Count > 3)
            {
                Invalidated = true;
            }

            if (Invalidated) //todo: logic for drawing skills less often
            {
                GD.SetRenderTarget(Texture);
                GD.Clear(Color.Transparent);
                batch.Begin();

                if (BGSprite != null)
                {
                    batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);
                }

                Texture2D main   = null;
                Vector2   offset = new Vector2();
                if (Sprite != null)
                {
                    var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                    main   = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                    offset = new Vector2(0, 4);
                }
                else if (AlgTex != null)
                {
                    main   = AlgTex;
                    offset = new Vector2(0, -6);
                }
                offset /= ZoomToDiv[(int)LastZoom];

                if (main != null && Texture != null)
                {
                    batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);
                }

                if (Headline.Operand.Crossed)
                {
                    Texture2D Cross = Sprites.Get <SPR>(0x67).Frames[ZoomFrame].GetTexture(GD);
                    batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 4), Color.White);
                }

                batch.End();
                GD.SetRenderTarget(null);
                Invalidated = false;
            }

            return(Texture);
        }
Example #14
0
        public override void Draw(GraphicsDevice device, WorldState world)
        {
            var scale2d = (1 << (3 - (int)world.Zoom));
            var weather = (Mode < ParticleType.GENERIC_BOX);

            if (Vertices == null || (LastZoom != world.Zoom && weather))
            {
                LastZoom = world.Zoom;
                if (weather)
                {
                    if (FSOEnvironment.Enable3D)
                    {
                        Volume = new BoundingBox(new Vector3(-50, -50, -50), new Vector3(50, 50, 50));
                    }
                    else
                    {
                        Volume = new BoundingBox(new Vector3(-100, 0, -100) * scale2d, new Vector3(100 * scale2d, 2.95f * 3 * 5 * 2, 100 * scale2d));
                    }
                    if (Indoors == null)
                    {
                        Indoors = new Texture2D(device, Bp.Width, Bp.Height, false, SurfaceFormat.Alpha8);
                    }
                    InitParticleVolume(device, Volume, (int)(12500 * WeatherIntensity));
                }
                else
                {
                    var volVec = Volume.Max - Volume.Min;
                    if (volVec.X < 0.1f)
                    {
                        volVec.X = 0.1f;
                    }
                    if (volVec.Y < 0.1f)
                    {
                        volVec.Y = 0.1f;
                    }
                    if (volVec.Z < 0.1f)
                    {
                        volVec.Z = 0.1f;
                    }

                    var maxDim = Math.Max(volVec.X, Math.Max(volVec.Y, volVec.Z));
                    NumParticles = (int)(maxDim * Resource.Particles);

                    if (NumParticles == 0)
                    {
                        NumParticles = 1;                   // return;
                    }
                    InitParticleVolume(device, Volume, NumParticles);
                }

                //return;
            }
            //get our billboard

            if (weather)
            {
                var indoors = Bp.GetIndoors();
                if (IndoorsDat != indoors)
                {
                    IndoorsDat = indoors;
                    Indoors.SetData(indoors);
                }
            }

            var rot = world.Camera.View;

            rot.Translation = Vector3.Zero;
            var inv = Matrix.Invert(rot);

            var     forward = Vector3.Transform(new Vector3(0, 0, 1), inv);
            var     effect  = WorldContent.ParticleEffect;
            Matrix  trans;
            var     basealt = Bp.InterpAltitude(new Vector3(world.CenterTile, 0));
            var     pos     = Vector3.Transform(Vector3.Zero, Matrix.Invert(world.Camera.View));
            Vector3 transp;

            float opacity = 1;

            if (weather)
            {
                if (FSOEnvironment.Enable3D)
                {
                    transp = (pos + forward * -20f + new Vector3(Volume.Max.X, 0, Volume.Max.Z)) * 2;
                }
                else
                {
                    transp = new Vector3(world.CenterTile.X * 3 + Volume.Max.X, basealt * 3, world.CenterTile.Y * 3 + Volume.Max.Z) * 2;
                }
                trans = Matrix.CreateTranslation(transp);
                effect.Parameters["World"].SetValue(trans);

                var velocity = (FSOEnvironment.Enable3D) ? transp - LastPosition : new Vector3();
                effect.Parameters["CameraVelocity"].SetValue(velocity);
                opacity      = Math.Min(1, (3f / velocity.Length() + 0.001f));
                LastPosition = transp;
                effect.Parameters["Level"].SetValue((float)(Math.Min((world.Level + 1), Bp.Stories) - 0.999f));
            }
            else
            {
                effect.Parameters["World"].SetValue(OwnerWorld);// Matrix.CreateScale(3,3,3));
                effect.Parameters["Level"].SetValue(Level - 0.999f);
            }

            effect.Parameters["View"].SetValue(world.Camera.View);
            effect.Parameters["Projection"].SetValue(world.Camera.Projection);
            effect.Parameters["InvRotation"].SetValue(inv * Matrix.CreateScale(0.5f));

            Tint = Color.White * opacity;
            if (Mode == ParticleType.RAIN)
            {
                //rot.Up = new Vector3(0, 1, 0);
                //rot.Backward = new Vector3(0, 0, 1);
                rot.Up = new Vector3(0, 1, 0);
                var invxz = (FSOEnvironment.Enable3D)?Matrix.Invert(rot): Matrix.Identity;
                effect.Parameters["InvXZRotation"].SetValue(invxz * Matrix.CreateScale(0.5f));
                effect.Parameters["SubColor"].SetValue(Bp.OutsideColor.ToVector4() * 0.6f * opacity);
            }
            else
            {
                effect.Parameters["SubColor"].SetValue(Vector4.Zero);
            }
            effect.Parameters["ClipLevel"].SetValue(FSOEnvironment.Enable3D ? float.MaxValue : world.Level);
            effect.Parameters["BaseAlt"].SetValue(basealt * 3);
            effect.Parameters["BpSize"].SetValue(new Vector2(Bp.Width * 3, Bp.Height * 3));
            effect.Parameters["Stories"].SetValue((float)(Bp.Stories + 1));
            InternalDraw(device, effect, scale2d, true);
        }
 void ucp_OnZoomChanged(WorldZoom zoom)
 {
     World.State.Zoom = zoom;
     //Scene.Zoom = zoom;
 }
Example #16
0
        public override void Update(UpdateState state)
        {
            base.Update(state);

            if (!vm.Ready || vm.Context.Architecture == null)
            {
                return;
            }

            //handling smooth scaled zoom
            if (FSOEnvironment.Enable3D)
            {
                var s3d = ((WorldStateRC)World.State);
                s3d.Zoom3D += ((9.75f - (TargetZoom - 0.25f) * 5.7f) - s3d.Zoom3D) / 10;
            }
            else
            {
                if (World.State.Zoom != LastZoom)
                {
                    //zoom has been changed by something else. inherit the value
                    SetTargetZoom(World.State.Zoom);
                    LastZoom = World.State.Zoom;
                }

                float     BaseScale;
                WorldZoom targetZoom;
                if (TargetZoom < 0.5f)
                {
                    targetZoom = WorldZoom.Far;
                    BaseScale  = 0.25f;
                }
                else if (TargetZoom < 1f)
                {
                    targetZoom = WorldZoom.Medium;
                    BaseScale  = 0.5f;
                }
                else
                {
                    targetZoom = WorldZoom.Near;
                    BaseScale  = 1f;
                }
                World.BackbufferScale = TargetZoom / BaseScale;
                if (World.State.Zoom != targetZoom)
                {
                    World.State.Zoom = targetZoom;
                }
                LastZoom = targetZoom;
                WorldConfig.Current.SmoothZoom = false;
            }

            Cheats.Update(state);
            AvatarDS.Update();
            if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID)
            {
                ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected.
                if (ActiveEntity == null)
                {
                    ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID > 0);
                }

                if (!FoundMe && ActiveEntity != null)
                {
                    vm.Context.World.State.CenterTile   = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y);
                    vm.Context.World.State.ScrollAnchor = null;
                    FoundMe = true;
                }
                Queue.QueueOwner = ActiveEntity;
            }

            if (GotoObject == null)
            {
                GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0];
            }

            if (ActiveEntity != null && BlockingDialog != null)
            {
                //are we still waiting on a blocking dialog? if not, cancel.
                if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult)))
                {
                    UIScreen.RemoveDialog(BlockingDialog);
                    LastDialogID   = 0;
                    BlockingDialog = null;
                }
            }

            if (Visible)
            {
                if (ShowTooltip)
                {
                    state.UIState.TooltipProperties.UpdateDead = false;
                }

                bool scrolled = false;
                if (RMBScroll)
                {
                    World.State.ScrollAnchor = null;
                    Vector2 scrollBy = new Vector2();
                    if (state.TouchMode)
                    {
                        scrollBy   = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y);
                        RMBScrollX = state.MouseState.X;
                        RMBScrollY = state.MouseState.Y;
                        scrollBy  /= 128f;
                        scrollBy  /= FSOEnvironment.DPIScaleFactor;
                    }
                    else
                    {
                        scrollBy  = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY);
                        scrollBy *= 0.0005f;

                        var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4;
                        angle += 8;
                        angle %= 8;

                        CursorType type = CursorType.ArrowUp;
                        switch ((int)Math.Round(angle))
                        {
                        case 0: type = CursorType.ArrowUp; break;

                        case 1: type = CursorType.ArrowUpRight; break;

                        case 2: type = CursorType.ArrowRight; break;

                        case 3: type = CursorType.ArrowDownRight; break;

                        case 4: type = CursorType.ArrowDown; break;

                        case 5: type = CursorType.ArrowDownLeft; break;

                        case 6: type = CursorType.ArrowLeft; break;

                        case 7: type = CursorType.ArrowUpLeft; break;
                        }
                        GameFacade.Cursor.SetCursor(type);
                    }
                    World.Scroll(scrollBy * (60f / FSOEnvironment.RefreshRate));
                    scrolled = true;
                }
                if (MouseIsOn)
                {
                    if (state.MouseState.RightButton == ButtonState.Pressed)
                    {
                        if (RMBScroll == false)
                        {
                            RMBScroll  = true;
                            RMBScrollX = state.MouseState.X;
                            RMBScrollY = state.MouseState.Y;
                        }
                    }
                    else
                    {
                        if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode)
                        {
                            scrolled = World.TestScroll(state);
                        }
                    }
                }

                if (state.MouseState.RightButton != ButtonState.Pressed)
                {
                    if (RMBScroll)
                    {
                        GameFacade.Cursor.SetCursor(CursorType.Normal);
                    }
                    RMBScroll = false;
                }

                if (LiveMode)
                {
                    LiveModeUpdate(state, scrolled);
                }
                else if (CustomControl != null)
                {
                    CustomControl.Update(state, scrolled);
                }
                else
                {
                    ObjectHolder.Update(state, scrolled);
                }

                //set cutaway around mouse
                UpdateCutaway(state);

                if (state.NewKeys.Contains(Keys.S) && state.KeyboardState.IsKeyDown(Keys.LeftControl))
                {
                    //save lot
                    if (LotSaveDialog == null)
                    {
                        SaveLot();
                    }
                }
            }
        }
Example #17
0
        public override Texture2D DrawFrame(World world)
        {
            if (LastZoom != world.State.Zoom || Texture == null)
            {
                Invalidated = true;
                LastZoom = world.State.Zoom;
                RecalculateTarget();
                if (Texture == null) return null;
            }
            var GD = GameFacade.GraphicsDevice;
            var batch = GameFacade.Screens.SpriteBatch;

            if (Headline.Anim % 15 == 0 && Sprite != null && Sprite.Frames.Count > 3) Invalidated = true;

            if (Invalidated || DrawSkill) //todo: logic for drawing skills less often
            {
                GD.SetRenderTarget(Texture);
                GD.Clear(Color.Transparent);
                batch.Begin();

                if (BGSprite != null) batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);

                Texture2D main = null;
                Vector2 offset = new Vector2();
                if (Sprite != null)
                {
                    var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                    main = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                    offset = new Vector2(0, 4);
                }
                else if (AlgTex != null)
                {
                    main = AlgTex;
                    offset = new Vector2(0, -6);
                }
                offset /= ZoomToDiv[(int)LastZoom];

                if (main != null && Texture != null) batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);

                if (Headline.Operand.Crossed)
                {
                    Texture2D Cross = Sprites.Get<SPR>(0x67).Frames[ZoomFrame].GetTexture(GD);
                    batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 4), Color.White);
                }

                if (DrawSkill)
                {
                    batch.Draw(WhitePx, new Rectangle(88, 4, 71, 41), new Color(92, 92, 92));
                    var font = GameFacade.MainFont.GetNearest(14).Font;

                    var avatar = (VMAvatar)Headline.Target;

                    string skillString = "Skill: " + (avatar.GetPersonData((VMPersonDataVariable)
                        (avatar.GetPersonData(VMPersonDataVariable.SkillEfficiency) >> 8)) / 100.0).ToString("F2");
                    Vector2 fontOrigin = font.MeasureString(skillString) / 2;
                    batch.DrawString(font, skillString, new Vector2(88 + 35, 15) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);

                    skillString = "Speed: " + (avatar.GetPersonData(VMPersonDataVariable.SkillEfficiency) & 0xFF) + "%";
                    fontOrigin = font.MeasureString(skillString) / 2;
                    batch.DrawString(font, skillString, new Vector2(88 + 35, 34) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);
                }

                batch.End();
                GD.SetRenderTarget(null);
                Invalidated = false;
            }

            return Texture;
        }
Example #18
0
        public void DrawFloor(GraphicsDevice gd, Effect e, WorldZoom zoom, WorldRotation rot, List <Texture2D> roommaps, HashSet <sbyte> floors, EffectPass pass,
                              Matrix?lightWorld = null, WorldState state = null, int minFloor = 0)
        {
            //assumes the effect and all its parameters have been set up already
            //we just need to get the right texture and offset
            var flrContent = Content.Content.Get().WorldFloors;

            e.Parameters["TexOffset"].SetValue(new Vector2());// TexOffset[zoom]*-1f);
            var tmat = TexMat[rot];

            e.Parameters["TexMatrix"].SetValue(tmat);

            var f = 0;

            foreach (var floor in Floors)
            {
                if (!floors.Contains((sbyte)(f++)))
                {
                    continue;
                }

                Matrix worldmat;
                if (lightWorld == null)
                {
                    worldmat = Matrix.CreateTranslation(0, 2.95f * (f - 1) * 3 - Bp.BaseAlt * Bp.TerrainFactor * 3, 0);
                }
                else
                {
                    worldmat = Matrix.CreateScale(1, 0, 1) * Matrix.CreateTranslation(0, 1f * (f - (1 + minFloor)), 0) * lightWorld.Value;
                    e.Parameters["DiffuseColor"].SetValue(new Vector4(1, 1, 1, 1) * (float)(6 - (f - (minFloor))) / 5f);
                }

                e.Parameters["World"].SetValue(worldmat);
                e.Parameters["Level"].SetValue((float)(f - ((lightWorld == null)?0.999f:1f)));
                if (roommaps != null)
                {
                    e.Parameters["RoomMap"].SetValue(roommaps[f - 1]);
                }
                foreach (var type in floor.GroupForTileType)
                {
                    bool water = false;
                    var  dat   = type.Value.GPUData;
                    if (dat == null)
                    {
                        continue;
                    }
                    gd.Indices = dat;

                    var id = type.Key;

                    if (id == 0)
                    {
                        e.Parameters["UseTexture"].SetValue(false);
                        e.Parameters["IgnoreColor"].SetValue(false);
                    }
                    else
                    {
                        Texture2D SPR = null;
                        if (id >= 65503)
                        {
                            if (id == 65503)
                            {
                                water = true;
                                var airTiles = TextureGenerator.GetAirTiles(gd);
                                switch (zoom)
                                {
                                case WorldZoom.Far:
                                    SPR = airTiles[2];
                                    break;

                                case WorldZoom.Medium:
                                    SPR = airTiles[1];
                                    break;

                                case WorldZoom.Near:
                                    SPR = airTiles[0];
                                    break;
                                }
                            }
                            else
                            {
                                e.Parameters["Water"].SetValue(true);
                                var pool = id >= 65520;
                                water = true;
                                if (!pool)
                                {
                                    e.Parameters["UseTexture"].SetValue(false);
                                    e.Parameters["IgnoreColor"].SetValue(false);

                                    //quickly draw under the water
                                    pass.Apply();
                                    gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, type.Value.GeomForOffset.Count * 2);

                                    e.Parameters["UseTexture"].SetValue(true);
                                    e.Parameters["IgnoreColor"].SetValue(true);
                                    if (lightWorld == null)
                                    {
                                        e.Parameters["World"].SetValue(worldmat * Matrix.CreateTranslation(0, 0.05f, 0));
                                    }
                                    id -= 65504;
                                }
                                else
                                {
                                    id -= 65520;
                                }

                                e.Parameters["TexMatrix"].SetValue(CounterTexMat[rot]);

                                var roti = (int)rot;
                                roti = (4 - roti) % 4;
                                id   = (ushort)(((id << roti) & 15) | (id >> (4 - roti)));
                                //pools & water are drawn with special logic, and may also be drawn slightly above the ground.

                                int baseSPR;
                                int frameNum = 0;
                                if (state != null)
                                {
                                    switch (zoom)
                                    {
                                    case WorldZoom.Far:
                                        baseSPR  = (pool) ? 0x400 : 0x800;
                                        frameNum = (pool) ? 0 : 2;
                                        SPR      = state._2D.GetTexture(flrContent.GetGlobalSPR((ushort)(baseSPR + id)).Frames[frameNum]);
                                        break;

                                    case WorldZoom.Medium:
                                        baseSPR  = (pool) ? 0x410 : 0x800;
                                        frameNum = (pool) ? 0 : 1;
                                        SPR      = state._2D.GetTexture(flrContent.GetGlobalSPR((ushort)(baseSPR + id)).Frames[frameNum]);
                                        break;

                                    default:
                                        baseSPR = (pool) ? 0x420 : 0x800;
                                        SPR     = state._2D.GetTexture(flrContent.GetGlobalSPR((ushort)(baseSPR + id)).Frames[frameNum]);
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            var flr = flrContent.Get(id);

                            if (flr == null)
                            {
                                continue;
                            }

                            if (state != null)
                            {
                                switch (zoom)
                                {
                                case WorldZoom.Far:
                                    SPR = state._2D.GetTexture(flr.Far.Frames[0]);
                                    break;

                                case WorldZoom.Medium:
                                    SPR = state._2D.GetTexture(flr.Medium.Frames[0]);
                                    break;

                                default:
                                    SPR = state._2D.GetTexture(flr.Near.Frames[0]);
                                    break;
                                }
                            }
                        }

                        //e.Parameters["UseTexture"].SetValue(SPR != null);
                        e.Parameters["BaseTex"].SetValue(SPR);
                    }

                    pass.Apply();
                    gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, type.Value.GeomForOffset.Count * 2);

                    if (id == 0)
                    {
                        e.Parameters["UseTexture"].SetValue(true);
                        e.Parameters["IgnoreColor"].SetValue(true);
                    }
                    if (water)
                    {
                        e.Parameters["World"].SetValue(worldmat);
                        e.Parameters["TexMatrix"].SetValue(tmat);
                        e.Parameters["Water"].SetValue(false);
                    }
                }
            }
            e.Parameters["Water"].SetValue(false);
        }
Example #19
0
        public override Texture2D DrawFrame(World world)
        {
            if (LastZoom != world.State.Zoom || Texture == null)
            {
                LastZoom = world.State.Zoom;
                RecalculateTarget();
            }
            var GD    = GameFacade.GraphicsDevice;
            var batch = new SpriteBatch(GD);

            GD.SetRenderTarget(Texture);
            GD.Clear(Color.Transparent);
            batch.Begin();

            if (BGSprite != null)
            {
                batch.Draw(BGSprite.Frames[ZoomFrame].GetTexture(GD), new Vector2(), Color.White);
            }

            Texture2D main   = null;
            Vector2   offset = new Vector2();

            if (Sprite != null)
            {
                var animFrame = (Headline.Anim / 15) % (Sprite.Frames.Count / 3);
                main   = Sprite.Frames[ZoomFrame + animFrame * 3].GetTexture(GD);
                offset = new Vector2(0, 4);
            }
            else if (AlgTex != null)
            {
                main   = AlgTex;
                offset = new Vector2(0, -6);
            }
            offset /= ZoomToDiv[(int)LastZoom];

            if (main != null)
            {
                batch.Draw(main, new Vector2(Texture.Width / 2 - main.Width / 2, Texture.Height / 2 - main.Height / 2) + offset, Color.White);
            }

            if (Headline.Operand.Crossed)
            {
                Texture2D Cross = Sprites.Get <SPR>(67).Frames[ZoomFrame].GetTexture(GD);
                batch.Draw(Cross, new Vector2(Texture.Width / 2 - Cross.Width / 2, Texture.Height / 2 - Cross.Height / 2), Color.White);
            }

            if (DrawSkill)
            {
                batch.Draw(WhitePx, new Rectangle(88, 4, 71, 41), new Color(92, 92, 92));
                var font = GameFacade.MainFont.GetNearest(14).Font;

                var avatar = (VMAvatar)Headline.Target;

                string skillString = "Skill: " + (avatar.GetPersonData((VMPersonDataVariable)
                                                                       (avatar.GetPersonData(VMPersonDataVariable.SkillEfficiency) >> 8)) / 100.0).ToString("F2");
                Vector2 fontOrigin = font.MeasureString(skillString) / 2;
                batch.DrawString(font, skillString, new Vector2(88 + 35, 15) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);

                skillString = "Speed: " + (avatar.GetPersonData(VMPersonDataVariable.SkillEfficiency) & 0xFF) + "%";
                fontOrigin  = font.MeasureString(skillString) / 2;
                batch.DrawString(font, skillString, new Vector2(88 + 35, 34) - fontOrigin * 0.60f, new Color(255, 249, 157), 0, new Vector2(), 0.60f, SpriteEffects.None, 0);
            }

            batch.End();
            GD.SetRenderTarget(null);

            return(Texture);
        }
Example #20
0
        public override void Update(UpdateState state)
        {
            base.Update(state);

            if (!vm.Ready || vm.Context.Architecture == null)
            {
                return;
            }

            //handling smooth scaled zoom
            var camType = World.State.Cameras.ActiveType;

            Touch._3D = camType != FSO.LotView.Utils.Camera.CameraControllerType._2D;
            if (World.State.Cameras.ActiveType == FSO.LotView.Utils.Camera.CameraControllerType._3D)
            {
                if (World.BackbufferScale != 1)
                {
                    World.BackbufferScale = 1;
                }
                var s3d = World.State.Cameras.Camera3D;
                if (TargetZoom < -0.25f)
                {
                    TargetZoom -= (TargetZoom - 0.25f) * (1f - (float)Math.Pow(0.975f, 60f / FSOEnvironment.RefreshRate));
                }
                s3d.Zoom3D += ((9.75f - (TargetZoom - 0.25f) * 5.7f) - s3d.Zoom3D) / 10;
            }
            else if (World.State.Cameras.ActiveType == FSO.LotView.Utils.Camera.CameraControllerType._2D)
            {
                if (World.State.Zoom != LastZoom)
                {
                    //zoom has been changed by something else. inherit the value
                    SetTargetZoom(World.State.Zoom);
                    LastZoom = World.State.Zoom;
                }

                float     BaseScale;
                WorldZoom targetZoom;
                if (TargetZoom < 0.5f)
                {
                    targetZoom = WorldZoom.Far;
                    BaseScale  = 0.25f;
                }
                else if (TargetZoom < 1f)
                {
                    targetZoom = WorldZoom.Medium;
                    BaseScale  = 0.5f;
                }
                else
                {
                    targetZoom = WorldZoom.Near;
                    BaseScale  = 1f;
                }
                World.BackbufferScale = TargetZoom / BaseScale;
                if (World.State.Zoom != targetZoom)
                {
                    World.State.Zoom = targetZoom;
                }
                WorldConfig.Current.SmoothZoom = false;
            }

            if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID)
            {
                ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected.
                //if (ActiveEntity == null) ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);

                if (!FoundMe && ActiveEntity != null)
                {
                    vm.Context.World.State.CenterTile   = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y);
                    vm.Context.World.State.ScrollAnchor = null;
                    FoundMe = true;
                }
                Queue.QueueOwner = ActiveEntity;
            }

            if (GotoObject == null)
            {
                GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0];
            }


            //update plumbbob
            var plumb = Content.Get().RCMeshes.Get("arrow.fsom");

            foreach (VMAvatar avatar in vm.Context.ObjectQueries.Avatars)
            {
                if (avatar.Avatar == null)
                {
                    continue;
                }
                var isActive = (avatar == ActiveEntity);
                if ((avatar.Avatar.HeadObject == plumb) != isActive)
                {
                    avatar.Avatar.HeadObject          = (avatar == ActiveEntity) ? plumb : null;
                    avatar.Avatar.HeadObjectSpeedyVel = 0.2f;
                }
                avatar.Avatar.HeadObjectRotation += 3f / FSOEnvironment.RefreshRate;
                if (isActive)
                {
                    avatar.Avatar.HeadObjectRotation  += avatar.Avatar.HeadObjectSpeedyVel;
                    avatar.Avatar.HeadObjectSpeedyVel *= 0.98f;
                }
                else if (avatar.GetValue(FSO.SimAntics.Model.VMStackObjectVariable.Category) == 87)
                {
                    avatar.Avatar.HeadObject = Content.Get().RCMeshes.Get("star.fsom");
                }
            }

            /*
             * if (ActiveEntity != null && BlockingDialog != null)
             * {
             *  //are we still waiting on a blocking dialog? if not, cancel.
             *  if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult)))
             *  {
             *      BlockingDialog.Close();
             *      LastDialogID = 0;
             *      BlockingDialog = null;
             *  }
             * }*/

            if (Visible)
            {
                if (ShowTooltip)
                {
                    state.UIState.TooltipProperties.UpdateDead = false;
                }

                bool scrolled = false;
                if (RMBScroll)
                {
                    World.State.ScrollAnchor = null;
                    Vector2 scrollBy = new Vector2();
                    if (state.TouchMode)
                    {
                        scrollBy   = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y);
                        RMBScrollX = state.MouseState.X;
                        RMBScrollY = state.MouseState.Y;
                        scrollBy  /= 128f;
                        scrollBy  /= FSOEnvironment.DPIScaleFactor;
                    }
                    else
                    {
                        scrollBy  = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY);
                        scrollBy *= 0.0005f;

                        var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4;
                        angle += 8;
                        angle %= 8;

                        CursorType type = CursorType.ArrowUp;
                        switch ((int)Math.Round(angle))
                        {
                        case 0: type = CursorType.ArrowUp; break;

                        case 1: type = CursorType.ArrowUpRight; break;

                        case 2: type = CursorType.ArrowRight; break;

                        case 3: type = CursorType.ArrowDownRight; break;

                        case 4: type = CursorType.ArrowDown; break;

                        case 5: type = CursorType.ArrowDownLeft; break;

                        case 6: type = CursorType.ArrowLeft; break;

                        case 7: type = CursorType.ArrowUpLeft; break;
                        }
                        GameFacade.Cursor.SetCursor(type);
                    }
                    World.Scroll(scrollBy * (60f / FSOEnvironment.RefreshRate));
                    scrolled = true;
                }
                if (MouseIsOn)
                {
                    if (state.MouseState.RightButton == ButtonState.Pressed)
                    {
                        if (RMBScroll == false)
                        {
                            RMBScroll  = true;
                            RMBScrollX = state.MouseState.X;
                            RMBScrollY = state.MouseState.Y;
                        }
                    }
                    else
                    {
                        if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode)
                        {
                            scrolled = World.TestScroll(state);
                        }
                    }
                }

                if (state.MouseState.RightButton != ButtonState.Pressed)
                {
                    if (RMBScroll)
                    {
                        GameFacade.Cursor.SetCursor(CursorType.Normal);
                    }
                    RMBScroll = false;
                }

                if (!LiveMode && PieMenu != null)
                {
                    PieMenu.RemoveSimScene();
                    this.Remove(PieMenu);
                    PieMenu = null;
                }

                if (state.NewKeys.Contains(Keys.F11))
                {
                    var utils = new FSO.SimAntics.Test.CollisionTestUtils();
                    utils.VerifyAllCollision(vm);
                }

                if (state.NewKeys.Contains(Keys.F8))
                {
                    UIMobileAlert alert = null;
                    alert = new UIMobileAlert(new UIAlertOptions()
                    {
                        Title   = "Debug Lot Thumbnail",
                        Message = "Arch Value: " + VMArchitectureStats.GetArchValue(vm.Context.Architecture),
                        Buttons = UIAlertButton.Ok((btn) => UIScreen.RemoveDialog(alert))
                    });
                    Texture2D roofless = null;
                    var       thumb    = World.GetLotThumb(GameFacade.GraphicsDevice, (tex) => roofless = FSO.Common.Utils.TextureUtils.Decimate(tex, GameFacade.GraphicsDevice, 2, false));
                    thumb = FSO.Common.Utils.TextureUtils.Decimate(thumb, GameFacade.GraphicsDevice, 2, false);
                    alert.SetIcon(thumb, thumb.Width, thumb.Height);
                    UIScreen.GlobalShowDialog(alert, true);
                }
                if (LiveMode)
                {
                    LiveModeUpdate(state, scrolled);
                }
                else if (CustomControl != null)
                {
                    if (FSOEnvironment.SoftwareKeyboard)
                    {
                        CustomControl.MousePosition = new Point(UIScreen.Current.ScreenWidth / 2, UIScreen.Current.ScreenHeight / 2);
                    }
                    else
                    {
                        CustomControl.Modifiers = 0;
                        if (state.CtrlDown)
                        {
                            CustomControl.Modifiers |= UILotControlModifiers.CTRL;
                        }
                        if (state.ShiftDown)
                        {
                            CustomControl.Modifiers |= UILotControlModifiers.SHIFT;
                        }
                        CustomControl.MousePosition = state.MouseState.Position;
                    }
                    CustomControl.Update(state, scrolled);
                }
                else
                {
                    ObjectHolder.Update(state, scrolled);
                }

                //set cutaway around mouse
                UpdateCutaway(state);

                if (RMBScrollX == int.MinValue)
                {
                    Dummy();                             //cannon fodder for mono AOT compilation: never called but gives these constructors a meaning in life
                }
            }
        }