public List <Entity> LoadUnspawnedEntities(Int3 batchId) { lock (parsedBatches) { if (parsedBatches.Contains(batchId)) { return(new List <Entity>()); } parsedBatches.Add(batchId); } Log.Debug("Batch {0} not parsed yet; parsing...", batchId); List <Entity> entities = new List <Entity>(); foreach (EntitySpawnPoint esp in batchCellsParser.ParseBatchData(batchId)) { if (esp.Density > 0) { DstData dstData; if (lootDistributionData.GetBiomeLoot(esp.BiomeType, out dstData)) { entities.AddRange(SpawnEntitiesUsingRandomDistribution(esp, dstData)); } else if (esp.ClassId != null) { entities.AddRange(SpawnEntitiesStaticly(esp)); } } } return(entities); }
public List <Entity> LoadUnspawnedEntities(Int3 batchId) { lock (parsedBatches) { if (parsedBatches.Contains(batchId)) { return(new List <Entity>()); } parsedBatches.Add(batchId); } DeterministicBatchGenerator deterministicBatchGenerator = new DeterministicBatchGenerator(batchId); List <Entity> entities = new List <Entity>(); List <EntitySpawnPoint> spawnPoints = batchCellsParser.ParseBatchData(batchId); entities = SpawnEntities(spawnPoints, deterministicBatchGenerator); if (entities.Count == 0) { lock (emptyBatches) { emptyBatches.Add(batchId); } } else { Log.Info("Spawning " + entities.Count + " entities from " + spawnPoints.Count + " spawn points in batch " + batchId); } return(entities); }
/// <summary> /// Spawns entities for <paramref name="batchId"/> if it was not loaded yet. /// </summary> public Optional <IDictionary <AbsoluteEntityCell, List <Entity> > > SpawnUnloadedEntitiesForBatch(Int3 batchId) { lock (parsedBatches) { if (parsedBatches.Contains(batchId)) { return(Optional <IDictionary <AbsoluteEntityCell, List <Entity> > > .Empty()); } parsedBatches.Add(batchId); } Log.Debug("Batch {0} not parsed yet; parsing...", batchId); IDictionary <AbsoluteEntityCell, List <Entity> > entitiesByAbsoluteCell = new Dictionary <AbsoluteEntityCell, List <Entity> >(); foreach (EntitySpawnPoint esp in batchCellsParser.ParseBatchData(batchId)) { List <Entity> entities; if (!entitiesByAbsoluteCell.TryGetValue(esp.AbsoluteEntityCell, out entities)) { entitiesByAbsoluteCell[esp.AbsoluteEntityCell] = entities = new List <Entity>(); } entities.AddRange(SpawnEntities(esp)); } return(Optional <IDictionary <AbsoluteEntityCell, List <Entity> > > .Of(entitiesByAbsoluteCell)); }
public List <Entity> LoadUnspawnedEntities(Int3 batchId) { lock (parsedBatches) { if (parsedBatches.Contains(batchId)) { return(new List <Entity>()); } parsedBatches.Add(batchId); } DeterministicBatchGenerator deterministicBatchGenerator = new DeterministicBatchGenerator(batchId); List <Entity> entities = new List <Entity>(); List <EntitySpawnPoint> spawnPoints = batchCellsParser.ParseBatchData(batchId); foreach (EntitySpawnPoint esp in spawnPoints) { if (esp.Density > 0) { List <UwePrefab> prefabs = prefabFactory.GetPossiblePrefabs(esp.BiomeType); if (prefabs.Count > 0) { entities.AddRange(SpawnEntitiesUsingRandomDistribution(esp, prefabs, deterministicBatchGenerator)); } else if (esp.ClassId != null) { entities.AddRange(SpawnEntitiesStaticly(esp, deterministicBatchGenerator)); } } } if (entities.Count == 0) { lock (emptyBatches) { emptyBatches.Add(batchId); } } else { Log.Info("Spawning " + entities.Count + " entities from " + spawnPoints.Count + " spawn points in batch " + batchId); } return(entities); }
public List <Entity> LoadUnspawnedEntities(Int3 batchId) { lock (parsedBatches) { if (parsedBatches.Contains(batchId)) { return(new List <Entity>()); } parsedBatches.Add(batchId); } Random random = new Random(batchId.GetHashCode()); List <Entity> entities = new List <Entity>(); List <EntitySpawnPoint> spawnPoints = batchCellsParser.ParseBatchData(batchId); foreach (EntitySpawnPoint esp in spawnPoints) { if (esp.Density > 0) { DstData dstData; if (lootDistributionData.GetBiomeLoot(esp.BiomeType, out dstData)) { entities.AddRange(SpawnEntitiesUsingRandomDistribution(esp, dstData, random)); } else if (esp.ClassId != null) { entities.AddRange(SpawnEntitiesStaticly(esp)); } } } if (entities.Count == 0) { lock (emptyBatches) { emptyBatches.Add(batchId); } } else { Log.Info("Spawning " + entities.Count + " entities from " + spawnPoints.Count + " spawn points in batch " + batchId); } return(entities); }
public List <Entity> LoadUnspawnedEntities(Int3 batchId) { lock (parsedBatches) { if (parsedBatches.Contains(batchId)) { return(new List <Entity>()); } parsedBatches.Add(batchId); } DeterministicBatchGenerator deterministicBatchGenerator = new DeterministicBatchGenerator(batchId); List <Entity> entities = new List <Entity>(); List <EntitySpawnPoint> spawnPoints = batchCellsParser.ParseBatchData(batchId); entities = SpawnEntities(spawnPoints, deterministicBatchGenerator); if (entities.Count == 0) { lock (emptyBatches) { emptyBatches.Add(batchId); } } else { Log.Info("Spawning " + entities.Count + " entities from " + spawnPoints.Count + " spawn points in batch " + batchId); } for (int x = 0; x < entities.Count; x++) // Throws on duplicate Entities already but nice to know which ones { for (int y = 0; y < entities.Count; y++) { if (entities[x] == entities[y] && x != y) { Log.Error("Duplicate Entity detected! " + entities[x]); } } } return(entities); }