Colobot
exchange_post.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, 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 
21 #pragma once
22 
23 #include "object/subclass/base_building.h"
24 
25 #include "object/auto/auto.h"
26 
27 #include <string>
28 #include <vector>
29 
30 #include <boost/optional.hpp>
31 
33 {
34  std::string name;
35  float value = 0.0f;
36 };
37 
38 struct ObjectCreateParams;
39 
40 namespace Gfx
41 {
42 class COldModelManager;
43 class CEngine;
44 }
45 
47 {
48 public:
49  CExchangePost(int id);
50 
51  static std::unique_ptr<CExchangePost> Create(
52  const ObjectCreateParams& params,
53  Gfx::COldModelManager* modelManager,
54  Gfx::CEngine* engine);
55 
56  static int GetMaximumInfoListSize();
57 
58  bool SetInfo(const std::string& name, float value);
59  const std::vector<ExchangePostInfo>& GetInfoList();
60  boost::optional<float> GetInfoValue(const std::string& name);
61  bool HasInfo(const std::string& name);
62  bool DeleteInfo(const std::string& name);
63 
64  void SetInfoUpdate(bool update);
65  bool GetInfoUpdate();
66 
67  void Write(CLevelParserLine* line) override;
68  void Read(CLevelParserLine* line) override;
69 
70  void ReadInfo(CLevelParserLine* line);
71 
72 private:
73  std::vector<ExchangePostInfo> m_infoList;
74  bool m_infoUpdate;
75 };
76 
77 // TODO: integrate this with CExchangePost
78 class CAutoInfo : public CAuto
79 {
80 public:
81  CAutoInfo(CExchangePost* object);
82  ~CAutoInfo();
83 
84  void DeleteObject(bool all=false) override;
85 
86  void Init() override;
87  void Start(int param) override;
88  bool EventProcess(const Event &event) override;
89  Error GetError() override;
90 
91  bool CreateInterface(bool select) override;
92 
93  bool Write(CLevelParserLine* line) override;
94  bool Read(CLevelParserLine* line) override;
95 
96 protected:
97  void UpdateInterface(float rTime);
98  void UpdateList();
99  void UpdateListVirus();
100 
101 protected:
102  CExchangePost* m_exchangePost;
103  enum class Phase : unsigned int;
104  Phase m_phase;
105  float m_progress;
106  float m_speed;
107  float m_timeVirus;
108  float m_lastParticle;
109  Math::Vector m_goal;
110  bool m_lastVirus;
111 };
std::string name
name of the information
Definition: exchange_post.h:34
Definition: exchange_post.h:46
Definition: exchange_post.h:32
Manager for static models.
Definition: oldmodelmanager.h:54
Definition: auto.h:53
Definition: parserline.h:37
Base class for all buildings.
Definition: base_building.h:36
Namespace for (new) graphics code.
Definition: app.h:49
The graphics engine.
Definition: engine.h:585
Definition: object_create_params.h:26
Definition: exchange_post.h:78
float value
value of the information
Definition: exchange_post.h:35
3D (3x1) vector
Definition: vector.h:53
Event sent by system, interface or game.
Definition: event.h:735