<commit_before>﻿using FlatRedBall;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dodgeball.Components
{


    public class ChargeThrow
    {
        private const float MaxValidThrowPercent = 80;
        public float MeterPercent { get; set; }
        private float defaultChargeLevel = 10f;

        public float LowEndChargeRate { get; set; }
        public float HighEndChargeRate { get; set; }

        private int chargeDirection = 1;

        public float EffectiveChargePercent => MeterPercent / MaxValidThrowPercent;
        public bool FailedThrow => MeterPercent > MaxValidThrowPercent;

        public void ChargeActivity()
        {
            MeterPercent += GetCurrentChargeRate() * chargeDirection * TimeManager.SecondDifference;

            //Change direction at top/bottom of charge
            if (MeterPercent < 0 || MeterPercent > 100) chargeDirection *= -1;

            //Keep charge within bar
            MeterPercent = MathHelper.Clamp(MeterPercent, 0, 100);
        }

        private float GetCurrentChargeRate()
        {
            float normalizedMeterPercentage = MeterPercent / 100.0f;

            return MathHelper.Lerp(LowEndChargeRate, HighEndChargeRate, normalizedMeterPercentage);
        }

        public void Reset()
        {
            MeterPercent = defaultChargeLevel;
        }
    }
}
<commit_msg>Charge meter now wraps rather than going back and forth<commit_after>﻿using FlatRedBall;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dodgeball.Components
{


    public class ChargeThrow
    {
        private const float MaxValidThrowPercent = 80;
        public float MeterPercent { get; set; }
        private float defaultChargeLevel = 10f;

        public float LowEndChargeRate { get; set; }
        public float HighEndChargeRate { get; set; }

        public float EffectiveChargePercent => MeterPercent / MaxValidThrowPercent;
        public bool FailedThrow => MeterPercent > MaxValidThrowPercent;

        public void ChargeActivity()
        {
            MeterPercent += GetCurrentChargeRate() * TimeManager.SecondDifference;

            //Reset at top of charge
            if (MeterPercent > 100) MeterPercent = 0;

            //Keep charge within bar
            MeterPercent = MathHelper.Clamp(MeterPercent, 0, 100);
        }

        private float GetCurrentChargeRate()
        {
            float normalizedMeterPercentage = MeterPercent / 100.0f;

            return MathHelper.Lerp(LowEndChargeRate, HighEndChargeRate, normalizedMeterPercentage);
        }

        public void Reset()
        {
            MeterPercent = defaultChargeLevel;
        }
    }
}

{'fraction_non_alphanumeric': 0.0696047569080098, 'fraction_numerical': 0.011892270024484085, 'mean_word_length': 2.5265104808877927, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, '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': '2392463', 'n_tokens_mistral': 781, 'n_tokens_neox': 731, 'n_words': 203}