Pie Noon
An open source project by FPL.
 All Classes Pages
shakeable_prop.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_SHAKEABLE_PROP_H_
16 #define COMPONENTS_SHAKEABLE_PROP_H_
17 
18 #include <memory>
19 #include <vector>
20 #include "common.h"
21 #include "components_generated.h"
22 #include "config_generated.h"
23 #include "corgi/component.h"
24 #include "motive/init.h"
25 #include "motive/io/flatbuffers.h"
26 #include "motive/util.h"
27 
28 namespace fpl {
29 namespace pie_noon {
30 
33  float shake_scale;
34  fplbase::Axis axis;
35  motive::Motivator1f motivator;
36 };
37 
38 class ShakeablePropComponent : public corgi::Component<ShakeablePropData> {
39  public:
40  virtual void UpdateAllEntities(corgi::WorldTime delta_time);
41  virtual void AddFromRawData(corgi::EntityRef& entity, const void* data);
42  virtual void InitEntity(corgi::EntityRef& entity);
43  virtual void CleanupEntity(corgi::EntityRef& entity);
44 
45  void set_config(const Config* config) { config_ = config; }
46  void set_engine(motive::MotiveEngine* engine) { engine_ = engine; }
47  void LoadMotivatorSpecs();
48  void ShakeProps(float damage_percent, const mathfu::vec3& damage_position);
49 
50  private:
51  const Config* config_;
52  motive::MotiveEngine* engine_;
53  motive::OvershootInit motivator_inits[MotivatorSpecification_Count];
54 };
55 
56 } // pie_noon
57 } // fpl
58 
59 CORGI_REGISTER_COMPONENT(fpl::pie_noon::ShakeablePropComponent,
61 
62 #endif // COMPONENTS_SHAKEABLE_PROP_H_
Definition: shakeable_prop.h:31
Definition: shakeable_prop.h:38