C# 如何从受保护函数中获取数组变量并将其传输到C中的另一个.cs文件#

C# 如何从受保护函数中获取数组变量并将其传输到C中的另一个.cs文件#,c#,arrays,.net-core,global-variables,C#,Arrays,.net Core,Global Variables,我的最终目标是将数组变量double[]JumpDistanceArray从…\embition\Skills\aim.cs传输到…\embition\osPerformanceCalculator.cs。由于变量被封装在受保护的覆盖函数中protected override double StrainValueOf(HardicultyHitObject current)我无法使用Skills.Aim.StrainValueOf.JumpDistanceArray.Average()与之关联我

我的最终目标是将数组变量
double[]JumpDistanceArray
从…\embition\Skills\aim.cs传输到…\embition\osPerformanceCalculator.cs。由于变量被封装在受保护的覆盖函数中
protected override double StrainValueOf(HardicultyHitObject current)
我无法使用
Skills.Aim.StrainValueOf.JumpDistanceArray.Average()与之关联我也不能将其从受保护状态中移除,因为这将导致许多我无法解决的连锁反应,例如

'Aim.StrainValueOf(艰难HitObject)':无法更改访问权限 重写“受保护”继承成员时的修饰符 'Skill.straintValueof(困难HitObject)' [osu.Game.ruleset.osu]csharp(CS0507)

我在这个网站上尝试了很多建议的解决方案,但是很多解决方案太广泛了,我无法正确理解并实施到这个特定类型的问题中

代码
…\defestion\Skills\aim.cs

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Linq;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
using osu.Game.Rulesets.Osu.Objects;
using static System.Math;

namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
    /// <summary>
    /// Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
    /// </summary>
    public class Aim : Skill
    {
        private const double angle_bonus_begin = Math.PI / 3;
        private const double timing_threshold = 107;
        private const double streamaimconst = 2.42;
        private const double stdevconst = 0.149820;
        /// public static double[] JumpDistanceArray;

        protected override double SkillMultiplier => 26.25;
        protected override double StrainDecayBase => 0.15;

        /// Standard Deviation Calculation Code courtesy of Roman http://csharphelper.com/blog/2015/12/make-an-extension-method-that-calculates-standard-deviation-in-c/
        /// public static double GetStandardDeviation(List values)
        ///     {
        ///     double avg = values.Average();
        ///     double sum = values.Sum(v => (v - avg) * (v-avg));
        ///     double denominator = values.Count - 1;
        ///     return denominator > 0.0 ? Math.Sqrt(sum / denominator) : -1;
        ///     };
                /// Use JumpDistanceArray to calculate SD
                /// https://stackoverflow.com/a/5336708
                /// double average = JumpDistanceArray.Average();
                /// double sumOfSquaresOfDifferences = JumpDistanceArray.Select(val => (val - average) * (val - average)).Sum();
                /// double finalsd = Math.Sqrt(sumOfSquaresOfDifferences / JumpDistanceArray.Length); 
                /// double finalsdpp = finalsd/stdevconst when missCount = 0;

        protected override double StrainValueOf(DifficultyHitObject current)
        {
            if (current.BaseObject is Spinner)
                return 0;

            var osuCurrent = (OsuDifficultyHitObject)current;

            double result = 0;

            double sectionvelocity = osuCurrent.JumpDistance/osuCurrent.StrainTime;
            double[] JumpDistanceArray = new double[32767];
            if (sectionvelocity < streamaimconst) 
                { 
                    int jumpdistpointercount = 0;
                    JumpDistanceArray[jumpdistpointercount] = osuCurrent.JumpDistance;
                    jumpdistpointercount = jumpdistpointercount + 1;
                }

            if (Previous.Count > 0)
            {
                var osuPrevious = (OsuDifficultyHitObject)Previous[0];

                if (osuCurrent.Angle != null && osuCurrent.Angle.Value > angle_bonus_begin)
                {
                    const double scale = 90;

                    var angleBonus = Math.Sqrt(
                        Math.Max(osuPrevious.JumpDistance - scale, 0)
                        * Math.Pow(Math.Sin(osuCurrent.Angle.Value - angle_bonus_begin), 2)
                        * Math.Max(osuCurrent.JumpDistance - scale, 0));
                    result = 1.5 * applyDiminishingExp(Math.Max(0, angleBonus)) / Math.Max(timing_threshold, osuPrevious.StrainTime);
                }
            }

            double jumpDistanceExp = applyDiminishingExp(osuCurrent.JumpDistance);
            double travelDistanceExp = applyDiminishingExp(osuCurrent.TravelDistance);

            return Math.Max(
                result + (jumpDistanceExp + travelDistanceExp + Math.Sqrt(travelDistanceExp * jumpDistanceExp)) / Math.Max(osuCurrent.StrainTime, timing_threshold),
                (Math.Sqrt(travelDistanceExp * jumpDistanceExp) + jumpDistanceExp + travelDistanceExp) / osuCurrent.StrainTime
            );
        }

        private double applyDiminishingExp(double val) => Math.Pow(val, 0.99);
    }
}
//版权所有(c)ppy私人有限公司。获得麻省理工学院许可证。
//请参阅存储库根目录中的许可证文件以获取完整的许可证文本。
使用制度;
使用System.Linq;
使用osu.Game.Rulesets.defficiency;
使用osu.Game.Rulesets.demobility.Preprocessing;
使用osu.Game.Rulesets.defficiency.Skills;
使用osu.Game.Rulesets.osu.demobility.Preprocessing;
使用osu.Game.Rulesets.osu.Objects;
使用静态系统。数学;
命名空间osu.Game.Rulesets.osu.demobility.Skills
{
/// 
///表示以统一的圆圈大小和标准化距离正确瞄准地图中的每个对象所需的技能。
/// 
公共课目标:技能
{
private const double angle\u bonus\u begin=Math.PI/3;
私有常数双定时_阈值=107;
私有常数双流aimconst=2.42;
私人常数双标准差=0.149820;
///公共静态双[]跳线距离阵列;
受保护的覆盖双技能乘数=>26.25;
保护覆盖双应变Decaybase=>0.15;
///标准偏差计算代码由Roman提供http://csharphelper.com/blog/2015/12/make-an-extension-method-that-calculates-standard-deviation-in-c/
///公共静态双标准偏差(列表值)
///     {
///双平均值=值。平均值();
///双和=值。和(v=>(v-avg)*(v-avg));
///双分母=值。计数-1;
///返回分母>0.0?数学Sqrt(总和/分母):-1;
///     };
///使用JumpDistanceArray计算SD
/// https://stackoverflow.com/a/5336708
///双平均=JumpDistanceArray.average();
///double sumOfSquaresOfDifferences=JumpDistanceArray。选择(val=>(val-平均值)*(val-平均值)).Sum();
///double finalsd=Math.Sqrt(平方差之和/跳跃距离数组.Length);
///当错误计数为0时,双finalsdpp=finalsd/stdevconst;
受保护的覆盖双应变值(困难HitObject当前)
{
if(current.BaseObject是微调器)
返回0;
var osuCurrent=(OsuDifficultyHitObject)电流;
双结果=0;
双段速度=osuCurrent.JumpDistance/osuCurrent.strainttime;
double[]JumpDistanceArray=新的双精度[32767];
如果(截面速度0)
{
var osuprovision=(OsuDifficultyHitObject)Previous[0];
如果(oscurrent.Angle!=null&&oscurrent.Angle.Value>Angle\u bonus\u begin)
{
常数双刻度=90;
var angleBonus=Math.Sqrt(
Math.Max(0.JumpDistance-比例,0)
*Math.Pow(Math.Sin(osurrent.Angle.Value-Angle\u bonus\u begin),2)
*数学最大值(当前跳距-刻度,0);
结果=1.5*applyDiminishingExp(Math.Max(0,angleBonus))/Math.Max(timing_threshold,Osuperion.StrainTime);
}
}
双跳线距离exp=applyDiminishingExp(OSU电流.跳线距离);
double travelDistanceExp=applyDiminishingExp(OSCURRENT.TravelDistance);
返回Math.Max(
结果+(jumpDistanceExp+travelDistanceExp+Math.Sqrt(travelDistanceExp*jumpDistanceExp))/Math.Max(OSCURRENT.STREANTIME,timing_阈值),
(数学Sqrt(travelDistanceExp*jumpDistanceExp)+jumpDistanceExp+travelDistanceExp)/OSCURRENT.STREANTIME
);
}
私有双applyDiminishingExp(double val)=>Math.Pow(val,0.99);
}
}
…\employment\OSPerformanceCalculator.cs

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Osu.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using static System.Math;

namespace osu.Game.Rulesets.Osu.Difficulty
{
    public class OsuPerformanceCalculator : PerformanceCalculator
    {
        public new OsuDifficultyAttributes Attributes => (OsuDifficultyAttributes)base.Attributes;

        private readonly int countHitCircles;
        private readonly int beatmapMaxCombo;

        private Mod[] mods;

        private double accuracy;
        private int scoreMaxCombo;
        private int countGreat;
        private int countGood;
        private int countMeh;
        private int countMiss;

        private const double streamaimconst = 2.42;
        private const double stdevconst = 0.149820;

        public OsuPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
            : base(ruleset, beatmap, score)
        {
            countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);

            beatmapMaxCombo = Beatmap.HitObjects.Count;
            // Add the ticks + tail of the slider. 1 is subtracted because the "headcircle" would be counted twice (once for the slider itself in the line above)
            beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count - 1);
        }

        public override double Calculate(Dictionary<string, double> categoryRatings = null)
        {
            mods = Score.Mods;
            accuracy = Score.Accuracy;
            scoreMaxCombo = Score.MaxCombo;
            countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
            countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
            countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
            countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);

            // Don't count scores made with supposedly unranked mods
            if (mods.Any(m => !m.Ranked))
                return 0;

            // Custom multipliers for NoFail and SpunOut.
            double multiplier = 1.12f; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things

            if (mods.Any(m => m is OsuModNoFail))
                multiplier *= 0.90f;

            if (mods.Any(m => m is OsuModSpunOut))
                multiplier *= 0.95f;

            double aimValue = computeAimValue();
            double speedValue = computeSpeedValue();
            double accuracyValue = computeAccuracyValue();
            double totalValue =
                Math.Pow(
                    Math.Pow(aimValue, 1.1f) +
                    Math.Pow(speedValue, 1.1f) +
                    Math.Pow(accuracyValue, 1.1f), 1.0f / 1.1f
                ) * multiplier;

            if (categoryRatings != null)
            {
                categoryRatings.Add("Aim", aimValue);
                categoryRatings.Add("Speed", speedValue);
                categoryRatings.Add("Accuracy", accuracyValue);
                categoryRatings.Add("OD", Attributes.OverallDifficulty);
                categoryRatings.Add("AR", Attributes.ApproachRate);
                categoryRatings.Add("Max Combo", beatmapMaxCombo);
            }

            return totalValue;
        }

        private double computeAimValue()
        {
            /// var Aim = new Aim();
            double average = Skills.Aim.StrainValueOf.JumpDistanceArray.Average();
            double sumOfSquaresOfDifferences = Skills.Aim.StrainValueOf.JumpDistanceArray.Select(val => (val - average) * (val - average)).Sum();
            double finalsd = Math.Sqrt(sumOfSquaresOfDifferences / Skills.Aim.StrainValueOf.JumpDistanceArray.Length); 
            double finalsdpp = 0;
            if (countMiss == 0) 
                  finalsdpp = finalsdpp+(finalsd/stdevconst);
            double rawAim = Attributes.AimStrain + finalsdpp;

            if (mods.Any(m => m is OsuModTouchDevice))
                rawAim = Math.Pow(rawAim, 0.8);

            double aimValue = Math.Pow(5.0f * Math.Max(1.0f, rawAim / 0.0675f) - 4.0f, 3.0f) / 100000.0f;

            // Longer maps are worth more
            double lengthBonus = 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +
                                 (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f);

            aimValue *= lengthBonus;

            // Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
            aimValue *= Math.Pow(0.97f, countMiss);

            // Combo scaling
            if (beatmapMaxCombo > 0)
                aimValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8f) / Math.Pow(beatmapMaxCombo, 0.8f), 1.0f);

            double approachRateFactor = 1.0f;

            if (Attributes.ApproachRate > 10.33f)
                approachRateFactor += 0.3f * (Attributes.ApproachRate - 10.33f);
            else if (Attributes.ApproachRate < 8.0f)
            {
                approachRateFactor += 0.01f * (8.0f - Attributes.ApproachRate);
            }

            aimValue *= approachRateFactor;

            // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
            if (mods.Any(h => h is OsuModHidden))
                aimValue *= 1.0f + 0.04f * (12.0f - Attributes.ApproachRate);

            if (mods.Any(h => h is OsuModFlashlight))
            {
                // Apply object-based bonus for flashlight.
                aimValue *= 1.0f + 0.35f * Math.Min(1.0f, totalHits / 200.0f) +
                            (totalHits > 200
                                ? 0.3f * Math.Min(1.0f, (totalHits - 200) / 300.0f) +
                                  (totalHits > 500 ? (totalHits - 500) / 1200.0f : 0.0f)
                                : 0.0f);
            }

            // Scale the aim value with accuracy _slightly_
            aimValue *= 0.5f + accuracy / 2.0f;
            // It is important to also consider accuracy difficulty when doing that
            aimValue *= 0.98f + Math.Pow(Attributes.OverallDifficulty, 2) / 2500;

            return aimValue;
        }

        private double computeSpeedValue()
        {
            double speedValue = Math.Pow(5.0f * Math.Max(1.0f, Attributes.SpeedStrain / 0.0675f) - 4.0f, 3.0f) / 100000.0f;

            // Longer maps are worth more
            speedValue *= 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +
                          (totalHits > 2000 ? Math.Log10(totalHits / 2000.0f) * 0.5f : 0.0f);

            // Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
            speedValue *= Math.Pow(0.97f, countMiss);

            // Combo scaling
            if (beatmapMaxCombo > 0)
                speedValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8f) / Math.Pow(beatmapMaxCombo, 0.8f), 1.0f);

            double approachRateFactor = 1.0f;
            if (Attributes.ApproachRate > 10.33f)
                approachRateFactor += 0.3f * (Attributes.ApproachRate - 10.33f);

            speedValue *= approachRateFactor;

            if (mods.Any(m => m is OsuModHidden))
                speedValue *= 1.0f + 0.04f * (12.0f - Attributes.ApproachRate);

            // Scale the speed value with accuracy _slightly_
            speedValue *= 0.02f + accuracy;
            // It is important to also consider accuracy difficulty when doing that
            speedValue *= 0.96f + Math.Pow(Attributes.OverallDifficulty, 2) / 1600;

            return speedValue;
        }

        private double computeAccuracyValue()
        {
            // This percentage only considers HitCircles of any value - in this part of the calculation we focus on hitting the timing hit window
            double betterAccuracyPercentage;
            int amountHitObjectsWithAccuracy = countHitCircles;

            if (amountHitObjectsWithAccuracy > 0)
                betterAccuracyPercentage = ((countGreat - (totalHits - amountHitObjectsWithAccuracy)) * 6 + countGood * 2 + countMeh) / (amountHitObjectsWithAccuracy * 6);
            else
                betterAccuracyPercentage = 0;

            // It is possible to reach a negative accuracy with this formula. Cap it at zero - zero points
            if (betterAccuracyPercentage < 0)
                betterAccuracyPercentage = 0;

            // Lots of arbitrary values from testing.
            // Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
            double accuracyValue = Math.Pow(1.52163f, Attributes.OverallDifficulty) * Math.Pow(betterAccuracyPercentage, 24) * 2.83f;

            // Bonus for many hitcircles - it's harder to keep good accuracy up for longer
            accuracyValue *= Math.Min(1.15f, Math.Pow(amountHitObjectsWithAccuracy / 1000.0f, 0.3f));

            if (mods.Any(m => m is OsuModHidden))
                accuracyValue *= 1.08f;
            if (mods.Any(m => m is OsuModFlashlight))
                accuracyValue *= 1.02f;

            return accuracyValue;
        }

        private double totalHits => countGreat + countGood + countMeh + countMiss;
        private double totalSuccessfulHits => countGreat + countGood + countMeh;
    }
}
//版权所有(c)ppy私人有限公司。获得麻省理工学院许可证。
//请参阅存储库根目录中的许可证文件以获取完整的许可证文本。
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用osu.Game.Beatmaps;
使用osu.Game.Rulesets.defficiency;
使用osu.Game.Rulesets.demobility.Preprocessing;
使用osu.Game.Rulesets.defficiency.Skills;
使用osu.Game.Rulesets.osu.demobility.Skills;
使用osu.Game.Rulesets.Mods;
使用osu.Game.Rulesets.osu.Mods;
使用osu.Game.Rulesets.osu.Objects;
使用osu.Game.ruleset.Scoring;
使用osu.Game.Scoring;
使用静态系统。数学;
名称空间osu.Game.Rulesets.osu.constitution
{
公共类性能计算器:性能计算器
{
公共新OsuDifficultyAttributes=>(OsuDifficulty