private GameObject CreateValve(int id, int typeId, string line)
    {
        int startNodeID = FileReaderHelper.GetNextIntNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        int endNodeID = FileReaderHelper.GetNextIntNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float diameter = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float flow = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float flowVelocity = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        int statusID = (int)FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        int valveTypeID = (int)FileReaderHelper.GetNextNumber(line);

        Debug.Log("Read valveTypeID is : " + valveTypeID);

        var startNodePos = MainSimulationManager.ComponentsHelper.GetComponentPosition(startNodeID);
        var endNodePos   = MainSimulationManager.ComponentsHelper.GetComponentPosition(endNodeID);

        GameStateManager.Instance.SetInactiveState();
        GameStateManager.Instance.SetPathCreationState();

        var obj         = LineGenerator.Instance.CreateAndReturnLineComponent(startNodePos, endNodePos, typeId);
        var valveScript = new Valve(id, typeId, startNodeID, endNodeID, diameter, flow, flowVelocity, statusID, valveTypeID);

        obj.GetComponent <Valve>().Init(valveScript);

        GameStateManager.Instance.SetInactiveState();
        GameStateManager.Instance.SetDragComponentsState();

        return(obj);
    }
    private GameObject CreateTank(int id, int typeId, string line)
    {
        Vector3 pos = FileReaderHelper.GetPosition(line);

        float volume = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float elevation = FileReaderHelper.GetNextNumber(line);

        var obj        = Instantiate(tank, pos, Quaternion.identity);
        var tankScript = new Tank(id, typeId, volume, elevation);

        obj.GetComponent <Tank>().Init(tankScript);

        return(obj);
    }
    private GameObject CreateJunction(int id, int typeId, string line)
    {
        Vector3 pos = FileReaderHelper.GetPosition(line);

        float baseDemand = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float elevation = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float pressure = FileReaderHelper.GetNextNumber(line);

        var obj            = Instantiate(junction, pos, Quaternion.identity);
        var junctionScript = new Junction(id, typeId, baseDemand, elevation, pressure);

        obj.GetComponent <Junction>().Init(junctionScript);

        return(obj);
    }
    private GameObject CreatePump(int id, int typeId, string line)
    {
        int startNodeID = FileReaderHelper.GetNextIntNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        int endNodeID = FileReaderHelper.GetNextIntNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float flow = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        float flowVelocity = FileReaderHelper.GetNextNumber(line);

        line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

        int curveTypeID = (int)FileReaderHelper.GetNextNumber(line);

        var startNodePos = MainSimulationManager.ComponentsHelper.GetComponentPosition(startNodeID);
        var endNodePos   = MainSimulationManager.ComponentsHelper.GetComponentPosition(endNodeID);

        GameStateManager.Instance.SetInactiveState();
        GameStateManager.Instance.SetPathCreationState();

        var obj        = LineGenerator.Instance.CreateAndReturnLineComponent(startNodePos, endNodePos, typeId);
        var pumpScript = new Pump(id, typeId, startNodeID, endNodeID, flow, flowVelocity, curveTypeID);

        obj.GetComponent <Pump>().Init(pumpScript);

        GameStateManager.Instance.SetInactiveState();
        GameStateManager.Instance.SetDragComponentsState();

        return(obj);
    }
    void ReadSaveFile(string line)
    {
        if (line.StartsWith("#"))
        {
            return;
        }

        if (line.StartsWith("el"))
        {
            //remove "el "
            line = line.Remove(0, 3);

            //Get ID
            int ID = (int)FileReaderHelper.GetNextNumber(line);
            line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

            //Get typeID
            int typeID = Int32.Parse(line.Substring(0, 1));
            line = line.Remove(0, 3);

            componentsManager.AddNodeComponent(ComponentsFactory.Instance.CreateComponentFromFile(ID, typeID, line), ID);
        }

        else if (line.StartsWith("ln"))
        {
            //remove "ln "
            line = line.Remove(0, 3);

            //Get ID
            int ID = (int)FileReaderHelper.GetNextNumber(line);
            line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

            //Get typeID
            int typeID = Int32.Parse(line.Substring(0, 1));
            line = line.Remove(0, 3);

            int startNodeID = -1;
            int endNodeID   = -1;

            var lineObj = ComponentsFactory.Instance.CreateComponentFromFile(ID, typeID, line);
            (startNodeID, endNodeID) = MainSimulationManager.ComponentsHelper.GetNodeIDsFromLineObject(lineObj, typeID);

            componentsManager.AddLineComponent(lineObj, typeID, startNodeID, endNodeID);
        }

        else if (line.StartsWith("yr"))
        {
            line = line.Remove(0, 3);

            int ID = (int)FileReaderHelper.GetNextNumber(line);
            line = line.Remove(0, FileReaderHelper.FindNextNumberIndex(line));

            var year = Int32.Parse(line.Substring(0, 4));
            line = line.Remove(0, 6);

            Model model = new Model(year);

            while (line.Length > 0)
            {
                var endOfNum   = FileReaderHelper.FindEndOfNumber(line);
                var removeSize = line.Length > (endOfNum + 2) ? (endOfNum + 2) : line.Length;
                int index      = Int32.Parse(line.Substring(0, endOfNum));
                model.Add(index);

                line = line.Remove(0, removeSize);
            }

            modelsManager.AddModel(model);
        }
    }