コード例 #1
0
        public override void UpdateLights(EffectFrame frame)
        {
            currenttime = Utils.Time.GetMillisecondsSinceEpoch();

            Queue <EffectLayer> layers = new Queue <EffectLayer>();

            //update background
            if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_enabled)
            {
                EffectLayer bg_layer = new EffectLayer("Payday 2 - Background");

                Color bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ambient_color;

                if ((level_phase == LevelPhase.Assault || level_phase == LevelPhase.Winters) && game_state == GameStates.Ingame)
                {
                    if (level_phase == LevelPhase.Assault)
                    {
                        bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_color;
                    }
                    else if (level_phase == LevelPhase.Winters)
                    {
                        bg_color = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).winters_color;
                    }

                    double blend_percent = Math.Pow(Math.Sin(((currenttime % 1300L) / 1300.0D) * (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_speed_mult * 2.0D * Math.PI), 2.0D);

                    bg_color = Utils.ColorUtils.BlendColors((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_fade_color, bg_color, blend_percent);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).assault_animation_enabled)
                    {
                        Color effect_contours            = Color.FromArgb(200, Color.Black);
                        float animation_stage_yoffset    = 20.0f;
                        float animation_repeat_keyframes = 250.0f; //Effects.canvas_width * 2.0f;

                        /* Effect visual:
                         *
                         * / /  ----  / /
                         *
                         */

                        EffectColorFunction line1_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        EffectColorFunction line2_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 9.0f + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        EffectColorFunction line3_col_func = new EffectColorFunction(
                            new EffectLine(new EffectPoint(Effects.canvas_width + assault_yoffset + 17.0f + animation_stage_yoffset, Effects.canvas_height / 2.0f), new EffectPoint(Effects.canvas_width + assault_yoffset + 34.0f + animation_stage_yoffset, Effects.canvas_height / 2.0f), true),
                            new ColorSpectrum(effect_contours),
                            6);

                        EffectColorFunction line4_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 52.0f + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        EffectColorFunction line5_col_func = new EffectColorFunction(
                            new EffectLine(-1f, Effects.canvas_width + assault_yoffset + 61.0f + animation_stage_yoffset),
                            new ColorSpectrum(effect_contours),
                            2);

                        assault_yoffset -= 0.50f;
                        assault_yoffset  = assault_yoffset % animation_repeat_keyframes;

                        bg_layer.AddPostFunction(line1_col_func);
                        bg_layer.AddPostFunction(line2_col_func);
                        //bg_layer.AddPostFunction(line3_col_func);
                        bg_layer.AddPostFunction(line4_col_func);
                        bg_layer.AddPostFunction(line5_col_func);
                    }

                    bg_layer.Fill(bg_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }
                else if (level_phase == LevelPhase.Stealth && game_state == GameStates.Ingame)
                {
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_show_suspicion)
                    {
                        double percentSuspicious = ((double)suspicion_amount / (double)1.0);

                        ColorSpectrum suspicion_spec = new ColorSpectrum((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).low_suspicion_color, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).high_suspicion_color);
                        suspicion_spec.SetColorAt(0.5f, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).medium_suspicion_color);

                        Settings.KeySequence suspicionSequence = new Settings.KeySequence(new Settings.FreeFormObject(0, 0, 1.0f / (Effects.editor_to_canvas_width / Effects.canvas_width), 1.0f / (Effects.editor_to_canvas_height / Effects.canvas_height)));

                        bg_layer.PercentEffect(suspicion_spec, suspicionSequence, percentSuspicious, 1.0D, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).suspicion_effect_type);

                        if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                        {
                            bg_layer.Set(Devices.DeviceKeys.Peripheral, suspicion_spec.GetColorAt((float)percentSuspicious));
                        }
                    }
                }
                else if (level_phase == LevelPhase.Point_of_no_return && game_state == GameStates.Ingame)
                {
                    ColorSpectrum no_return_spec = new ColorSpectrum(Color.Red, Color.Yellow);

                    Color no_return_color = no_return_spec.GetColorAt(no_return_flashamount);
                    no_return_flashamount -= 0.05f;

                    if (no_return_flashamount < 0.0f)
                    {
                        no_return_flashamount = 0.0f;
                    }

                    bg_layer.Fill(no_return_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, no_return_color);
                    }
                }
                else
                {
                    bg_layer.Fill(bg_color);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        bg_layer.Set(Devices.DeviceKeys.Peripheral, bg_color);
                    }
                }

                layers.Enqueue(bg_layer);
            }

            if (game_state == GameStates.Ingame)
            {
                if (
                    player_state == PlayerState.Mask_Off ||
                    player_state == PlayerState.Standard ||
                    player_state == PlayerState.Jerry1 ||
                    player_state == PlayerState.Jerry2 ||
                    player_state == PlayerState.Tased ||
                    player_state == PlayerState.Bipod ||
                    player_state == PlayerState.Carry
                    )
                {
                    //Update Health
                    EffectLayer hpbar_layer = new EffectLayer("Payday 2 - HP Bar");
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_enabled)
                    {
                        hpbar_layer.PercentEffect((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).healthy_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).hurt_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_sequence,
                                                  (double)health,
                                                  (double)health_max,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).health_effect_type);
                    }

                    layers.Enqueue(hpbar_layer);

                    //Update Health
                    EffectLayer ammobar_layer = new EffectLayer("Payday 2 - Ammo Bar");
                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_enabled)
                    {
                        hpbar_layer.PercentEffect((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).noammo_color,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_sequence,
                                                  (double)clip,
                                                  (double)clip_max,
                                                  (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).ammo_effect_type);
                    }

                    layers.Enqueue(ammobar_layer);
                }
                else if (player_state == PlayerState.Incapacitated || player_state == PlayerState.Bleed_out || player_state == PlayerState.Fatal)
                {
                    int incapAlpha = (int)(down_time > 10 ? 0 : 255 * (1.0D - (double)down_time / 10.0D));

                    if (incapAlpha > 255)
                    {
                        incapAlpha = 255;
                    }
                    else if (incapAlpha < 0)
                    {
                        incapAlpha = 0;
                    }

                    Color       incapColor  = Color.FromArgb(incapAlpha, (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).downed_color);
                    EffectLayer incap_layer = new EffectLayer("Payday 2 - Incapacitated", incapColor);
                    incap_layer.Set(Devices.DeviceKeys.Peripheral, incapColor);

                    layers.Enqueue(incap_layer);
                }
                else if (player_state == PlayerState.Arrested)
                {
                    Color       arrstedColor   = (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).arrested_color;
                    EffectLayer arrested_layer = new EffectLayer("Payday 2 - Arrested", arrstedColor);
                    arrested_layer.Set(Devices.DeviceKeys.Peripheral, arrstedColor);

                    layers.Enqueue(arrested_layer);
                }

                if (isSwanSong && (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_enabled)
                {
                    EffectLayer swansong_layer = new EffectLayer("Payday 2 - Swansong");

                    double blend_percent = Math.Pow(Math.Cos((currenttime % 1300L) / 1300.0D * (Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_speed_mult * 2.0D * Math.PI), 2.0D);

                    Color swansongColor = Utils.ColorUtils.MultiplyColorByScalar((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).swansong_color, blend_percent);

                    swansong_layer.Fill(swansongColor);

                    if ((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).bg_peripheral_use)
                    {
                        swansong_layer.Set(Devices.DeviceKeys.Peripheral, swansongColor);
                    }

                    layers.Enqueue(swansong_layer);
                }

                //Update Flashed
                if (flashbang_amount > 0)
                {
                    EffectLayer flashed_layer = new EffectLayer("Payday 2 - Flashed");

                    Color flash_color = Utils.ColorUtils.MultiplyColorByScalar(Color.White, flashbang_amount);

                    flashed_layer.Fill(flash_color);

                    layers.Enqueue(flashed_layer);
                }
            }

            //ColorZones
            EffectLayer cz_layer = new EffectLayer("Payday 2 - Color Zones");

            cz_layer.DrawColorZones((Global.Configuration.ApplicationProfiles[profilename].Settings as PD2Settings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            //Scripts
            Global.Configuration.ApplicationProfiles[profilename].UpdateEffectScripts(layers, _game_state);

            frame.AddLayers(layers.ToArray());

            lasttime = currenttime;
        }