Example #1
0
    public CarPart GetPartWithHighestStat(CarPart.PartType inType, CarPartStats.CarPartStat inStat)
    {
        CarPart        carPart       = (CarPart)null;
        List <CarPart> partInventory = this.GetPartInventory(inType);

        for (int index = 0; index < partInventory.Count; ++index)
        {
            switch (inStat)
            {
            case CarPartStats.CarPartStat.MainStat:
                if (!partInventory[index].IsBanned && (carPart == null || (double)partInventory[index].stats.statWithPerformance > (double)carPart.stats.statWithPerformance))
                {
                    carPart = partInventory[index];
                    break;
                }
                break;

            case CarPartStats.CarPartStat.Reliability:
                if (!partInventory[index].IsBanned && (carPart == null || (double)partInventory[index].stats.reliability > (double)carPart.stats.reliability))
                {
                    carPart = partInventory[index];
                    break;
                }
                break;
            }
        }
        return(carPart);
    }
Example #2
0
    public float GetHighestStatOfType(CarPart.PartType inType, CarPartStats.CarPartStat inStat)
    {
        CarPart partWithHighestStat = this.GetPartWithHighestStat(inType, inStat);

        if (partWithHighestStat == null)
        {
            return(0.0f);
        }
        return(partWithHighestStat.stats.statWithPerformance);
    }
    public float GetStat(CarPartStats.CarPartStat inStat)
    {
        float num = 0.0f;

        switch (inStat)
        {
        case CarPartStats.CarPartStat.MainStat:
            num = this.mStat;
            break;

        case CarPartStats.CarPartStat.Reliability:
            num = this.mReliability;
            break;

        case CarPartStats.CarPartStat.Condition:
            num = this.partCondition.condition;
            break;

        case CarPartStats.CarPartStat.Performance:
            num = this.mPerformance;
            break;
        }
        return(num);
    }
    public void SetStat(CarPartStats.CarPartStat inStat, float inValue)
    {
        switch (inStat)
        {
        case CarPartStats.CarPartStat.MainStat:
            this.mStat = inValue;
            break;

        case CarPartStats.CarPartStat.Reliability:
            this.mReliability = inValue;
            this.mReliability = this.mReliability.Clamp(0.0f, this.maxReliability);
            this.SetStat(CarPartStats.CarPartStat.Condition, this.mReliability);
            break;

        case CarPartStats.CarPartStat.Condition:
            this.partCondition.SetCondition(inValue);
            break;

        case CarPartStats.CarPartStat.Performance:
            this.mPerformance = inValue;
            this.mPerformance = Math.Min(this.mPerformance, this.maxPerformance);
            break;
        }
    }
Example #5
0
    public void AutoFit(Car inCar, CarManager.AutofitOptions inOption, CarManager.AutofitAvailabilityOption inAvailabilityOption)
    {
        this.UnfitAllParts(inCar);
        bool flag1 = false;

        switch (inAvailabilityOption)
        {
        case CarManager.AutofitAvailabilityOption.AllParts:
            flag1 = false;
            break;

        case CarManager.AutofitAvailabilityOption.UnfitedParts:
            flag1 = true;
            break;
        }
        CarPartStats.CarPartStat inStat1 = CarPartStats.CarPartStat.MainStat;
        CarPartStats.CarPartStat inStat2 = CarPartStats.CarPartStat.Reliability;
        switch (inOption)
        {
        case CarManager.AutofitOptions.Performance:
            inStat1 = CarPartStats.CarPartStat.MainStat;
            inStat2 = CarPartStats.CarPartStat.Reliability;
            break;

        case CarManager.AutofitOptions.Reliability:
            inStat1 = CarPartStats.CarPartStat.Reliability;
            inStat2 = CarPartStats.CarPartStat.MainStat;
            break;
        }
        CarPart.PartType[] partType = CarPart.GetPartType(this.mTeam.championship.series, false);
        for (int index1 = 0; index1 < partType.Length; ++index1)
        {
            List <CarPart> partInventory     = this.partInventory.GetPartInventory(partType[index1]);
            CarPart        seriesCurrentPart = inCar.seriesCurrentParts[index1];
            for (int index2 = 0; index2 < partInventory.Count; ++index2)
            {
                if (!flag1 || !partInventory[index2].isFitted)
                {
                    bool flag2 = false;
                    bool flag3 = false;
                    if (seriesCurrentPart != null)
                    {
                        switch (inStat1)
                        {
                        case CarPartStats.CarPartStat.MainStat:
                            flag2 = (double)seriesCurrentPart.stats.statWithPerformance < (double)partInventory[index2].stats.statWithPerformance;
                            flag3 = (double)seriesCurrentPart.stats.statWithPerformance == (double)partInventory[index2].stats.statWithPerformance && (double)seriesCurrentPart.stats.GetStat(inStat2) < (double)partInventory[index2].stats.GetStat(inStat2);
                            break;

                        case CarPartStats.CarPartStat.Reliability:
                            flag2 = (double)seriesCurrentPart.stats.GetStat(inStat1) < (double)partInventory[index2].stats.GetStat(inStat1);
                            flag3 = (double)seriesCurrentPart.stats.GetStat(inStat1) == (double)partInventory[index2].stats.GetStat(inStat1) && (double)seriesCurrentPart.stats.statWithPerformance < (double)partInventory[index2].stats.statWithPerformance;
                            break;
                        }
                    }
                    if ((seriesCurrentPart == null || flag2 || flag3) && inCar.FitPart(partInventory[index2]))
                    {
                        seriesCurrentPart = partInventory[index2];
                    }
                }
            }
        }
    }