Pie Noon
An open source project by FPL.
 All Classes Pages
player_character.h
1 // Copyright 2014 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_PLAYER_CHARACTER_H_
16 #define COMPONENTS_PLAYER_CHARACTER_H_
17 
18 #include "character.h"
19 #include "common.h"
20 #include "components_generated.h"
21 #include "config_generated.h"
22 #include "corgi/component.h"
23 #include "mathfu/constants.h"
24 #include "scene_description.h"
25 
26 namespace fpl {
27 namespace pie_noon {
28 
29 class GameState;
30 
31 const int kMaxAccessories = 15;
32 
33 // Data for accessory components.
35  corgi::EntityRef base_circle;
36  corgi::EntityRef character;
37  corgi::EntityRef accessories[kMaxAccessories];
38  CharacterId character_id;
39 };
40 
41 // Child Objects are basically anything that hangs off of a scene-object as a
42 // child. They inherit transformations from their parent.
43 class PlayerCharacterComponent : public corgi::Component<PlayerCharacterData> {
44  public:
45  virtual void AddFromRawData(corgi::EntityRef& entity, const void* data);
46  virtual void UpdateAllEntities(corgi::WorldTime delta_time);
47  virtual void InitEntity(corgi::EntityRef& entity);
48  void set_gamestate_ptr(GameState* gamestate_ptr) {
49  gamestate_ptr_ = gamestate_ptr;
50  }
51 
52  void set_config(const Config* config) { config_ = config; }
53 
54  private:
55  void UpdateCharacterFacing(corgi::EntityRef entity);
56  void UpdateCharacterTint(corgi::EntityRef entity);
57  void UpdateUiArrow(corgi::EntityRef entity);
58  void UpdateVisibility(corgi::EntityRef entity);
59  int PopulatePieAccessories(corgi::EntityRef entity, int num_accessories);
60  int PopulateHealthAccessories(corgi::EntityRef entity, int num_accessories);
61  Controller::ControllerType ControllerType(
62  const corgi::EntityRef& entity) const;
63  bool DrawBaseCircle(const corgi::EntityRef& entity) const;
64 
65  const Config* config_;
66  GameState* gamestate_ptr_;
67 };
68 
69 } // pie_noon
70 } // fpl
71 
72 CORGI_REGISTER_COMPONENT(fpl::pie_noon::PlayerCharacterComponent,
74 
75 #endif // COMPONENTS_PLAYER_CHARACTER_H_
Definition: player_character.h:34
Definition: game_state.h:56
Definition: player_character.h:43