public override List <EntitySpawnPoint> From(AbsoluteEntityCell absoluteEntityCell, Transform transform, GameObject gameObject) { List <EntitySpawnPoint> spawnPoints = new List <EntitySpawnPoint>(); EntitySlotsPlaceholder entitySlotsPlaceholder = gameObject.GetComponent <EntitySlotsPlaceholder>(); if (!ReferenceEquals(entitySlotsPlaceholder, null)) { foreach (EntitySlotData entitySlotData in entitySlotsPlaceholder.slotsData) { List <EntitySlot.Type> slotTypes = SlotsHelper.GetEntitySlotTypes(entitySlotData); List <string> stringSlotTypes = slotTypes.Select(s => s.ToString()).ToList(); spawnPoints.Add( new EntitySpawnPoint(absoluteEntityCell, entitySlotData.localPosition, entitySlotData.localRotation, stringSlotTypes, entitySlotData.density, entitySlotData.biomeType.ToString()) ); } } else { spawnPoints.Add( new EntitySpawnPoint(absoluteEntityCell, transform.Position, transform.Rotation, transform.Scale, gameObject.ClassId) ); } return(spawnPoints); }
private void ParseGameObjectsFromStream(Stream stream, Int3 batchId, Int3 cellId, int level, List <EntitySpawnPoint> spawnPoints) { ProtobufSerializer.LoopHeader gameObjectCount = serializer.Deserialize <ProtobufSerializer.LoopHeader>(stream); for (int goCounter = 0; goCounter < gameObjectCount.Count; goCounter++) { GameObject gameObject = DeserializeGameObject(stream); if (gameObject.TotalComponents > 0) { AbsoluteEntityCell absoluteEntityCell = new AbsoluteEntityCell(batchId, cellId, level); Transform transform = gameObject.GetComponent <Transform>(); EntitySlotsPlaceholder entitySlotsPlaceholder = gameObject.GetComponent <EntitySlotsPlaceholder>(); EntitySlot entitySlot = gameObject.GetComponent <EntitySlot>(); if (!ReferenceEquals(entitySlotsPlaceholder, null)) { spawnPoints.AddRange(EntitySpawnPoint.From(absoluteEntityCell, entitySlotsPlaceholder)); } else if (!ReferenceEquals(entitySlot, null)) { spawnPoints.Add(EntitySpawnPoint.From(absoluteEntityCell, transform.Position, transform.Rotation, transform.Scale, gameObject.ClassId, entitySlot)); } else { spawnPoints.Add(EntitySpawnPoint.From(absoluteEntityCell, transform.Position, transform.Rotation, transform.Scale, gameObject.ClassId)); } } } }
public static List <EntitySpawnPoint> From(AbsoluteEntityCell absoluteEntityCell, EntitySlotsPlaceholder placeholder) { List <EntitySpawnPoint> esp = new List <EntitySpawnPoint>(); foreach (EntitySlotData entitySlot in placeholder.slotsData) { esp.Add(new EntitySpawnPoint { AbsoluteEntityCell = absoluteEntityCell, BiomeType = entitySlot.biomeType, Density = entitySlot.density, Position = absoluteEntityCell.Center + entitySlot.localPosition, Rotation = entitySlot.localRotation, AllowedTypes = SlotsHelper.GetEntitySlotTypes(entitySlot), }); } return(esp); }