Pie Noon
An open source project by FPL.
 All Classes Pages
cardboard_player.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef COMPONENTS_CARDBOARD_PLAYER_H_
16 #define COMPONENTS_CARDBOARD_PLAYER_H_
17 
18 #include "common.h"
19 #include "components_generated.h"
20 #include "config_generated.h"
21 #include "corgi/component.h"
22 #include "scene_description.h"
23 
24 namespace fpl {
25 namespace pie_noon {
26 
27 class GameState;
28 
29 const int kMaxHealthAccessories = 3;
30 
32  corgi::EntityRef target_reticle;
33  corgi::EntityRef loaded_pie;
34  corgi::EntityRef health[kMaxHealthAccessories];
35  CharacterId character_id;
36 };
37 
38 class CardboardPlayerComponent : public corgi::Component<CardboardPlayerData> {
39  public:
40  virtual void AddFromRawData(corgi::EntityRef& entity, const void* data);
41  virtual void UpdateAllEntities(corgi::WorldTime delta_time);
42  virtual void InitEntity(corgi::EntityRef& entity);
43 
44  void set_gamestate_ptr(GameState* gamestate_ptr) {
45  gamestate_ptr_ = gamestate_ptr;
46  }
47  void set_config(const Config* config) { config_ = config; }
48 
49  private:
50  void UpdateTargetReticle(corgi::EntityRef entity);
51  void UpdateLoadedPie(corgi::EntityRef entity);
52  void UpdateHealthAccessories(corgi::EntityRef entity);
53  const Config* config_;
54  GameState* gamestate_ptr_;
55 };
56 
57 } // pie_noon
58 } // fpl
59 
60 CORGI_REGISTER_COMPONENT(fpl::pie_noon::CardboardPlayerComponent,
62 
63 #endif // COMPONENTS_CARDBOARD_PLAYER_H_
Definition: cardboard_player.h:31
Definition: game_state.h:56
Definition: cardboard_player.h:38