<commit_before>﻿// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Configuration;
using osu.Framework.Configuration;

namespace osu.Game.Rulesets.Osu.Mods
{
    public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects, IReadFromConfig
    {
        public override string Description => @"Play with no approach circles and fading notes for a slight score advantage.";
        public override double ScoreMultiplier => 1.06;
        private const double fade_in_duration_multiplier = 0.4;
        private const double fade_out_duration_multiplier = 0.3;
        private Bindable<bool> increaseFirstObjectVisibility;

        public void ReadFromConfig(OsuConfigManager config)
        {
            increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
        }

        public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
        {
            //In the Tests for hidden the ReadFromConfig() void isn't called -> the following bindable is null
            //It's too much work to get the Dependency Injection on the Tests to get the config for just this mod, so I just make sure
            //the bindable isn't null
            foreach (var d in drawables.OfType<DrawableOsuHitObject>())
            {
                //Don't hide the first object ("drawables" are in a reverse order -> Last() )
                if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue;
                d.ApplyCustomUpdateState += ApplyHiddenState;

                d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier;
                foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
                    h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier;
            }
        }

        protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
        {
            if (!(drawable is DrawableOsuHitObject d))
                return;<commit_msg>cleared comment<commit_after>﻿// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Configuration;
using osu.Framework.Configuration;

namespace osu.Game.Rulesets.Osu.Mods
{
    public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects, IReadFromConfig
    {
        public override string Description => @"Play with no approach circles and fading notes for a slight score advantage.";
        public override double ScoreMultiplier => 1.06;
        private const double fade_in_duration_multiplier = 0.4;
        private const double fade_out_duration_multiplier = 0.3;
        private Bindable<bool> increaseFirstObjectVisibility;

        public void ReadFromConfig(OsuConfigManager config)
        {
            increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
        }

        public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
        {
            foreach (var d in drawables.OfType<DrawableOsuHitObject>())
            {
                //Don't hide the first object ("drawables" are in a reverse order -> Last() )
                //If increaseFirstObjectVisibility is null then we're exectuing one of the tests for the hidden mod. Since it's too much
                //work for just this interface to work on this tests (DI of the config..), I just make sure to not throw a null exception
                if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue;
                d.ApplyCustomUpdateState += ApplyHiddenState;

                d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier;
                foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
                    h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier;
            }
        }

        protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
        {
            if (!(drawable is DrawableOsuHitObject d))
                return;
{'fraction_non_alphanumeric': 0.08045742291198693, 'fraction_numerical': 0.00612619971411068, 'mean_word_length': 2.988599348534202, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5096554', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1324, 'n_words': 363}