public SerializablePopulation(Population population) { // Set the first few fields count = population.Count; prePopulationCount = population.PrePopulationCount; foodDominance = population.FoodDominance; origin = population.Origin; // Create a list with all the entries in the needs dictionary IEnumerable <SerializableNeed> entries = population.Needs.Values .Select(need => new SerializableNeed(need)); needs = new List <SerializableNeed>(entries); // Set the remaining fields growthCalculator = new SerializableGrowthCalculator(population.GrowthCalculator); isPaused = population.IsPaused; hasAccessibilityChanged = population.HasAccessibilityChanged; }
private void UpdateItems() { // Destroy any existing items on update foreach (VerboseInspectorItem item in items) { Destroy(item.gameObject); } // Clear out the list items.Clear(); // Try to get the game manager GameManager gameManager = GameManager.Instance; // Check if there is a game manager and a connected inspector if (gameManager && inspector) { // Get the tile data at the inspector's position and display all the data as a JSON TileData tileData = gameManager.m_tileDataController.GetTileData(inspector.selectedPosition); CreateInspectorItem(tileData); if (tileData.Food) { // Inspect the food source component FoodSource food = tileData.Food.GetComponent <FoodSource>(); CreateInspectorItem(food); CreateInspectorItem(food.Species); } if (tileData.Animal) { // Get some references to the objects we will inspect Animal animal = tileData.Animal.GetComponent <Animal>(); SerializablePopulation population = new SerializablePopulation(animal.PopulationInfo); SerializableGrowthCalculator growthCalculator = new SerializableGrowthCalculator(animal.PopulationInfo.GrowthCalculator); CreateInspectorItem(animal.PopulationInfo.Species); CreateInspectorItem(population, "Population"); } } }