summary refs log tree commit diff stats
path: root/src/prototype.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-04-21 14:50:52 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-04-21 14:50:52 -0400
commit8142a9c87a13cecc7a3698e877f24d89f128c074 (patch)
treecbee6ae85c5c674dd313c7cfe1420477ee55ca95 /src/prototype.cpp
parent0f70db34d9b47de55b00c558ac3c445f30b7b6a5 (diff)
downloadtherapy-8142a9c87a13cecc7a3698e877f24d89f128c074.tar.gz
therapy-8142a9c87a13cecc7a3698e877f24d89f128c074.tar.bz2
therapy-8142a9c87a13cecc7a3698e877f24d89f128c074.zip
Started working on prototype objects proto-objs
Diffstat (limited to 'src/prototype.cpp')
-rw-r--r--src/prototype.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/prototype.cpp b/src/prototype.cpp new file mode 100644 index 0000000..a4a0e80 --- /dev/null +++ b/src/prototype.cpp
@@ -0,0 +1,55 @@
1#include "prototype.h"
2#include "game.h"
3#include "animation.h"
4#include "components/animatable.h"
5#include "components/transformable.h"
6#include "components/ponderable.h"
7#include "systems/pondering.h"
8#include "systems/playing.h"
9
10id_type Prototype::instantiate(
11 Game& game,
12 const Map::Object& object) const
13{
14 id_type entity = game.getEntityManager().emplaceEntity();
15
16 AnimationSet entityGraphics(spritePath_.c_str(), w_, h_, 1);
17 entityGraphics.emplaceAnimation("default", 0, 1, 1);
18
19 game.getEntityManager().emplaceComponent<AnimatableComponent>(
20 entity,
21 std::move(entityGraphics),
22 "default");
23
24 game.getEntityManager().emplaceComponent<TransformableComponent>(
25 entity,
26 object.getX(),
27 object.getY(),
28 w_,
29 h_);
30
31 game.getSystemManager().getSystem<PonderingSystem>().initializeBody(
32 entity,
33 PonderableComponent::BodyType::vacuumed,
34 PonderableComponent::ColliderType::event);
35
36 auto& ponderable = game.getEntityManager().
37 getComponent<PonderableComponent>(entity);
38
39 switch (action_)
40 {
41 case Action::save:
42 {
43 ponderable.setEventCallback(PonderableComponent::ColliderType::player,
44 [] (Game& game) {
45 auto& playing = game.getSystemManager().getSystem<PlayingSystem>();
46
47 playing.save();
48 });
49
50 break;
51 }
52 }
53
54 return entity;
55}