Leviathan  0.8.0.0
Leviathan game engine
Components.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2019 Henri Hyyryläinen
3 #pragma once
4 
6 #include "Define.h"
7 // ------------------------------------ //
8 #include "Common/SFMLPackets.h"
9 #include "Common/Types.h"
10 #include "Physics/PhysicsBody.h"
11 #include "Physics/PhysicsShape.h"
12 
13 #include "Component.h"
14 #include "ComponentState.h"
15 
16 #include "bsfCore/BsCorePrerequisites.h"
17 
18 #include <functional>
19 
20 namespace Leviathan {
21 
22 class PhysicalWorld;
23 
24 namespace Test {
25 class TestComponentCreation;
26 }
27 
28 class PositionState;
29 
34 class Position : public ComponentWithStates<PositionState>, public PhysicsPositionProvider {
35 public:
36  struct Data {
37 
38  Data(const Float3& position, const Float4& orientation) :
39  _Position(position), _Orientation(orientation)
40  {}
41 
44  };
45 
46 public:
48  inline Position(const Data& data) : ComponentWithStates(TYPE), Members(data) {}
49 
51  const Float3*& position, const Float4*& orientation) const override
52  {
53  position = &Members._Position;
54  orientation = &Members._Orientation;
55  }
56 
57  void SetPositionDataFromPhysics(const Float3& position, const Float4& orientation) override
58  {
59  Members._Position = position;
60  Members._Orientation = orientation;
61  Marked = true;
62  }
63 
66  DLLEXPORT void ApplyState(const PositionState& state);
67 
69 
71 
72  static constexpr auto TYPE = COMPONENT_TYPE::Position;
73  using StateT = PositionState;
74 };
75 
79 class RenderNode : public Component {
80 public:
82 
84  DLLEXPORT RenderNode(const Test::TestComponentCreation& test);
85 
87  DLLEXPORT void Release(bs::Scene* worldsscene);
88 
90 
91  bs::HSceneObject Node;
92 
94  bool Hidden = false;
95 
97  Float3 Scale = Float3(1, 1, 1);
98 
99  // TODO: implement
101  // ObjectID ParentEntity = NULL_OBJECT;
102 
105 
106  static constexpr auto TYPE = COMPONENT_TYPE::RenderNode;
107 };
108 
115 class Sendable : public Component {
116 public:
122  public:
123  inline ActiveConnection(const std::shared_ptr<Connection>& connection) :
124  CorrespondingConnection(connection)
125  {}
126 
130 
132  inline void AddSentPacket(int tick, const std::shared_ptr<EntityState>& state,
133  std::shared_ptr<SentNetworkThing> packet)
134  {
135  SentPackets.emplace_back(tick, state, packet);
136  }
137 
138  std::shared_ptr<Connection> CorrespondingConnection;
139 
143  std::shared_ptr<EntityState> LastConfirmedData;
144 
147  // LastConfirmedData will be replaced.
149 
151  std::vector<
152  std::tuple<int, std::shared_ptr<EntityState>, std::shared_ptr<SentNetworkThing>>>
154  };
155 
156 public:
157  inline Sendable() : Component(TYPE) {}
158 
160 
162  std::vector<ActiveConnection> UpdateReceivers;
163 
164  static constexpr auto TYPE = COMPONENT_TYPE::Sendable;
165 };
166 
170 class Received : public Component {
171 public:
172  // //! \brief Storage class for ObjectDeltaStateData
173  // //! \todo Possibly add move constructors
174  // class StoredState {
175  // public:
176  // inline StoredState(std::shared_ptr<ComponentState> safedata, int tick, void* data) :
177  // DeltaData(safedata), Tick(tick), DirectData(data)
178  // {}
179 
180  // std::shared_ptr<ComponentState> DeltaData;
181 
182  // //! Tick number, should be retrieved from DeltaData
183  // int Tick;
184 
185  // //! This avoids using dynamic_cast
186  // void* DirectData;
187  // };
188 
189 public:
190  inline Received() :
191  Component(TYPE) //, ClientStateBuffer(BASESENDABLE_STORED_RECEIVED_STATES)
192  {}
193 
194  // DLLEXPORT void GetServerSentStates(StoredState const** first, StoredState const**
195  // second,
196  // int tick, float& progress) const;
197 
199 
200  // //! Client side buffer of past states
201  // boost::circular_buffer<StoredState> ClientStateBuffer;
202 
204  bool LocallyControlled = false;
205 
206  static constexpr auto TYPE = COMPONENT_TYPE::Received;
207 };
208 
209 
211 class BoxGeometry : public Component {
212 public:
213  inline BoxGeometry(const Float3& size, const std::string& material) :
214  Component(TYPE), Sizes(size), Material(material)
215  {}
216 
218 
221 
223  std::string Material;
224 
225  // //! Entity created from a box mesh
226  // Ogre::Item* GraphicalObject = nullptr;
227 
228  static constexpr auto TYPE = COMPONENT_TYPE::BoxGeometry;
229 };
230 
232 class Model : public Component {
233 public:
234  DLLEXPORT Model(bs::Scene* scene, RenderNode& parent, const std::string& meshname,
235  const bs::HMaterial& material);
236 
237  DLLEXPORT void Release();
238 
239  DLLEXPORT void ApplyMeshName();
240 
242 
244  bs::HRenderable GraphicalObject;
245 
247  std::string MeshName;
248 
250  bs::HMaterial Material;
251 
252  static constexpr auto TYPE = COMPONENT_TYPE::Model;
253 };
254 
257  friend class AnimationSystem;
258 
259 public:
260  DLLEXPORT inline SimpleAnimation(const std::string& name) : Name(name) {}
261 
263  Name(std::move(other.Name)), Loop(other.Loop), SpeedFactor(other.SpeedFactor),
264  Paused(other.Paused), _LoadedAnimation(std::move(other._LoadedAnimation))
265  {
266  Loop = other.Loop;
267  SpeedFactor = other.SpeedFactor;
268  Paused = other.Paused;
269  }
270 
272  Name(other.Name), Loop(other.Loop), SpeedFactor(other.SpeedFactor),
274  {}
275 
277  std::string Name;
278  bool NameMarked = true;
279 
281  bool Loop = false;
282 
284  float SpeedFactor = 1;
285 
287  bool Paused = false;
288 
289 protected:
291  bs::HAnimationClip _LoadedAnimation;
292 };
293 
295 class Animated : public Component {
296 public:
298 
299  DLLEXPORT void Release();
300 
302 
304  bs::HAnimation Animation;
305 
309  std::vector<SimpleAnimation> Animations;
310 
311  static constexpr auto TYPE = COMPONENT_TYPE::Animated;
312 };
313 
314 // //! \brief Plane component
315 // //!
316 // //! Creates a static mesh for this
317 // class Plane : public Component {
318 // public:
319 // DLLEXPORT Plane(bs::Scene* scene, Ogre::SceneNode* parent,
320 // const std::string& material, const Ogre::Plane& plane, const Float2& size,
321 // const Ogre::Vector3& uvupvector = Ogre::Vector3::UNIT_Y);
322 
323 // //! \brief Destroys GraphicalObject
324 // DLLEXPORT void Release(bs::Scene* scene);
325 
326 // REFERENCE_HANDLE_UNCOUNTED_TYPE(Plane);
327 
328 // //! The plane that this component creates
329 // Ogre::Item* GraphicalObject = nullptr;
330 
331 // const std::string GeneratedMeshName;
332 
333 // // Changing any of these does nothing
334 // std::string Material;
335 // Ogre::Plane PlaneDefinition;
336 // Float2 Size;
337 // Float3 UpVector;
338 
339 // static constexpr auto TYPE = COMPONENT_TYPE::Plane;
340 // };
341 
342 
346 class Physics : public Component {
347 public:
350  public:
353  ApplyForceInfo(bool addmass,
354  std::function<Float3(ApplyForceInfo* instance, Physics& object)> getforce,
355  std::unique_ptr<std::string> name = nullptr) :
356  OptionalName(move(name)),
357  MultiplyByMass(addmass), Callback(getforce)
358  {}
359 
362  {
363  if(other.OptionalName)
364  OptionalName = std::make_unique<std::string>(*other.OptionalName);
365  }
366 
368  OptionalName(move(other.OptionalName)),
369  MultiplyByMass(std::move(other.MultiplyByMass)), Callback(move(other.Callback))
370  {}
371 
373  {
374 
375  if(other.OptionalName)
376  OptionalName = std::make_unique<std::string>(*other.OptionalName);
377 
379  Callback = other.Callback;
380 
381  return *this;
382  }
383 
385  std::unique_ptr<std::string> OptionalName;
386 
390 
393  std::function<Float3(ApplyForceInfo* instance, Physics& object)> Callback;
394  };
395 
397 
400  };
401 
402  struct Data {
403 
409  };
410 
411 public:
412  inline Physics(const Data& args) :
413  Component(TYPE), ThisEntity(args.id), _Position(args.updatepos)
414  {}
415 
417 
419  DLLEXPORT void Release(PhysicalWorld* world);
420 
428  DLLEXPORT PhysicsBody::pointer CreatePhysicsBody(PhysicalWorld* world,
429  const PhysicsShape::pointer& shape, float mass, int physicsmaterialid = -1);
430 
433  DLLEXPORT bool ChangeShape(PhysicalWorld* world, const PhysicsShape::pointer& shape);
434 
439  DLLEXPORT void JumpTo(Position& target);
440 
442  DLLEXPORT void ApplyPhysicalState(const BasePhysicsData& data);
443 
445  Float3 _GatherApplyForces(const float& mass);
446 
447  DLLEXPORT float GetMass() const;
448 
449  inline PhysicsBody* GetBody() const
450  {
451  return Body.get();
452  }
453 
454  //
455  // Script wrappers
456  //
457 
458  inline PhysicsBody* GetBodyWrapper() const
459  {
460  if(Body)
461  Body->AddRef();
462  return Body.get();
463  }
464 
465  inline bool ChangeShapeWrapper(PhysicalWorld* world, PhysicsShape* shape)
466  {
467  return ChangeShape(world, ReferenceCounted::WrapPtr(shape));
468  }
469 
471  PhysicalWorld* world, PhysicsShape* shape, float mass, int physicsmaterialid)
472  {
473  auto body = CreatePhysicsBody(
474  world, ReferenceCounted::WrapPtr(shape), mass, physicsmaterialid);
475 
476  if(body)
477  body->AddRef();
478  return body.get();
479  }
480 
482 
483 private:
484  PhysicsBody::pointer Body;
485 
486 public:
489 
490  // //! Used to access gravity data
491  // GameWorld* World = nullptr;
492 
495 
496  static constexpr auto TYPE = COMPONENT_TYPE::Physics;
497 };
498 
499 // class ManualObject : public Component {
500 // public:
501 // DLLEXPORT ManualObject(bs::Scene* scene);
502 
503 // DLLEXPORT void Release(bs::Scene* scene);
504 
505 // REFERENCE_HANDLE_UNCOUNTED_TYPE(ManualObject);
506 
507 // Ogre::ManualObject* Object = nullptr;
508 
509 // //! When not empty the ManualObject has been created into an actual mesh
510 // //! that needs to be destroyed on release
511 // //! \note The Object can be directly added to a scene so this may be empty even
512 // //! if the Object is created
513 // std::string CreatedMesh;
514 
515 // static constexpr auto TYPE = COMPONENT_TYPE::ManualObject;
516 // };
517 
518 
519 // class Parent : public Component{
520 // public:
521 
522 // struct Data{
523 
524 // std::vector<ObjectID> EntityIDs;
525 // };
526 
527 // public:
528 // DLLEXPORT Parent();
529 
530 // DLLEXPORT Parent(const Data &data, GameWorld* world, Lock &worldlock);
531 
532 // //! \brief Removes child object without notifying it
533 // DLLEXPORT void RemoveChildNoNotify(Parentable* which);
534 
535 // //! \brief Removes all children notifying them
536 // DLLEXPORT void RemoveChildren();
537 
538 // DLLEXPORT void AddDataToPacket(sf::Packet &packet) const;
539 
540 // //! \note The packet needs to be checked that it is still valid after this call
541 // DLLEXPORT static Data LoadDataFromPacket(sf::Packet &packet);
542 
543 // //! \brief Does everything necessary to attach a child
544 // DLLEXPORT void AddChild(ObjectID childid, Parentable &child);
545 
546 // //! Attached children which can be moved at certain times
547 // //! \todo Make improvements to component lookup performance through this
548 // std::vector<std::tuple<ObjectID, Parentable*>> Children;
549 // };
550 
551 
552 
553 // class Constraintable : public Component{
554 // public:
555 // //! \param world Used to allow created constraints to access world data (including
556 // physics) DLLEXPORT Constraintable(ObjectID id, GameWorld* world);
557 
558 // //! \brief Destroys all constraints attached to this
559 // DLLEXPORT ~Constraintable();
560 
561 // //! Creates a constraint between this and another object
562 // //! \warning DO NOT store the returned value (since that reference isn't counted)
563 // //! \note Before the constraint is actually finished, you need to
564 // //! call ->SetParameters() on the returned ptr
565 // //! and then ->Init() and then let go of the ptr
566 // //! \note If you do not want to allow constraints where child is NULL you have to
567 // //! check if child is NULL before calling this function
568 // template<class ConstraintClass, typename... Args>
569 // std::shared_ptr<ConstraintClass> CreateConstraintWith(Constraintable &other,
570 // Args&&... args)
571 // {
572 // auto tmpconstraint = std::make_shared<ConstraintClass>(World, *this, other,
573 // args...);
574 
575 // if(tmpconstraint)
576 // _NotifyCreate(tmpconstraint, other);
577 
578 // return tmpconstraint;
579 // }
580 
581 // DLLEXPORT void RemoveConstraint(BaseConstraint* removed);
582 
583 // DLLEXPORT void AddConstraint(std::shared_ptr<BaseConstraint> added);
584 
585 // protected:
586 
587 // //! \brief Notifies the other object and the GameWorld of the new constraint
588 // DLLEXPORT void _NotifyCreate(std::shared_ptr<BaseConstraint> newconstraint,
589 // Constraintable &other);
590 
591 // public:
592 
593 
594 // std::vector<std::shared_ptr<BaseConstraint>> PartInConstraints;
595 
596 // GameWorld* World;
597 
598 // //! ID for other component lookup
599 // ObjectID PartOfEntity;
600 // };
601 
602 // class Trail : public Component{
603 // public:
604 
605 // struct ElementProperties{
606 // ElementProperties(const Float4 &initialcolour,
607 // const Float4 &colourchange, const float &initialsize, const float &sizechange) :
608 // InitialColour(initialcolour), ColourChange(colourchange),
609 // InitialSize(initialsize), SizeChange(sizechange)
610 // {
611 
612 // }
613 
614 // ElementProperties(const Float4 &initialcolour,
615 // const float &initialsize) :
616 // InitialColour(initialcolour), ColourChange(0), InitialSize(initialsize),
617 // SizeChange(0)
618 // {
619 
620 // }
621 
622 // ElementProperties() :
623 // InitialColour(1), ColourChange(0), InitialSize(1), SizeChange(0)
624 // {
625 
626 // }
627 
628 // Float4 InitialColour;
629 // Float4 ColourChange;
630 // float InitialSize;
631 // float SizeChange;
632 // };
633 
634 // struct Properties{
635 // public:
636 // Properties(size_t maxelements, float lenght, float maxdistance,
637 // bool castshadows = false) :
638 // TrailLenght(lenght), MaxDistance(maxdistance),
639 // MaxChainElements(maxelements), CastShadows(castshadows), Elements(1)
640 // {
641 // }
642 
643 // float TrailLenght;
644 // float MaxDistance;
645 // size_t MaxChainElements;
646 // bool CastShadows;
647 
648 // std::vector<ElementProperties> Elements;
649 // };
650 
651 
652 // public:
653 
654 // DLLEXPORT Trail(RenderNode* node, const std::string &materialname,
655 // const Properties &variables);
656 
657 // //! \brief Sets properties on the trail object
658 // //! \pre Ogre objects have been created
659 // //! \param force If set to true all settings will be applied
660 // DLLEXPORT bool SetTrailProperties(const Properties &variables, bool force = false);
661 
662 // //! \brief Destroys the TrailEntity
663 // DLLEXPORT void Release(bs::Scene* scene);
664 
665 // //! The trail entity which is attached at the root scene node and follows our RenderNode
666 // //! component around
667 // Ogre::RibbonTrail* TrailEntity = nullptr;
668 
669 // //! For ease of use direct access to ogre node is required
670 // //! Not valid in non-gui mode
671 // RenderNode* _RenderNode = nullptr;
672 
673 // //! The used trail material
674 // std::string Material;
675 
676 // //! Current settings, when updating settings only changed ones are applied
677 // Properties CurrentSettings;
678 // };
679 
680 // //! \todo Add the Markers to the actual world for sending over the network individually
681 // class PositionMarkerOwner : public Component{
682 // public:
683 
684 // struct Data{
685 
686 // std::vector<std::tuple<ObjectID, Float3, Float4>> EntityPositions;
687 // };
688 
689 // public:
690 // DLLEXPORT PositionMarkerOwner();
691 
692 // //! \brief Create with automatically created positions
693 // DLLEXPORT PositionMarkerOwner(const Data &positions, GameWorld* world,
694 // Lock &worldlock);
695 
696 // //! \brief Queues destruction and clears the list of Markers
697 // DLLEXPORT void Release(GameWorld* world, Lock &worldlock);
698 
699 // //! Adds a node
700 // //! \todo Allow not deleting entities on release
701 // DLLEXPORT void Add(ObjectID entity, Position& pos);
702 
703 // DLLEXPORT void AddDataToPacket(sf::Packet &packet) const;
704 
705 // //! \note The packet needs to be checked that it is valid after this call
706 // DLLEXPORT static Data LoadDataFromPacket(sf::Packet &packet);
707 
708 // std::vector<std::tuple<ObjectID, Position*>> Markers;
709 // };
710 
711 
713 class Camera : public Component {
714 public:
717  inline Camera(uint8_t fov = 90, bool soundperceiver = true) :
718  Component(TYPE), FOV(fov), SoundPerceiver(soundperceiver)
719  {}
720 
722 
725 
727  // TODO: orthographic
728  // bool Orthographic;
729 
730  static constexpr auto TYPE = COMPONENT_TYPE::Camera;
731 };
732 
733 } // namespace Leviathan
734 
735 #ifdef LEAK_INTO_GLOBAL
736 using ApplyForceInfo = Leviathan::Physics::ApplyForceInfo;
737 #endif
std::vector< ActiveConnection > UpdateReceivers
Clients we have already sent a state to.
Definition: Components.h:162
bs::HAnimation Animation
Created animation component for this entity.
Definition: Components.h:304
PhysicsBody * GetBody() const
Definition: Components.h:449
DLLEXPORT void CheckReceivedPackets()
Checks has any packet been successfully received and updates last confirmed.
Definition: Components.cpp:251
REFERENCE_HANDLE_UNCOUNTED_TYPE(Physics)
ObjectID ThisEntity
For passing to PhysicsBody::SetOwningEntity.
Definition: Components.h:488
bs::HRenderable GraphicalObject
The entity that has this model's mesh loaded.
Definition: Components.h:244
Entity is received from a server.
Definition: Components.h:170
PositionState StateT
Definition: Components.h:73
int32_t ObjectID
Definition: EntityCommon.h:11
Camera(uint8_t fov=90, bool soundperceiver=true)
Creates at specific position.
Definition: Components.h:717
Float3 Scale
Sets the scale of the node.
Definition: Components.h:97
static constexpr auto TYPE
Definition: Components.h:228
std::function< Float3(ApplyForceInfo *instance, Physics &object)> Callback
Definition: Components.h:393
This acts as a bridge between Leviathan positions and physics engine positions.
Definition: PhysicsBody.h:24
DLLEXPORT RenderNode(bs::Scene *scene)
Definition: Components.cpp:34
std::shared_ptr< Connection > CorrespondingConnection
Definition: Components.h:138
bs::HAnimationClip _LoadedAnimation
Loaded animation.
Definition: Components.h:291
REFERENCE_HANDLE_UNCOUNTED_TYPE(Model)
DLLEXPORT SimpleAnimation(SimpleAnimation &&other)
Definition: Components.h:262
REFERENCE_HANDLE_UNCOUNTED_TYPE(RenderNode)
A physical shape that can be used to create PhysicsBody objects.
Definition: PhysicsShape.h:17
REFERENCE_HANDLE_UNCOUNTED_TYPE(Position)
ApplyForceInfo & operator=(const ApplyForceInfo &other)
Definition: Components.h:372
std::string MeshName
Definition: Components.h:247
REFERENCE_HANDLE_UNCOUNTED_TYPE(Received)
REFERENCE_HANDLE_UNCOUNTED_TYPE(BoxGeometry)
ActiveConnection(const std::shared_ptr< Connection > &connection)
Definition: Components.h:123
DLLEXPORT void ApplyState(const PositionState &state)
Applies the state and marks this as changed. Doesn't check if the state is actually different.
Definition: Components.cpp:26
Alternative base class for Component that creates distinct state objects.
Position(const Data &data)
Creates at specific position.
Definition: Components.h:48
ApplyForceInfo(ApplyForceInfo &&other)
Definition: Components.h:367
Contains an animation for Animated component.
Definition: Components.h:256
std::vector< std::tuple< int, std::shared_ptr< EntityState >, std::shared_ptr< SentNetworkThing > > > SentPackets
Holds packets sent to this connection that haven't failed or been received yet.
Definition: Components.h:153
bool Loop
If true the animation will automatically loop.
Definition: Components.h:281
void AddSentPacket(int tick, const std::shared_ptr< EntityState > &state, std::shared_ptr< SentNetworkThing > packet)
Adds a package to be checked for finalization in CheckReceivedPackages.
Definition: Components.h:132
bs::HMaterial Material
Material set on the object.
Definition: Components.h:250
static constexpr auto TYPE
Definition: Components.h:72
static constexpr auto TYPE
Definition: Components.h:496
bool LocallyControlled
If true this uses local control and will send updates to the server.
Definition: Components.h:204
DLLEXPORT bool ChangeShape(PhysicalWorld *world, const PhysicsShape::pointer &shape)
Updates the shape. This can be the same pointer as before. BUT if the shape is modified this MUST be ...
Definition: Components.cpp:143
bool Paused
If true then the animation will be paused.
Definition: Components.h:287
This is an instance of a collision body.
Definition: PhysicsBody.h:74
unsigned char uint8_t
Definition: core.h:38
bool Hidden
Sets objects attached to the node to be hidden or visible.
Definition: Components.h:94
Holder for information regarding a single force.
Definition: Components.h:349
DLLEXPORT SimpleAnimation(const std::string &name)
Definition: Components.h:260
Float3 Sizes
Size along the axises.
Definition: Components.h:220
std::shared_ptr< EntityState > LastConfirmedData
Definition: Components.h:143
ApplyForceInfo(const ApplyForceInfo &other)
Definition: Components.h:360
Entity has a box for geometry/model, possibly also physics.
Definition: Components.h:211
bool ChangeShapeWrapper(PhysicalWorld *world, PhysicsShape *shape)
Definition: Components.h:465
PhysicsBody * CreatePhysicsBodyWrapper(PhysicalWorld *world, PhysicsShape *shape, float mass, int physicsmaterialid)
Definition: Components.h:470
Entity has position and direction it is looking at.
Definition: Components.h:34
Entity has a scene node.
Definition: Components.h:79
DLLEXPORT void Release()
Definition: Components.cpp:315
DLLEXPORT ~Physics()
Definition: Components.cpp:100
DLLEXPORT SimpleAnimation(const SimpleAnimation &other)
Definition: Components.h:271
static constexpr auto TYPE
Definition: Components.h:311
Float3 _GatherApplyForces(const float &mass)
Adds all applied forces together.
ApplyForceInfo(bool addmass, std::function< Float3(ApplyForceInfo *instance, Physics &object)> getforce, std::unique_ptr< std::string > name=nullptr)
Definition: Components.h:353
BoxGeometry(const Float3 &size, const std::string &material)
Definition: Components.h:213
DLLEXPORT Model(bs::Scene *scene, RenderNode &parent, const std::string &meshname, const bs::HMaterial &material)
Definition: Components.cpp:294
bs::HSceneObject Node
Definition: Components.h:91
unsigned short uint16_t
Definition: core.h:39
static constexpr auto TYPE
Definition: Components.h:164
Physics(const Data &args)
Definition: Components.h:412
DLLEXPORT void Release()
Definition: Components.cpp:359
DLLEXPORT PhysicsBody::pointer CreatePhysicsBody(PhysicalWorld *world, const PhysicsShape::pointer &shape, float mass, int physicsmaterialid=-1)
Use this to create a body for this component once Collision is set.
Definition: Components.cpp:123
Entity has a physical component.
Definition: Components.h:346
Handles updating time of Ogre animations.
Definition: Systems.h:121
bs::Scene Scene
Attaches this node to this parent (if null entity then attached to the scene root)
Definition: Components.h:104
DLLEXPORT void Release(PhysicalWorld *world)
Destroys the physical body.
Definition: Components.cpp:107
Entity has a model.
Definition: Components.h:232
static constexpr auto TYPE
Definition: Components.h:106
std::unique_ptr< std::string > OptionalName
Set a name when you don't want other non-named forces to override this.
Definition: Components.h:385
static constexpr auto TYPE
Definition: Components.h:730
REFERENCE_HANDLE_UNCOUNTED_TYPE(Sendable)
DLLEXPORT void JumpTo(Position &target)
Syncs this physics body to a changed position.
Definition: Components.cpp:117
DLLEXPORT Animated(RenderNode &node)
Definition: Components.cpp:354
Properties that a camera entity has (will also need a Position component)
Definition: Components.h:713
uint16_t FOV
Horizontal (ie. "normal") field of view.
Definition: Components.h:724
static constexpr auto TYPE
Definition: Components.h:252
std::string Material
Rendering surface material name.
Definition: Components.h:223
REFERENCE_HANDLE_UNCOUNTED_TYPE(Camera)
#define DLLEXPORT
Definition: Include.h:84
static constexpr auto TYPE
Definition: Components.h:206
Entity plays animations on an Ogre::Item.
Definition: Components.h:295
Base class for all components.
Definition: Component.h:52
Position & _Position
Physics object requires a position.
Definition: Components.h:494
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
Entity is sendable to clients.
Definition: Components.h:115
DLLEXPORT float GetMass() const
DLLEXPORT void Release(bs::Scene *worldsscene)
Gracefully releases while world is still valid.
Definition: Components.cpp:46
DLLEXPORT void ApplyPhysicalState(const BasePhysicsData &data)
Applies physical state from holder object.
float SpeedFactor
Controls how fast the animation plays.
Definition: Components.h:284
void SetPositionDataFromPhysics(const Float3 &position, const Float4 &orientation) override
Definition: Components.h:57
void GetPositionDataForPhysics(const Float3 *&position, const Float4 *&orientation) const override
Definition: Components.h:50
static boost::intrusive_ptr< ActualType > WrapPtr(ActualType *ptr)
Creates an intrusive_ptr from raw pointer.
REFERENCE_HANDLE_UNCOUNTED_TYPE(Animated)
DLLEXPORT void ApplyMeshName()
Definition: Components.cpp:321
Data(const Float3 &position, const Float4 &orientation)
Definition: Components.h:38
int32_t Scene
Definition: Define.h:68
Represents a world that contains entities.
Definition: GameWorld.h:94
std::vector< SimpleAnimation > Animations
Definition: Components.h:309
PhysicsBody * GetBodyWrapper() const
Definition: Components.h:458