i6engine  1.0
LifetimeComponent.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_API_LIFETIMECOMPONENT_H__
26 #define __I6ENGINE_API_LIFETIMECOMPONENT_H__
27 
29 
30 namespace i6e {
31 namespace api {
32 
42  public:
47  LifetimeComponent(const int64_t id, const attributeMap & params);
48 
50 
54  void dead();
55 
59  void instantKill();
60 
64  attributeMap synchronize() const override;
65 
66  std::string getTemplateName() const override {
67  return "Lifetime";
68  }
69 
70  std::vector<componentOptions> getComponentOptions() override;
71 
72  private:
73  uint64_t _startTime;
74 
78  uint64_t _lifetime;
79 
80  void Init() override;
81 
82  void Finalize() override;
83 
87  void Tick() override;
88 
89  LifetimeComponent(const LifetimeComponent &) = delete;
90  const LifetimeComponent & operator=(const LifetimeComponent &) = delete;
91  };
92 
93 } /* namespace api */
94 } /* namespace i6e */
95 
96 #endif /* __I6ENGINE_API_LIFETIMECOMPONENT_H__ */
97 
destroys the owning game object after given lifetime For creating a LifetimeComponent, these keys are possible: Name Required Type Description Public lifetime yes uint64_t time until this GameObject will be destroyed yes
#define ISIXE_MODULES_API
std::map< std::string, std::string > attributeMap
Definition: attributeMap.h:42
std::string getTemplateName() const override
returns the name this template was registered with
Component Base Class. All Components must derive from Component.
Definition: Component.h:97