<commit_before>﻿using UnityEngine;
using System.Collections;
using Assets.Paradigms.SearchAndFind.ImageEffects;

namespace Assets.BeMoBI.Paradigms.SearchAndFind.Scripts
{
    public class FogControl : MonoBehaviour
    {
        public CustomGlobalFog fogEffect;
        
        [Tooltip("Fog top Y coordinate")]
        public float HeightWhenRaised = 1.0f;
        [Range(0.001f, 10.0f)]
        public float HeightDensityWhenRaised = 2.0f;
        [Tooltip("Push fog away from the camera by this amount")]
        public float StartDistanceWhenRaised = 0.0f;

        public float RaisingSpeed = 0.1f;

        [Tooltip("Fog top Y coordinate when Fog disappeared")]
        public float HeightWhenDisappeared = 1.0f;
        [Range(0.001f, 10.0f)]
        public float DensityWhenDisappeared = 2.0f;
        [Tooltip("Push fog away from the camera by this amount")]
        public float StartDistanceWhenDisappeared = 0.0f;

        public float Disappearingspeed = 0.1f;

        public void RaiseFog()
        {
            StopCoroutine(ReduceFogToTargetValues());
            StartCoroutine(RaiseToTargetValues());
        }

        IEnumerator RaiseToTargetValues()
        {
            while (true)
            {
                if(fogEffect.height < HeightWhenRaised)
                    fogEffect.height += 1 * RaisingSpeed * Time.deltaTime;

                if (fogEffect.heightDensity < HeightDensityWhenRaised)
                    fogEffect.heightDensity += 1 * RaisingSpeed * Time.deltaTime;

                if(fogEffect.startDistance < StartDistanceWhenRaised)
                    fogEffect.startDistance += 1 * RaisingSpeed * Time.deltaTime;

                yield return new WaitWhile(FogHasRaisedCompletely);
            }
        }

        bool FogHasRaisedCompletely()
        {
            var result = fogEffect.height >= HeightWhenRaised &&
                         fogEffect.heightDensity >= HeightDensityWhenRaised &&
                         fogEffect.startDistance >= StartDistanceWhenRaised;

            return result;
        }

        public void LetFogDisappeare()
        {
            StopCoroutine(RaiseToTargetValues());
            StartCoroutine(ReduceFogToTargetValues());
        }

        IEnumerator ReduceFogToTargetValues()
        {
            var state = FogHasDisappearedCompletely();

            do
            {
                if (fogEffect.height > HeightWhenDisappeared)
                    fogEffect.height -= 1 * Disappearingspeed * Time.deltaTime;

                if (fogEffect.heightDensity > DensityWhenDisappeared)
                    fogEffect.heightDensity -= 1 * Disappearingspeed * Time.deltaTime;

                if (fogEffect.startDistance > StartDistanceWhenDisappeared)
                    fogEffect.startDistance -= 1 * Disappearingspeed * Time.deltaTime;

                yield return new WaitWhile(() => state);

            } while (!state);

            fogEffect.height = HeightWhenDisappeared;
            fogEffect.startDistance = StartDistanceWhenDisappeared;
            fogEffect.heightDensity = DensityWhenDisappeared;

        }

        bool FogHasDisappearedCompletely()
        {
            var result = fogEffect.height <= HeightWhenDisappeared &&
                         fogEffect.heightDensity <= DensityWhenDisappeared &&
                         fogEffect.startDistance <= StartDistanceWhenDisappeared;

            return result;
        }

        public void DisappeareImmediately()
        {
            fogEffect.height = HeightWhenDisappeared;
            fogEffect.heightDensity = DensityWhenDisappeared;
            fogEffect.startDistance = StartDistanceWhenDisappeared;
        }

        public void RaisedImmediately()
        {
            fogEffect.height = HeightWhenRaised;
            fogEffect.heightDensity = HeightDensityWhenRaised;
            fogEffect.startDistance = StartDistanceWhenRaised;
        }
    }

}<commit_msg>[BUGFIX] Simplify the FogControl... now only density changes<commit_after>﻿using UnityEngine;
using System.Collections;
using Assets.Paradigms.SearchAndFind.ImageEffects;

namespace Assets.BeMoBI.Paradigms.SearchAndFind.Scripts
{
    public class FogControl : MonoBehaviour
    {
        public CustomGlobalFog fogEffect;
        
        [Range(0.001f, 10.0f)]
        public float HeightDensityWhenRaised = 2.0f;
        public float RaisingSpeed = 0.1f;
        
        [Range(0.001f, 10.0f)]
        public float DensityWhenDisappeared = 2.0f;
        public float Disappearingspeed = 0.1f;

        public void RaiseFog()
        {
            StopAllCoroutines();
            StartCoroutine(RaiseToTargetValues());
        }

        IEnumerator RaiseToTargetValues()
        {
            var state = FogHasRaisedCompletely();

            do
            {
                if (fogEffect.heightDensity < HeightDensityWhenRaised)
                    fogEffect.heightDensity += 1 * RaisingSpeed * Time.deltaTime;
                
                yield return new WaitWhile(() => state);

            } while (!state) ;

            fogEffect.heightDensity = HeightDensityWhenRaised;
        }

        bool FogHasRaisedCompletely()
        {
            return fogEffect.heightDensity >= HeightDensityWhenRaised;
        }

        public void LetFogDisappeare()
        {
            StopAllCoroutines();
            StartCoroutine(ReduceFogToTargetValues());
        }

        IEnumerator ReduceFogToTargetValues()
        {
            var state = FogHasDisappearedCompletely();

            do
            {
                if (fogEffect.heightDensity > DensityWhenDisappeared)
                    fogEffect.heightDensity -= 1 * Disappearingspeed * Time.deltaTime;
                
                yield return new WaitWhile(() => state);

            } while (!state);
             
            fogEffect.heightDensity = DensityWhenDisappeared;
        }

        bool FogHasDisappearedCompletely()
        {  
            return fogEffect.heightDensity <= DensityWhenDisappeared;
        }

        public void DisappeareImmediately()
        {
            fogEffect.heightDensity = DensityWhenDisappeared;
        }

        public void RaisedImmediately()
        {
            fogEffect.heightDensity = HeightDensityWhenRaised; 
        }
    }

}
{'fraction_non_alphanumeric': 0.07291171342526549, 'fraction_numerical': 0.009510223490252021, 'mean_word_length': 1.8839122486288848, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 0, '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': '7584425', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1687, 'n_words': 315}