efficient way to make RTS building instances

I am working on a construction system for my RTS. Each building requires different amounts of cordage, wood, stone etc. My first attempt was to make a class “structure” and then make a child class for each building type which would specify its building requirements and other stats such as hit points.

The problem with this approach is that it requires a long if statement to work. For example, I press the ‘build’ button and the worker finds the closest construction site and takes materials to it. In order for the worker to know what materials to bring and how much, they must access the component unique to that structure. Since every structure type has a different class, I need to create an if statement like in the following pseudo code:

if (closestConstructionSite.name == "Wood Storage")
   woodStorageScript = closestConstructionSite.transform.GetComponent<WoodStorage>(); 
else if(closestConstructionSite.name == "Stone Wall")
  stoneWallScript = closestConstructionSite.transform.GetComponent<StoneWall>(); 
//etc.... for every building type that I have. 

I’m more than happy to do this but I’ve got a sinking feeling that there is a better way. Any ideas?

Why not adding the requirements (materials, hit points etc) directly in the base building class? Since every building has requirements I see no reason to add this in every subclass, I did this way in the last RTS having HitPoints, RequireWood, RequireIron etc as “int” type in the BaseBuilding class. The buildings that don’t require a specific resource would have the property set to 0.

Some pseudo code may illustrate the point.

 public class Structure : MonoBehaviour {
     public string structureName;
     public int structureID; 
     public int structureHP; 
     public int requiredWood;
     public int requiredCordage; 

 public class TreeHouse : Structure {
     void Start (){
         requiredWood = 30;

 public class Builder : MonoBehavour{
     void SomeFunction (){
         woodRemaining = constructionSite.GetComponent(typeof(Structure)).requiredWood;