Entity2D_SimpleView.cpp
Go to the documentation of this file.
2 
3 namespace comp
4 {
5 
7  iv::Transform( inst ),
8  cm( inst, this, "Entity2D_SimpleView_Item" ),
9  img( inst )
10 {
11  this->cm.inherits( this->iv::Transform::cm );
12  this->cm.owns( this->img.cm );
13 
14  this->setChild( &this->img );
15  this->img.filename( "/CoreModels/Entity2D/SimpleView.png" );
16  this->img.translucent( true );
17 }
18 
20  iv::Slot( inst ),
21  iv::FrameUpdateClient( inst ),
22  Entity2D_Listener( inst, world ),
23  cm( inst, this, "Entity2D_SimpleView" ),
24  heap( inst, &this->cm )
25 {
27 
29 }
30 
32 {
33  for( auto & [ entity, item ] : this->entities )
34  {
35  iv::float2 pos = entity->position.Get();
36  item->position( iv::float3( pos.x, pos.y, 0.0f ) );
37  }
38 }
39 
41 {
42  if( this->entities.count( entity ) )
43  {
44  this->cm.warning( SRC_INFO, "Entity already registered." );
45  return;
46  }
47 
48  auto item = this->heap.createClient< Entity2D_SimpleView_Item >();
49  this->pushChild( item );
50  this->entities[ entity ] = item;
51 }
52 
54 {
55  auto item = this->entities[ entity ];
56  this->removeChild( item );
57  this->heap.destroy( item );
58  this->entities.erase( entity );
59 }
60 
61 }