public void CreateSmoke()
        {
            // how much is this huring FPS?

            if (issmoke)
            {
                return;
            }

            PhysicalRocket smoke = null;

            if (CreateSmokeRecycleCache.Count < 8)
            {
                smoke = new PhysicalRocket(textures_rocket, Context, issmoke: true);
            }
            else
            {
                smoke = CreateSmokeRecycleCache.Dequeue();
                smoke.body.SetActive(true);
                smoke.visual.visible = true;
            }


            smoke.smokerandom = Context.random.NextDouble() * Math.PI * 2;
            smoke.smoketime   = Context.gametime.ElapsedMilliseconds;

            if (this.body.GetLinearVelocity().Length() > 0)
            {
                smoke.smokescale = 0.7 + 0.7 * Context.random.NextDouble();
                CreateSmokeRecycleCache.Enqueue(smoke);
            }
            else
            {
                smoke.smokescale = 2.0;
            }

            {
                var up = new KeySample();
                up[Keys.Up] = true;
                smoke.speed = 5;
                smoke.SetVelocityFromInput(up);
            }

            var a = this.body.GetAngle() + (175 + Context.random.Next(10)).DegreesToRadians();

            smoke.SetPositionAndAngle(
                this.body.GetPosition().x + Math.Cos(a) * 2,
                this.body.GetPosition().y + Math.Sin(a) * 2,
                a
                );
            smoke.ShowPositionAndAngle();
        }
        public StarlingGameSpriteWithRocket()
        {
            var textures_rocket = new StarlingGameSpriteWithRocketTextures(this.new_tex_crop);

            this.onbeforefirstframe += (stage, s) =>
            {
                var cl = new PhysicalRocket(textures_rocket, this);

                cl.issmoke = true;

                current = new PhysicalRocket(textures_rocket, this);


                #region __keyDown

                stage.keyDown +=
                    e =>
                {
                    // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/
                    if (e.altKey)
                    {
                        __keyDown[Keys.Alt] = true;
                    }

                    __keyDown[(Keys)e.keyCode] = true;
                };

                stage.keyUp +=
                    e =>
                {
                    if (!e.altKey)
                    {
                        __keyDown[Keys.Alt] = false;
                    }

                    __keyDown[(Keys)e.keyCode] = false;
                };

                #endregion

                onsyncframe += delegate
                {
                    current.SetVelocityFromInput(__keyDown);
                };
            };
        }
        public StarlingGameSpriteWithRocket()
        {
            var textures_rocket = new StarlingGameSpriteWithRocketTextures(this.new_tex_crop);

            this.onbeforefirstframe += (stage, s) =>
            {

                var cl = new PhysicalRocket(textures_rocket, this);

                cl.issmoke = true;

                current = new PhysicalRocket(textures_rocket, this);


                #region __keyDown

                stage.keyDown +=
                   e =>
                   {
                       // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/
                       if (e.altKey)
                           __keyDown[Keys.Alt] = true;

                       __keyDown[(Keys)e.keyCode] = true;
                   };

                stage.keyUp +=
                 e =>
                 {
                     if (!e.altKey)
                         __keyDown[Keys.Alt] = false;

                     __keyDown[(Keys)e.keyCode] = false;
                 };

                #endregion

                onsyncframe += delegate
                {
                    current.SetVelocityFromInput(__keyDown);
                };
            };
        }
        public void CreateSmoke()
        {
            // how much is this huring FPS?

            if (issmoke)
                return;

            PhysicalRocket smoke = null;

            if (CreateSmokeRecycleCache.Count < 8)
            {

                smoke = new PhysicalRocket(textures_rocket, Context, issmoke: true);

            }
            else
            {
                smoke = CreateSmokeRecycleCache.Dequeue();
                smoke.body.SetActive(true);
                smoke.visual.visible = true;
            }


            smoke.smokerandom = Context.random.NextDouble() * Math.PI * 2;
            smoke.smoketime = Context.gametime.ElapsedMilliseconds;

            if (this.body.GetLinearVelocity().Length() > 0)
            {
                smoke.smokescale = 0.7 + 0.7 * Context.random.NextDouble();
                CreateSmokeRecycleCache.Enqueue(smoke);
            }
            else
            {
                smoke.smokescale = 2.0;
            }

            {
                var up = new KeySample();
                up[Keys.Up] = true;
                smoke.speed = 5;
                smoke.SetVelocityFromInput(up);
            }

            var a = this.body.GetAngle() + (175 + Context.random.Next(10)).DegreesToRadians();

            smoke.SetPositionAndAngle(
                this.body.GetPosition().x + Math.Cos(a) * 2,
                this.body.GetPosition().y + Math.Sin(a) * 2,
                a
                );
            smoke.ShowPositionAndAngle();
        }
        public PhysicalHindWeaponized(
            StarlingGameSpriteWithHindTextures textures_hind,
            StarlingGameSpriteWithRocketTextures textures_rocket,
            StarlingGameSpriteWithPhysics __Context,


            Image Explosion1 = null
            )
            : base(textures_hind, __Context)
        {
            var RocketsMax = 12;
            var Rockets = new Queue<PhysicalRocket>();

            var Context = __Context;
            var rocket0 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);
            rocket0.body.SetActive(false);
            rocket0.SetPositionAndAngle(-0.5, 2);


            var rocket1 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);
            rocket1.body.SetActive(false);
            rocket1.SetPositionAndAngle(-0.5, -2);

            #region z fixup
            rocket0.visual.parent.setChildIndex(
                rocket0.visual,

                this.visual.visualnowings.parent.getChildIndex(
                    this.visual.visualnowings
                )
            );
            #endregion

            #region z fixup
            rocket1.visual.parent.setChildIndex(
                rocket1.visual,

                this.visual.visualnowings.parent.getChildIndex(
                    this.visual.visualnowings
                )
            );
            #endregion

            var hind0 = this;

            #region ShowPositionAndAngleForSlaves
            hind0.ShowPositionAndAngleForSlaves = delegate
            {
                // we are faking 3d here!
                var sc = 1 + hind0.visual.airzoom * hind0.visual.Altitude;


                if (rocket0 != null)
                {
                    rocket0.body.SetActive(false);
                    rocket0.Altitude = hind0.visual.Altitude;
                    rocket0.SetPositionAndAngle(


                            hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,
                            hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,

                        hind0.body.GetAngle() - hind0.CameraRotation
                    );
                    rocket0.ShowPositionAndAngle();
                }

                if (rocket1 != null)
                {
                    rocket1.body.SetActive(false);
                    rocket1.Altitude = hind0.visual.Altitude;
                    rocket1.SetPositionAndAngle(


                            hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,
                            hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,

                        hind0.body.GetAngle() - hind0.CameraRotation
                    );
                    rocket1.ShowPositionAndAngle();
                }
            };
            #endregion

            #region FireRocket
            FireRocket = delegate
            {



                if (rocket0 != null)
                {
                    var sc = 1 + hind0.visual.airzoom * hind0.visual.Altitude;

                    rocket0.SetPositionAndAngle(


                              hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,
                              hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,

                          hind0.body.GetAngle() - hind0.CameraRotation
                      );
                    rocket0.ShowPositionAndAngle();
                    rocket0.body.SetActive(true);

                    rocket0.CreateSmoke();
                    {
                        var up = new KeySample();
                        up[Keys.Up] = true;
                        rocket0.speed = 60 + this.body.GetLinearVelocity().Length();
                        rocket0.SetVelocityFromInput(up);
                    }
                    Rockets.Enqueue(rocket0);
                    rocket0 = null;


                    if (rocket1 == null)
                    {
                        if (Rockets.Count > RocketsMax)
                        {
                            rocket1 = Rockets.Dequeue();
                            rocket1.SetVelocityFromInput(new KeySample());
                            rocket1.visual.visible = true;
                        }
                        else
                        {
                            rocket1 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);
                            rocket1.body.SetActive(false);

                            #region z fixup
                            rocket1.visual.parent.setChildIndex(
                                rocket1.visual,

                                this.visual.visualnowings.parent.getChildIndex(
                                    this.visual.visualnowings
                                )
                            );
                            #endregion
                        }
                    }
                }
                else if (rocket1 != null)
                {
                    var sc = 1 + hind0.visual.airzoom * hind0.visual.Altitude;

                    rocket1.SetPositionAndAngle(


                              hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,
                              hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,

                          hind0.body.GetAngle() - hind0.CameraRotation
                      );
                    rocket1.ShowPositionAndAngle();
                    rocket1.body.SetActive(true);

                    rocket1.CreateSmoke();
                    {
                        var up = new KeySample();
                        up[Keys.Up] = true;
                        rocket1.speed = 60 + this.body.GetLinearVelocity().Length();
                        rocket1.SetVelocityFromInput(up);
                    }
                    Rockets.Enqueue(rocket1);
                    rocket1 = null;

                    if (rocket0 == null)
                    {
                        if (Rockets.Count > RocketsMax)
                        {
                            rocket0 = Rockets.Dequeue();
                            rocket0.SetVelocityFromInput(new KeySample());
                            rocket0.visual.visible = true;
                        }
                        else
                        {
                            rocket0 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);
                            rocket0.body.SetActive(false);

                            #region z fixup
                            rocket0.visual.parent.setChildIndex(
                                rocket0.visual,

                                this.visual.visualnowings.parent.getChildIndex(
                                    this.visual.visualnowings
                                )
                            );
                            #endregion



                        }

                    }
                }
            };
            #endregion

        }