1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2020, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 
23 #include "object/auto/auto.h"
24 
25 class CObject;
26 
27 enum AutoFactoryPhase
28 {
29     AFP_WAIT        = 1,    // expected metal
30     AFP_CLOSE_S     = 2,    // closes doors (shift)
31     AFP_CLOSE_T     = 3,    // closes doors (turn)
32     AFP_BUILD       = 4,    // building the vehicle
33     AFP_OPEN_T      = 5,    // opens the doors (turn)
34     AFP_OPEN_S      = 6,    // opens the doors (shift)
35     AFP_ADVANCE     = 7,    // advance at the door
36 };
37 
38 
39 
40 class CAutoFactory : public CAuto
41 {
42 public:
43     CAutoFactory(COldObject* object);
44     ~CAutoFactory();
45 
46     void        DeleteObject(bool all=false) override;
47 
48     void        Init() override;
49     bool        EventProcess(const Event &event) override;
50 
51     Error       StartAction(int param) override;
52     void        SetProgram(const std::string& program);
53 
54     bool        CreateInterface(bool bSelect) override;
55 
56     bool        Write(CLevelParserLine* line) override;
57     bool        Read(CLevelParserLine* line) override;
58 
59 protected:
60     void        UpdateInterface();
61     void        UpdateButton(Ui::CWindow *pw, EventType event, bool bBusy);
62 
63     CObject*    SearchCargo();
64     bool        NearestVehicle();
65     bool        CreateVehicle();
66     CObject*    SearchVehicle();
67 
68     void        SoundManip(float time, float amplitude, float frequency);
69 
70 protected:
71     AutoFactoryPhase    m_phase = AFP_WAIT;
72     float               m_progress = 0.0f;
73     float               m_speed = 0.0f;
74     float               m_lastParticle = 0.0f;
75     Math::Vector        m_cargoPos;
76     int                 m_channelSound = 0;
77 
78     std::string         m_program;
79 };
80