GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
BehaviorsContainer.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #pragma once
7 
8 #include <map>
9 #include <memory>
10 #include <vector>
11 
12 #include "GDCore/Project/Behavior.h"
13 #include "GDCore/Project/EffectsContainer.h"
14 #include "GDCore/Project/ObjectConfiguration.h"
15 #include "GDCore/Project/VariablesContainer.h"
16 #include "GDCore/String.h"
17 #include "GDCore/Tools/MakeUnique.h"
18 #include "GDCore/Vector2.h"
19 
20 namespace gd {
21 class PropertyDescriptor;
22 class Project;
23 class Layout;
24 class ArbitraryResourceWorker;
25 class InitialInstance;
26 class SerializerElement;
27 class EffectsContainer;
28 } // namespace gd
29 
30 namespace gd {
31 
37 class GD_CORE_API BehaviorsContainer {
38 public:
42  BehaviorsContainer(bool isOverriding = false);
43 
47  BehaviorsContainer(const gd::BehaviorsContainer &behaviorsContainer) {
48  Init(behaviorsContainer);
49  };
50 
55  operator=(const gd::BehaviorsContainer &behaviorsContainer) {
56  if ((this) != &behaviorsContainer)
57  Init(behaviorsContainer);
58  return *this;
59  }
60 
64  virtual ~BehaviorsContainer();
65 
70 
75  std::vector<gd::String> GetAllBehaviorNames() const;
76 
80  Behavior &GetBehavior(const gd::String &name);
81 
85  const Behavior &GetBehavior(const gd::String &name) const;
86 
90  bool HasBehaviorNamed(const gd::String &name) const;
91 
95  void RemoveBehavior(const gd::String &name);
96 
101  bool RenameBehavior(const gd::String &name, const gd::String &newName);
102 
112  gd::Behavior *AddNewBehavior(const gd::Project &project,
113  const gd::String &type, const gd::String &name);
114 
119  const std::map<gd::String, std::unique_ptr<gd::Behavior>> &
121  return behaviors;
122  };
124 
129 
133  void SerializeTo(SerializerElement &element) const;
134 
139  void UnserializeFrom(gd::Project &project, const SerializerElement &element);
140 
141 protected:
142  bool isOverriding = false;
143  std::map<gd::String, std::unique_ptr<gd::Behavior>>
147 
155  void Init(const gd::BehaviorsContainer &behaviorsContainer);
156 };
157 
158 } // namespace gd
Base class used to represents a behavior that can be applied to an object. It stores the content (i....
Definition: Behavior.h:23
Represent an behaviors container of a platform.
Definition: BehaviorsContainer.h:37
BehaviorsContainer & operator=(const gd::BehaviorsContainer &behaviorsContainer)
Definition: BehaviorsContainer.h:55
BehaviorsContainer(const gd::BehaviorsContainer &behaviorsContainer)
Definition: BehaviorsContainer.h:47
const std::map< gd::String, std::unique_ptr< gd::Behavior > > & GetAllBehaviorContents() const
Get a read-only access to the map containing the behaviors with their properties.
Definition: BehaviorsContainer.h:120
std::map< gd::String, std::unique_ptr< gd::Behavior > > behaviors
Definition: BehaviorsContainer.h:144
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24