public EmitterComponent(ParticleManager particles, string emitter, ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos)
     : base(manager, name, parent, localTransform, boundingBoxExtents, boundingBoxPos, false)
 {
     ParticleManager = particles;
     Emitter = emitter;
     TriggerOnDeath = true;
     TriggerAmount = 10;
     BoxTriggerTimes = 10;
     TriggerInBox = true;
 }
        public override void OnEnter()
        {
            dorfs = new List<Person>();
               players = new List<Player>();
               aiPlayers = new List<Player>();
               hospitals = new List<Hospital>() ;
            Bloom = new BloomPostprocess.BloomComponent(Game);

            Bloom.Initialize();
            Bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[5];
            IsInitialized = true;

            MapHeight = 40;
            MapWidth = 40;
            Player.defib = new Player.defibCallbackType(defib);
            online = false; // DO NOT CHANGE, offline mode is now detected when server connection is refused
            SoundManager.Content = Game.Content;
            Camera = new OrbitCamera(Game.GraphicsDevice, 0, 0, 0.001f, new Vector3(0, 15, 0), new Vector3(-10, 10, 0), (float)Math.PI * 0.25f, Game.GraphicsDevice.Viewport.AspectRatio, 0.1f, 1000.0f);
            ComponentManager = new ComponentManager();
            ComponentManager.RootComponent = new LocatableComponent(ComponentManager, "root", null, Matrix.Identity, Vector3.Zero, Vector3.Zero);

            notification = null;
            particles = new ParticleManager(ComponentManager);

            EmitterData testData = new EmitterData();
            testData.AngularDamping = 1.0f;
            List<Point> frm = new List<Point>();
            frm.Add(new Point(0, 0));
            frm.Add(new Point(1, 0));
            frm.Add(new Point(0, 1));
            frm.Add(new Point(1, 1));
            testData.Animation = new Animation(Game.GraphicsDevice, Game.Content.Load<Texture2D>("electricity"),
                "electricity", 32, 32, frm, true, Color.White, 20f, 1.0f, 1.0f, false);
            testData.ConstantAccel = new Vector3(0, -1, 0);
            testData.LinearDamping = 0.9f;
            testData.AngularDamping = 0.9f;
            testData.EmissionFrequency = 1.0f;
            testData.EmissionRadius = 1.0f;
            testData.EmissionSpeed = 20.0f;
            testData.GrowthSpeed = -0.9f;
            testData.MaxAngle = 3.14159f;
            testData.MinAngle = 0.0f;
            testData.MaxParticles = 1000;
            testData.MaxScale = 1.0f;
            testData.MinScale = 0.1f;
            testData.MinAngular = -5.0f;
            testData.MaxAngular = 5.0f;
            testData.ParticleDecay = 0.1f;
            testData.ParticlesPerFrame = 0;
            testData.ReleaseOnce = true;
            testData.Texture = Game.Content.Load<Texture2D>("electricity");
            particles.RegisterEffect("shock", testData);

            ChargeCooldown = 1.0f;
            CurrentChargeCooldown = 1.0f;

            InputManager inputManager = new InputManager();
            InputManager.KeyPressedCallback += pressKey;
            InputManager.KeyReleasedCallback += releaseKey;

            sounds = new SoundManager();

            wordsDict = new Dictionary<string, string>();
            wordsDict.Add("MONSTER SAVE", "monstersave");
            wordsDict.Add("DOUBLE SAVE", "doublesave");
            wordsDict.Add("TRIPLE SAVE", "triplesave");

            drawer2D = new Drawer2D(Game.Content, Game.GraphicsDevice);

            client = new Client(online);
            string name = client.Connect();
            if (name == "error")
            {
                Console.Out.WriteLine("connection refused");
                name = "0";
                online = false;
            }

            Hospital hospital1 = new Hospital(new Vector3(-10, 0, -10), new Vector3(4, 2, 3), ComponentManager, Game.Content, Game.GraphicsDevice, "hospital", Color.Red, new Point(2, 0));
            Hospital hospital2 = new Hospital(new Vector3(12, 0, 12), new Vector3(4, 2, 3), ComponentManager, Game.Content, Game.GraphicsDevice, "hospital", Color.Blue, new Point(1, 0));
            hospitals.Add(hospital1);
            hospitals.Add(hospital2);

            Random r = new Random(1);
            for (int i = 0; i < 20; i++) // fnord
            {
                NPC npc;
                switch ((int)(detRand(r) * 3))
                {
                    case (0):
                        npc = new Smoker(new Vector3(detRand(r) * 9, 5, detRand(r) * 10), ComponentManager,
                                        Game.Content, Game.GraphicsDevice);
                        break;
                    case (1):
                        npc = new Fatter(new Vector3(detRand(r) * 9, 5, detRand(r) * 10), ComponentManager,
                                        Game.Content, Game.GraphicsDevice);
                        break;
                    case (2):
                        npc = new Older(new Vector3(detRand(r) * 9, 5, detRand(r) * 10), ComponentManager,
                                        Game.Content, Game.GraphicsDevice);
                        break;
                    default:
                        /* graphics don't exist yet, never reached */
                        npc = new Worker(new Vector3(detRand(r) * 9, 5, detRand(r) * 10 - 0), ComponentManager,
                                        Game.Content, Game.GraphicsDevice);
                        break;
                }
                npc.velocityController.MaxSpeed = 1;
                npc.SetTag((i + 1000).ToString());
                int al = (int)(detRand(r) * 2);
                npc.Team = hospitals[al];
                npc.Velocity = new Vector3(0f, -0.5f, 0f);
                npc.HasMoved = true;
                dorfs.Add(npc);
            }

            player = new Player(name, new Vector3(hospital1.Component.LocalTransform.Translation.X + 5,
                hospital1.Component.LocalTransform.Translation.Y,
                hospital1.Component.LocalTransform.Translation.Z),
                                ComponentManager, Game.Content, Game.GraphicsDevice, "surgeonwalk");
            player.Velocity = new Vector3(0f, -0.5f, 0f);
            player.HasMoved = true;
            dorfs.Add(player);
            players.Add(player);

            if (!online)
            {
                aiPlayers.Add(new Player("1", new Vector3(hospital2.Component.LocalTransform.Translation.X - 5,
                    hospital2.Component.LocalTransform.Translation.Y,
                    hospital2.Component.LocalTransform.Translation.Z), ComponentManager, Game.Content, Game.GraphicsDevice, "surgeonwalk"));

                players.Add(aiPlayers.ElementAt(0));
                dorfs.Add(aiPlayers.ElementAt(0));

                aiPlayers.ElementAt(0).team = hospital2;

                VelocityController velocityController4 = new VelocityController(aiPlayers.ElementAt(0));
                velocityController4.IsTracking = true;
            }

            VelocityController velocityController3 = new VelocityController(player);
            velocityController3.IsTracking = true;

            Vector3 boundingBoxPos = new Vector3(0, -2, 0);
            Vector3 boundingBoxExtents = new Vector3(MapWidth, 4, MapHeight);
            Vector3 boundingBoxMin = boundingBoxPos - boundingBoxExtents * 0.5f;
            Vector3 boundingBoxMax = boundingBoxPos + boundingBoxExtents * 0.5f;

            ground = (LocatableComponent)EntityFactory.GenerateBlankBox(new BoundingBox(boundingBoxMin, boundingBoxMax), ComponentManager, Game.Content, Game.GraphicsDevice, "newground", Point.Zero, Point.Zero, 128, 128);

            if (Convert.ToInt32(name) % 2 == 0)
                player.team = hospital1;
            else
                player.team = hospital2;

            SpriteBatch = new SpriteBatch(Game.GraphicsDevice);
            Shader = Game.Content.Load<Effect>("Hargraves");

            SunMap = Game.Content.Load<Texture2D>("sungradient");
            AmbientMap = Game.Content.Load<Texture2D>("ambientgradient");
            TorchMap = Game.Content.Load<Texture2D>("torchgradient");

            if (online)
            {
                AddNotification("Mash Space to Begin");
            }
            base.OnEnter();
        }