public void Build(GameObject buildingPrefab) { if (navmesh == null) { navmesh = FindObjectOfType <NavmeshManager>(); } if (game == null) { game = FindObjectOfType <GameManager>(); } if (buildingPrefab.GetComponent <BuildingInfo>() == null) { Debug.LogError("You are trying to place a building without a buildinginfo script I will save you just this once and put one on for you:)"); buildingPrefab.AddComponent <BuildingInfo>(); buildingPrefab.GetComponent <BuildingInfo>().spawnHeight = 0.8f; } building = (GameObject)Instantiate(buildingPrefab, new Vector3(this.transform.position.x, buildingPrefab.GetComponent <BuildingInfo>().spawnHeight, this.transform.position.z), buildingPrefab.transform.rotation, navmesh.surface.gameObject.transform); isBuiltOn = true; navmesh.UpdateMesh(); if (building.tag == "Resource") { ResourceNode node = new ResourceNode(nodeCoords, building.GetComponent <ResourceSpawnInfo>().product, building); game.AddResourceNode(node); if (OnResourceNodePlaceListeners != null) { OnResourceNodePlaceListeners(node); } } if (building.tag == "Extractor") { game.AddExtractor(building.GetComponent <Extractor>()); building.GetComponent <Extractor>().extractorCoords = nodeCoords; } if (building.tag == "Storage") { game.AddStorage(new StorageNode(nodeCoords, building)); } }