private void Spawn(Vector3 position) { float balance = wallet.GetResourceCount(ResourceType.Money); if (balance >= toSpawn.cost) { wallet.AddResources(ResourceType.Money, -toSpawn.cost); var created = Instantiate(toSpawn); created.transform.position = tileManager.CastWorldCoordsToTile(position); created.GetComponent <Building>().destinationStorage = wallet; created.GetComponent <Building>().inputStorage = tileManager.GetResourceTileAtWorldCoords(position); } }