public IEnumerator <Coroutine> LoadNatural(string path) { ClearNaturals(); using (BinaryReader reader = new BinaryReader(File.OpenRead(Path.Combine(path, "natural.dat")))) { int header = reader.ReadInt32(); if (header <= 0) { int counter = reader.ReadInt32(); for (int i = 0; i < counter; i++) { TriCoordinates coord = TriCoordinates.Load(reader); Natural loaded = Natural.Load(reader); if (loaded) { loaded.ID = i; loaded.Location = grid.GetCell(coord); loaded.transform.SetParent(NaturalGroup); AddNatural(loaded); loaded.validateRotation(); } // if (i % Strings.refreshLimit == 0) yield return null; } } else { Debug.LogWarning("Unknown naturals format " + header); } } yield return(null); }
public void Load(string path) { ClearEntities(); using (BinaryReader reader = new BinaryReader(File.OpenRead(Path.Combine(path, "natural.dat")))) { int header = reader.ReadInt32(); if (header <= 0) { int counter = reader.ReadInt32(); for (int i = 0; i < counter; i++) { TriCoordinates coord = TriCoordinates.Load(reader); Natural loaded = Natural.Load(reader); if (loaded) { loaded.ID = i; loaded.Location = grid.GetCell(coord); loaded.transform.SetParent(NaturalGroup); AddNatural(loaded); loaded.validateRotation(); } } } else { Debug.LogWarning("Unknown naturals format " + header); } } using (BinaryReader reader = new BinaryReader(File.OpenRead(Path.Combine(path, "building.dat")))) { int header = reader.ReadInt32(); if (header <= 0) { int counter = reader.ReadInt32(); for (int i = 0; i < counter; i++) { TriCoordinates coord = TriCoordinates.Load(reader); Building loaded = Building.Load(reader); if (loaded) { loaded.ID = i; loaded.Location = grid.GetCell(coord); loaded.EntranceDirection = loaded.EntranceDirection; loaded.Location.Statics = loaded; loaded.transform.SetParent(BuildingGroup); AddBuilding(loaded); } } } else { Debug.LogWarning("Unknown building format " + header); } } using (BinaryReader reader = new BinaryReader(File.OpenRead(Path.Combine(path, "unit.dat")))) { int header = reader.ReadInt32(); if (header <= 0) { int counter = reader.ReadInt32(); for (int i = 0; i < counter; i++) { TriCoordinates coord = TriCoordinates.Load(reader); Unit loaded = Unit.Load(reader); if (loaded) { loaded.ID = i; loaded.Location = grid.GetCell(coord); if (grid.GetCell(coord).Statics) { loaded.GetIn((Building)grid.GetCell(coord).Statics); } loaded.transform.SetParent(UnitGroup); AddUnit(loaded); } } } else { Debug.LogWarning("Unknown unit format " + header); } } }