Beispiel #1
0
 private void SpawnForcedEntities()
 {
     if (this._forcedSpawns.Count == 0)
     {
         return;
     }
     for (int index = this._forcedSpawns.Count - 1; index >= 0; --index)
     {
         AmbienceServer.AmbienceSpawnInfo forcedSpawn = this._forcedSpawns[index];
         Player player;
         if (forcedSpawn.targetPlayer == -1)
         {
             AmbienceServer.FindPlayerThatCanSeeBackgroundAmbience(out player);
         }
         else
         {
             player = Main.player[forcedSpawn.targetPlayer];
         }
         if (player != null && this.IsPlayerAtRightHeightForType(forcedSpawn.skyEntityType, player))
         {
             this.SpawnForPlayer(player, forcedSpawn.skyEntityType);
         }
         this._forcedSpawns.RemoveAt(index);
     }
 }
Beispiel #2
0
 public void Update()
 {
     this.SpawnForcedEntities();
     if (this._updatesUntilNextAttempt > 0)
     {
         this._updatesUntilNextAttempt -= Main.dayRate;
     }
     else
     {
         this.ResetSpawnTime();
         IEnumerable <SkyEntityType> source1 = this._spawnConditions.Where <KeyValuePair <SkyEntityType, Func <bool> > >((Func <KeyValuePair <SkyEntityType, Func <bool> >, bool>)(pair => pair.Value())).Select <KeyValuePair <SkyEntityType, Func <bool> >, SkyEntityType>((Func <KeyValuePair <SkyEntityType, Func <bool> >, SkyEntityType>)(pair => pair.Key));
         if (source1.Count <SkyEntityType>((Func <SkyEntityType, bool>)(type => true)) == 0)
         {
             return;
         }
         Player player;
         AmbienceServer.FindPlayerThatCanSeeBackgroundAmbience(out player);
         if (player == null)
         {
             return;
         }
         IEnumerable <SkyEntityType> source2 = source1.Where <SkyEntityType>((Func <SkyEntityType, bool>)(type => this.IsPlayerAtRightHeightForType(type, player) && this._secondarySpawnConditionsPerPlayer.ContainsKey(type) && this._secondarySpawnConditionsPerPlayer[type](player)));
         int maxValue = source2.Count <SkyEntityType>((Func <SkyEntityType, bool>)(type => true));
         if (maxValue == 0 || Main.rand.Next(5) < 3)
         {
             source2 = source1.Where <SkyEntityType>((Func <SkyEntityType, bool>)(type =>
             {
                 if (!this.IsPlayerAtRightHeightForType(type, player))
                 {
                     return(false);
                 }
                 return(!this._secondarySpawnConditionsPerPlayer.ContainsKey(type) || this._secondarySpawnConditionsPerPlayer[type](player));
             }));
             maxValue = source2.Count <SkyEntityType>((Func <SkyEntityType, bool>)(type => true));
         }
         if (maxValue == 0)
         {
             return;
         }
         SkyEntityType type1 = source2.ElementAt <SkyEntityType>(Main.rand.Next(maxValue));
         this.SpawnForPlayer(player, type1);
     }
 }