コード例 #1
0
 private void ExtendRiver(float[] flow, List <int>[] riverPaths, int index, RiverDef incomingRiver)
 {
     if (riverPaths[index] != null)
     {
         int      bestOutput = riverPaths[index].MaxBy((int ni) => flow[ni]);
         RiverDef riverDef   = incomingRiver;
         while (riverDef != null && (float)riverDef.degradeThreshold > flow[bestOutput])
         {
             riverDef = riverDef.degradeChild;
         }
         if (riverDef != null)
         {
             Find.WorldGrid.OverlayRiver(index, bestOutput, riverDef);
             ExtendRiver(flow, riverPaths, bestOutput, riverDef);
         }
         if (incomingRiver.branches != null)
         {
             foreach (int alternateRiver in from ni in riverPaths[index]
                      where ni != bestOutput
                      select ni)
             {
                 RiverDef.Branch branch2 = incomingRiver.branches.Where((RiverDef.Branch branch) => (float)branch.minFlow <= flow[alternateRiver]).MaxByWithFallback((RiverDef.Branch branch) => branch.minFlow);
                 if (branch2 != null && Rand.Value < branch2.chance)
                 {
                     Find.WorldGrid.OverlayRiver(index, alternateRiver, branch2.child);
                     ExtendRiver(flow, riverPaths, alternateRiver, branch2.child);
                 }
             }
         }
     }
 }
コード例 #2
0
        private void ExtendRiver(float[] flow, List <int>[] riverPaths, int index, RiverDef incomingRiver)
        {
            if (riverPaths[index] == null)
            {
                return;
            }
            int      bestOutput = riverPaths[index].MaxBy((int ni) => flow[ni]);
            RiverDef riverDef   = incomingRiver;

            while (riverDef != null && (float)riverDef.degradeThreshold > flow[bestOutput])
            {
                riverDef = riverDef.degradeChild;
            }
            if (riverDef != null)
            {
                Find.WorldGrid.OverlayRiver(index, bestOutput, riverDef);
                this.ExtendRiver(flow, riverPaths, bestOutput, riverDef);
            }
            if (incomingRiver.branches != null)
            {
                using (IEnumerator <int> enumerator = (from ni in riverPaths[index]
                                                       where ni != bestOutput
                                                       select ni).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        int             alternateRiver = enumerator.Current;
                        RiverDef.Branch branch2        = (from branch in incomingRiver.branches
                                                          where (float)branch.minFlow <= flow[alternateRiver]
                                                          select branch).MaxByWithFallback((RiverDef.Branch branch) => branch.minFlow, null);
                        if (branch2 != null && Rand.Value < branch2.chance)
                        {
                            Find.WorldGrid.OverlayRiver(index, alternateRiver, branch2.child);
                            this.ExtendRiver(flow, riverPaths, alternateRiver, branch2.child);
                        }
                    }
                }
            }
        }
コード例 #3
0
 private static int <ExtendRiver> m__2(RiverDef.Branch branch)
 {
     return(branch.minFlow);
 }