Beispiel #1
0
    private static GeneWeighting GetDominantGeneWeighting(GrowableEntity crossBreedingGrowable, List <GrowableEntity> neighbours, int slot)
    {
        PlanterBox planter = crossBreedingGrowable.GetPlanter();

        if (planter == null)
        {
            dominant.Weighting = -1f;
            return(dominant);
        }
        for (int i = 0; i < neighbourWeights.Length; i++)
        {
            neighbourWeights[i].Weighting = 0f;
            neighbourWeights[i].GeneType  = (GeneType)i;
        }
        dominant.Weighting = 0f;
        foreach (GrowableEntity neighbour in neighbours)
        {
            if (!neighbour.isServer)
            {
                continue;
            }
            PlanterBox planter2 = neighbour.GetPlanter();
            if (!(planter2 == null) && !(planter2 != planter) && !(neighbour == crossBreedingGrowable) && neighbour.prefabID == crossBreedingGrowable.prefabID && !neighbour.IsDead())
            {
                GeneType type = neighbour.Genes.Genes[slot].Type;
                float    crossBreedingWeight = neighbour.Properties.Genes.Weights[(int)type].CrossBreedingWeight;
                float    num = (neighbourWeights[(int)type].Weighting += crossBreedingWeight);
                if (num > dominant.Weighting)
                {
                    dominant.Weighting = num;
                    dominant.GeneType  = type;
                }
            }
        }
        return(dominant);
    }