RType
AScene.cpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2023
3 ** R-type
4 ** File description:
5 ** R-type
6 */
7 
8 #include "AScene.hpp"
9 
10 /**
11  * @brief addComponent, add a component to the scene
12  * @param component
13  */
14 void AScene::addComponent(std::shared_ptr<IComponent> component)
15 {
16  _components.push_back(component);
17 }
18 
19 /**
20  * @brief getComponents, get all the components of the scene
21  * @return std::vector<std::shared_ptr<IComponent>>
22  */
24 {
25  return _components;
26 }
27 
28 /**
29  * @brief display, display the scene
30  * @param window
31  */
32 void AScene::display(sf::RenderWindow &window)
33 {
34  for (auto &component : _components) {
35  component->display(window);
36  }
37 }
38 
39 void AScene::update()
40 {
41 }
42 
43 /**
44  * @brief handleEvent, handle the event
45  * @param event
46  * @param window
47  */
48 void AScene::handleEvent(const sf::Event &event, sf::RenderWindow &window)
49 {
50  for (auto &component : _components) {
51  component->handleEvent(event, window);
52  }
53 }
54 
55 /**
56  * @brief pauseScene, pause the scene
57  */
59 {
60  for (auto &component : _components) {
61  if (component->getType() == MUSIC) {
62  auto music = std::dynamic_pointer_cast<MusicComponent>(component);
63  if (music->getPersistant())
64  continue;
65  music->setPaused(false);
66  }
67  }
68 }
69 
70 /**
71  * @brief resumeScene, resume the scene
72  */
74 {
75  for (auto &component : _components) {
76  if (component->getType() == MUSIC) {
77  auto music = std::dynamic_pointer_cast<MusicComponent>(component);
78  if (music->getPersistant())
79  continue;
80  music->setPaused(true);
81  }
82  }
83 }
84 
85 /**
86  * @brief stopScene, stop the scene
87  */
89 {
90  for (auto &component : _components) {
91  if (component->getType() == MUSIC) {
92  auto music = std::dynamic_pointer_cast<MusicComponent>(component);
93  music->stop();
94  }
95  }
96 }