Leviathan  0.8.0.0
Leviathan game engine
GameWorld.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2019 Henri Hyyryläinen
3 #pragma once
4 #include "Define.h"
5 // ------------------------------------ //
6 #include "Common/Ray.h"
8 #include "Common/ThreadSafe.h"
9 #include "Component.h"
11 #include "WorldNetworkSettings.h"
12 
13 class CScriptArray;
14 class asIScriptObject;
15 class asIScriptFunction;
16 
17 
18 namespace Leviathan {
19 
20 class Camera;
21 class PhysicalWorld;
22 class ScriptComponentHolder;
23 class ResponseEntityCreation;
24 class ResponseEntityDestruction;
25 class ResponseEntityUpdate;
26 class ResponseEntityLocalControlStatus;
27 class Scene;
28 class SceneNode;
29 
30 template<class StateT>
32 
33 class EntityState;
34 
36 
37  inline ComponentTypeInfo(uint16_t ltype, int astype) :
38  LeviathanType(ltype), AngelScriptType(astype)
39  {}
40 
43 };
44 
45 
46 #define WORLD_CLOCK_SYNC_PACKETS 12
47 #define WORLD_CLOCK_SYNC_ALLOW_FAILS 2
48 #define WORLD_OBJECT_UPDATE_CLIENTS_INTERVAL 2
49 
50 
57 class GameWorld {
58  class Implementation;
59 
60 public:
63  DLLEXPORT GameWorld(int32_t worldtype,
64  const std::shared_ptr<PhysicsMaterialManager>& physicsMaterials, int worldid = -1);
66 
69  DLLEXPORT bool Init(const WorldNetworkSettings& network, Graphics* graphics);
70 
72  DLLEXPORT void Release();
73 
75  DLLEXPORT void MarkForClear();
76 
78  DLLEXPORT void ClearEntities();
79 
83  DLLEXPORT size_t GetEntityCount() const
84  {
85  return Entities.size();
86  }
87 
89  DLLEXPORT inline const auto& GetEntities() const
90  {
91  return Entities;
92  }
93 
96  DLLEXPORT void Tick(float elapsed);
97 
100  DLLEXPORT void Render(float elapsed);
101 
103  DLLEXPORT inline auto GetCurrentWorldTime() const
104  {
105  return TotalElapsed;
106  }
107 
110  DLLEXPORT int GetPhysicalMaterial(const std::string& name);
111 
115 
122 
125 
128  DLLEXPORT void SetEntitysParent(ObjectID child, ObjectID parent);
129 
132  {
133  for(const auto& entity : Entities) {
134  if(id == entity)
135  return true;
136  }
137 
138  return false;
139  }
140 
141 
143  DLLEXPORT virtual void DestroyAllIn(ObjectID id);
144 
149  template<class TComponent>
150  TComponent& GetComponent(ObjectID id)
151  {
152  std::tuple<void*, bool> component = GetComponent(id, TComponent::TYPE);
153 
154  if(!std::get<1>(component))
155  throw InvalidArgument("Unrecognized component type as template parameter");
156 
157  void* ptr = std::get<0>(component);
158 
159  if(!ptr)
160  throw NotFound("Component for entity with id was not found");
161 
162  return *static_cast<TComponent*>(ptr);
163  }
164 
169  template<class TComponent>
170  TComponent* GetComponentPtr(ObjectID id)
171  {
172  std::tuple<void*, bool> component = GetComponent(id, TComponent::TYPE);
173 
174  void* ptr = std::get<0>(component);
175 
176  if(!ptr)
177  return nullptr;
178 
179  return static_cast<TComponent*>(ptr);
180  }
181 
185  DLLEXPORT virtual std::tuple<void*, bool> GetComponent(ObjectID id, COMPONENT_TYPE type);
186 
190  DLLEXPORT virtual std::tuple<void*, ComponentTypeInfo, bool> GetComponentWithType(
191  ObjectID id, COMPONENT_TYPE type);
192 
197  template<class TComponent>
199  {
200  std::tuple<void*, bool> stateHolder = GetStatesFor(TComponent::TYPE);
201 
202  if(!std::get<1>(stateHolder))
203  throw InvalidArgument("Unrecognized component type as template parameter for "
204  "state holder");
205 
206  void* ptr = std::get<0>(stateHolder);
207 
208  return *static_cast<StateHolder<typename TComponent::StateT>*>(ptr);
209  }
210 
214  DLLEXPORT virtual std::tuple<void*, bool> GetStatesFor(COMPONENT_TYPE type);
215 
219  DLLEXPORT virtual bool GetRemovedFor(
220  COMPONENT_TYPE type, std::vector<std::tuple<void*, ObjectID>>& result);
221 
224  const std::string& name, std::vector<std::tuple<asIScriptObject*, ObjectID>>& result);
225 
230  DLLEXPORT virtual bool GetAddedFor(COMPONENT_TYPE type,
231  std::vector<std::tuple<void*, ObjectID, ComponentTypeInfo>>& result);
232 
234  DLLEXPORT bool GetAddedForScriptDefined(const std::string& name,
235  std::vector<std::tuple<asIScriptObject*, ObjectID, ScriptComponentHolder*>>& result);
236 
238  DLLEXPORT virtual void CaptureEntityState(ObjectID id, EntityState& curstate) const;
239 
244  ObjectID id, sf::Packet& receiver) const;
245 
250  DLLEXPORT void SetCamera(ObjectID object);
251 
258  DLLEXPORT Ray CastRayFromCamera(int x, int y) const;
259 
261 
266 
267  // physics functions //
268  // DLLEXPORT Float3 GetGravityAtPosition(const Float3& pos);
269 
272 
274  {
275  return _PhysicalWorld.get();
276  }
277 
279  DLLEXPORT inline int GetID() const
280  {
281  return ID;
282  }
283 
285  DLLEXPORT inline int32_t GetType() const
286  {
287  return WorldType;
288  }
289 
290  DLLEXPORT inline const auto& GetNetworkSettings() const
291  {
292  return NetworkSettings;
293  }
294 
296  DLLEXPORT void SetWorldPhysicsFrozenState(bool frozen);
297 
299  DLLEXPORT inline void SetPaused(bool paused)
300  {
301  Paused = paused;
302  }
303 
304  // Script proxies //
307 
308  //
309  // Networking methods
310  //
311 
315  DLLEXPORT bool ShouldPlayerReceiveEntity(Position& atposition, Connection& connection);
316 
319  DLLEXPORT bool IsConnectionInWorld(Connection& connection) const;
320 
322  DLLEXPORT void SetPlayerReceiveWorld(std::shared_ptr<ConnectedPlayer> ply);
323 
326  inline const auto& GetConnectedPlayers() const
327  {
328  return ReceivingPlayers;
329  }
330 
333  const std::shared_ptr<NetworkResponse>& response, RECEIVE_GUARANTEE guarantee) const;
334 
339  ObjectID id, bool enabled, const std::shared_ptr<Connection>& allowedconnection);
340 
342  DLLEXPORT const auto& GetOurLocalControl() const
343  {
344  return OurActiveLocalControl;
345  }
346 
352  {
353  for(const auto& entity : OurActiveLocalControl)
354  if(entity == id)
355  return true;
356  return false;
357  }
358 
361  DLLEXPORT void SetServerForLocalControl(const std::shared_ptr<Connection>& connection)
362  {
363  ClientToServerConnection = connection;
364  }
365 
367  {
368  return ClientToServerConnection;
369  }
370 
376  DLLEXPORT void HandleEntityPacket(ResponseEntityUpdate&& message, Connection& connection);
377 
379  DLLEXPORT ObjectID HandleEntityPacket(ResponseEntityCreation& message);
380 
381  DLLEXPORT void HandleEntityPacket(ResponseEntityDestruction& message);
382 
383  DLLEXPORT void HandleEntityPacket(ResponseEntityLocalControlStatus& message);
384 
385  // //! \brief Handles a world clock synchronizing packet
386  // //! \note This should only be allowed to be called on a client that has connected
387  // //! to a server
388  // DLLEXPORT void HandleClockSyncPacket(RequestWorldClockSync* data);
389 
390  // //! \brief Handles a world freeze/unfreeze packet
391  // //! \note Should only be called on a client
392  // DLLEXPORT void HandleWorldFrozenPacket(ResponseWorldFrozen* data);
393 
394  DLLEXPORT void SetSunlight();
395  DLLEXPORT void RemoveSunlight();
398  DLLEXPORT void SetLightProperties(const Float3& colour, float intensity = 0.0001f,
399  const Float3& direction = Float3(0.55f, -0.3f, 0.75f), float sourceradius = 0.5f,
400  bool castsshadows = true);
401 
403  DLLEXPORT void SetSkybox(const std::string& skyboxname, float brightness = 1.f);
404 
406  DLLEXPORT void SetAutoExposure(float mineyeadaptation = 0.003f,
407  float maxeyeadaptation = 2.0f, float eyeadaptationspeeddown = 3.0f,
408  float eyeadaptationspeedup = 3.0f, float histogramlog2max = 4.0f,
409  float histogramlog2min = -8.0f, float histogrampcthigh = 0.985f,
410  float histogrampctlow = 0.8f);
411 
412  // ------------------------------------ //
413  // Script proxies for script system implementation (don't use from c++ systems)
414 
417  DLLEXPORT CScriptArray* GetRemovedIDsForComponents(CScriptArray* componenttypes);
418 
421  DLLEXPORT CScriptArray* GetRemovedIDsForScriptComponents(CScriptArray* typenames);
422 
425  const std::string& name, asIScriptFunction* factory);
426 
429  DLLEXPORT ScriptComponentHolder* GetScriptComponentHolder(const std::string& name);
430 
433  DLLEXPORT bool RegisterScriptSystem(const std::string& name, asIScriptObject* system);
434 
439  DLLEXPORT bool UnregisterScriptSystem(const std::string& name);
440 
443  DLLEXPORT asIScriptObject* GetScriptSystem(const std::string& name);
444 
445  // ------------------------------------ //
446  // Background worlds (used to stop ticking etc.)
447 
450  DLLEXPORT virtual void OnUnLinkedFromWindow(Window* window, Graphics* graphics);
451 
454  DLLEXPORT virtual void OnLinkToWindow(Window* window, Graphics* graphics);
455 
457  DLLEXPORT virtual void SetRunInBackground(bool tickinbackground);
458 
459 
461 
462 protected:
466 
467 public:
472  DLLEXPORT virtual void RunFrameRenderSystems(float elapsed);
473 
474 protected:
480  DLLEXPORT virtual void _RunTickSystems(float elapsed);
481 
487  DLLEXPORT virtual void HandleAddedAndDeleted();
488 
490  DLLEXPORT virtual void ClearAddedAndRemoved();
491 
493  DLLEXPORT virtual void _ResetSystems();
494 
496  DLLEXPORT virtual void _ResetOrReleaseComponents();
497 
499  DLLEXPORT virtual void _DoSystemsInit();
500 
502  DLLEXPORT virtual void _DoSystemsRelease();
503 
508  DLLEXPORT virtual void _DoSuspendSystems();
509 
511  DLLEXPORT virtual void _DoResumeSystems();
512 
515 
518 
525  ObjectID id, sf::Packet& data, int entriesleft, int decodedtype);
526 
530  DLLEXPORT virtual void _CreateStatesFromUpdateMessage(ObjectID id, int32_t ticknumber,
531  sf::Packet& data, int32_t referencetick, int decodedtype);
532 
539  DLLEXPORT virtual void _ApplyLocalControlUpdateMessage(ObjectID id, int32_t ticknumber,
540  sf::Packet& data, int32_t referencetick, int decodedtype);
541 
542 
547  DLLEXPORT virtual void _OnLocalControlUpdatedEntity(ObjectID id, int32_t ticknumber);
548 
549 private:
551  void UpdatePlayersPositionData(ConnectedPlayer& ply);
552 
553  void _CreateRenderingResources(Graphics* graphics);
554  void _DestroyRenderingResources();
555 
556  void _HandleDelayedDelete();
557 
559  void _ReportEntityDestruction(ObjectID id);
560 
563  void _DoDestroy(ObjectID id);
564 
566  void _SendEntityUpdates(ObjectID id, Sendable& sendable, int tick);
567 
568 
569 protected:
574  bool GraphicalMode = false;
575 
576 private:
577  // pimpl to reduce need of including tons of headers (this causes
578  // a double pointer dereference so don't put performance critical
579  // stuff here)
580  std::unique_ptr<Implementation> pimpl;
581 
583  Window* LinkedToWindow = nullptr;
584 
585  // physics //
586  std::shared_ptr<PhysicsMaterialManager> PhysicsMaterials;
587  std::shared_ptr<PhysicalWorld> _PhysicalWorld;
588 
590  bool WorldFrozen = false;
591 
593  bool Paused = false;
594 
596  bool ClearAllEntities = false;
597 
601  std::vector<std::shared_ptr<ConnectedPlayer>> ReceivingPlayers;
602 
605  std::map<ObjectID, Connection*> ActiveLocalControl;
606 
608  std::shared_ptr<Connection> ClientToServerConnection;
609 
611  std::vector<ObjectID> OurActiveLocalControl;
612 
614  WorldNetworkSettings NetworkSettings;
615 
616  // //! List of newly created entities that need to be created (or they have added new
617  // //! components and the initial value needs to be sent again)
618  // std::vector<ObjectID> NewlyCreatedEntities;
619 
620  // Entities //
621  std::vector<ObjectID> Entities;
622 
623  // Parented entities, used to destroy children
624  // First is the parent, second is child
625  std::vector<std::tuple<ObjectID, ObjectID>> Parents;
626 
628  const int ID;
629 
632  const int32_t WorldType;
633 
635  double TotalElapsed = 0.0;
636 
638  std::string DecoratedName;
639 
641  ObjectID CameraEntity = 0;
642 
646  Camera* AppliedCameraPropertiesPtr = nullptr;
647 
650  bool TickInProgress = false;
651 
653  bool TickWhileInBackground = false;
654 
660  bool InBackground = true;
661 
663  Mutex DeleteMutex;
664 
666  std::vector<ObjectID> DelayedDeleteIDS;
667 
668  float FOV = 90;
669 
670  // //! If true any pointers to this world are invalid
671  // std::shared_ptr<bool> WorldDestroyed = std::make_shared<bool>(false);
672 };
673 
674 } // namespace Leviathan
675 
676 #ifdef LEAK_INTO_GLOBAL
678 using Leviathan::ObjectID;
679 #endif
virtual DLLEXPORT std::tuple< void *, ComponentTypeInfo, bool > GetComponentWithType(ObjectID id, COMPONENT_TYPE type)
Gets a component of type or returns nullptr.
Definition: GameWorld.cpp:1101
DLLEXPORT asIScriptObject * GetScriptSystem(const std::string &name)
Returns the underlying angelscript object that implements a script system.
Definition: GameWorld.cpp:1772
virtual DLLEXPORT void _DoSuspendSystems()
Called when this is put in the background and systems (the sound system) should suspend their active ...
Definition: GameWorld.cpp:1181
DLLEXPORT ObjectID CreateEntity()
Creates a new empty entity and returns its id.
Definition: GameWorld.cpp:865
DLLEXPORT const auto & GetEntities() const
Returns the created entity id vector.
Definition: GameWorld.h:89
int32_t ObjectID
Definition: EntityCommon.h:11
DLLEXPORT bool RegisterScriptComponentType(const std::string &name, asIScriptFunction *factory)
Registers a component type from scripts.
Definition: GameWorld.cpp:1693
DLLEXPORT void SetEntitysParent(ObjectID child, ObjectID parent)
Makes child entity be deleted when parent is deleted.
Definition: GameWorld.cpp:1091
Ray starting from an origin with a direction.
Definition: Ray.h:14
virtual DLLEXPORT void OnLinkToWindow(Window *window, Graphics *graphics)
Called when this is added to a Window.
Definition: GameWorld.cpp:1824
DLLEXPORT void HandleEntityPacket(ResponseEntityUpdate &&message, Connection &connection)
Applies an entity update packet.
Definition: GameWorld.cpp:1323
DLLEXPORT void Render(float elapsed)
Runs systems required for a rendering run. Also updates camera positions.
Definition: GameWorld.cpp:390
COMPONENT_TYPE
Must contain all valid Component types.
Definition: Component.h:21
virtual DLLEXPORT void _DoSystemsRelease()
Called in Release when systems should run their shutdown logic.
Definition: GameWorld.cpp:1165
virtual DLLEXPORT void DestroyAllIn(ObjectID id)
Removes all components from an entity.
Definition: GameWorld.cpp:1214
PhysicalWorld * GetPhysicalWorld()
Definition: GameWorld.h:273
RECEIVE_GUARANTEE
Controls whether a packet is critical.
Definition: CommonNetwork.h:49
virtual DLLEXPORT void _CreateSendableComponentForEntity(ObjectID id)
Called when this base class wants to create a Sendable component.
Definition: GameWorld.cpp:1201
virtual DLLEXPORT void _ApplyLocalControlUpdateMessage(ObjectID id, int32_t ticknumber, sf::Packet &data, int32_t referencetick, int decodedtype)
Called to apply local control from a clients message.
Definition: GameWorld.cpp:709
DLLEXPORT void SetLightProperties(const Float3 &colour, float intensity=0.0001f, const Float3 &direction=Float3(0.55f, -0.3f, 0.75f), float sourceradius=0.5f, bool castsshadows=true)
Sets the sunlight properties.
Definition: GameWorld.cpp:338
DLLEXPORT void Tick(float elapsed)
Used to keep track of passed ticks and trigger timed triggers.
Definition: GameWorld.cpp:716
DLLEXPORT int GetID() const
Definition: GameWorld.h:279
DLLEXPORT CScriptArray * GetRemovedIDsForComponents(CScriptArray *componenttypes)
Returns a list of ObjectIDs that have been removed from any of the specified component types.
Definition: GameWorld.cpp:1603
DLLEXPORT SceneNode * GetCameraSceneObject()
Returns the scene object the camera is attached to.
Definition: GameWorld.cpp:508
DLLEXPORT void EnablePhysicsDebugDraw()
Definition: GameWorld.cpp:527
DLLEXPORT void SetLocalControl(ObjectID id, bool enabled, const std::shared_ptr< Connection > &allowedconnection)
Sets local control on a client over an entity or disables it.
Definition: GameWorld.cpp:1495
virtual DLLEXPORT void _CreateReceivedComponentForEntity(ObjectID id)
Called when this base class wants to create a Received component.
Definition: GameWorld.cpp:1207
virtual DLLEXPORT void RunFrameRenderSystems(float elapsed)
Called by Render which is called from a Window if this is linked to one.
Definition: GameWorld.cpp:845
virtual DLLEXPORT bool GetAddedFor(COMPONENT_TYPE type, std::vector< std::tuple< void *, ObjectID, ComponentTypeInfo >> &result)
Gets a list of created components of type.
Definition: GameWorld.cpp:1132
DLLEXPORT void QueueDestroyEntity(ObjectID id)
Deletes an entity during the next tick.
Definition: GameWorld.cpp:961
virtual DLLEXPORT void HandleAddedAndDeleted()
Handles added entities and components.
Definition: GameWorld.cpp:796
DLLEXPORT bool IsConnectionInWorld(Connection &connection) const
Returns true if a player with the given connection is receiving updates for this world.
Definition: GameWorld.cpp:554
DLLEXPORT void DisablePhysicsDebugDraw()
Definition: GameWorld.cpp:536
A node in the Scene used to position renderables and other SceneNodes.
Definition: SceneNode.h:70
DLLEXPORT bool GetRemovedForScriptDefined(const std::string &name, std::vector< std::tuple< asIScriptObject *, ObjectID >> &result)
Variant of GetRemovedFor for script defined types.
Definition: GameWorld.cpp:1118
ComponentTypeInfo(uint16_t ltype, int astype)
Definition: GameWorld.h:37
DLLEXPORT void ApplyQueuedPackets()
Applies packets that were received out of order. And throws out any too old packets.
Definition: GameWorld.cpp:1535
virtual DLLEXPORT void _ResetOrReleaseComponents()
Resets components in holders. Used together with _ResetSystems.
Definition: GameWorld.cpp:831
virtual DLLEXPORT void OnUnLinkedFromWindow(Window *window, Graphics *graphics)
Used to detect that this world is in the background and should not tick.
Definition: GameWorld.cpp:1789
DLLEXPORT void SetSunlight()
Definition: GameWorld.cpp:271
DLLEXPORT const auto & GetNetworkSettings() const
Definition: GameWorld.h:290
DLLEXPORT auto GetCurrentWorldTime() const
Returns the total amount of time the world has been running.
Definition: GameWorld.h:103
DLLEXPORT void SetWorldPhysicsFrozenState(bool frozen)
Definition: GameWorld.cpp:1235
DLLEXPORT const auto & GetServerForLocalControl() const
Definition: GameWorld.h:366
DLLEXPORT size_t GetEntityCount() const
Returns the number of ObjectIDs this world keeps track of.
Definition: GameWorld.h:83
TComponent & GetComponent(ObjectID id)
Definition: GameWorld.h:150
virtual DLLEXPORT void _CreateStatesFromUpdateMessage(ObjectID id, int32_t ticknumber, sf::Packet &data, int32_t referencetick, int decodedtype)
Called to deserialize entity component states from a packet.
Definition: GameWorld.cpp:701
DLLEXPORT void SetPaused(bool paused)
Pause or unpause all systems and physics.
Definition: GameWorld.h:299
DLLEXPORT CScriptArray * GetRemovedIDsForScriptComponents(CScriptArray *typenames)
Returns a list of ObjectIDs that have been removed from any of the script registered component types ...
Definition: GameWorld.cpp:1647
Entity has position and direction it is looking at.
Definition: Components.h:36
DLLEXPORT int32_t GetType() const
Definition: GameWorld.h:285
DLLEXPORT ~GameWorld()
Definition: GameWorld.cpp:84
DLLEXPORT Ray CastRayFromCamera(int x, int y) const
Casts a ray from the active camera.
Definition: GameWorld.cpp:494
DLLEXPORT bool Init(const WorldNetworkSettings &network, Graphics *graphics)
Creates resources for the world to work.
Definition: GameWorld.cpp:95
DLLEXPORT const auto & GetOurLocalControl() const
Definition: GameWorld.h:342
DLLEXPORT bool ShouldPlayerReceiveEntity(Position &atposition, Connection &connection)
Returns true when the player matching the connection should receive updates about an entity.
Definition: GameWorld.cpp:548
DLLEXPORT void SetServerForLocalControl(const std::shared_ptr< Connection > &connection)
Sets a connection that will be used to send local control entity updates to the server.
Definition: GameWorld.h:361
unsigned short uint16_t
Definition: core.h:39
std::mutex Mutex
Definition: ThreadSafe.h:16
DLLEXPORT bool RegisterScriptSystem(const std::string &name, asIScriptObject *system)
Registers a new system defined in a script. Must implement the ScriptSystem interface.
Definition: GameWorld.cpp:1725
virtual DLLEXPORT void ClearAddedAndRemoved()
Clears the added components. Call after HandleAddedAndDeleted.
Definition: GameWorld.cpp:806
DLLEXPORT GameWorld(int32_t worldtype, const std::shared_ptr< PhysicsMaterialManager > &physicsMaterials, int worldid=-1)
Definition: GameWorld.cpp:77
StateHolder< typename TComponent::StateT > & GetStatesFor()
Definition: GameWorld.h:198
virtual DLLEXPORT void CaptureEntityState(ObjectID id, EntityState &curstate) const
Captures the current state of an entity.
Definition: GameWorld.cpp:684
DLLEXPORT void RemoveSunlight()
Definition: GameWorld.cpp:295
virtual DLLEXPORT void _OnLocalControlUpdatedEntity(ObjectID id, int32_t ticknumber)
This method is for doing checks after applying client sent state to the server.
Definition: GameWorld.cpp:1521
DLLEXPORT void Release()
Release resources.
Definition: GameWorld.cpp:122
A class that represents a human player.
virtual DLLEXPORT void _CreateComponentsFromCreationMessage(ObjectID id, sf::Packet &data, int entriesleft, int decodedtype)
Called to deserialize initial entity components and their static state.
Definition: GameWorld.cpp:691
DLLEXPORT ScriptComponentHolder * GetScriptComponentHolder(const std::string &name)
Retrieves a script registered component type holder.
Definition: GameWorld.cpp:1710
DLLEXPORT bool IsUnderOurLocalControl(ObjectID id)
Definition: GameWorld.h:351
Properties that a camera entity has (will also need a Position component)
Definition: Components.h:714
Class that handles a single connection to another instance.
Definition: Connection.h:105
virtual DLLEXPORT void _RunTickSystems(float elapsed)
Called by Tick.
Definition: GameWorld.cpp:854
#define DLLEXPORT
Definition: Include.h:84
DLLEXPORT void SetCamera(ObjectID object)
Sets the entity that acts as a camera.
Definition: GameWorld.cpp:469
DLLEXPORT void MarkForClear()
Marks all entities to be deleted.
Definition: GameWorld.cpp:1296
virtual DLLEXPORT void _DoResumeSystems()
Opposite of _DoSuspendSystems.
Definition: GameWorld.cpp:1191
DLLEXPORT bool GetAddedForScriptDefined(const std::string &name, std::vector< std::tuple< asIScriptObject *, ObjectID, ScriptComponentHolder * >> &result)
Variant of GetAddedFor for script defined types.
Definition: GameWorld.cpp:1138
virtual DLLEXPORT uint32_t CaptureEntityStaticState(ObjectID id, sf::Packet &receiver) const
Captures the initial parameters of an entity with components that don't have current state synchroniz...
Definition: GameWorld.cpp:686
DLLEXPORT void ClearEntities()
Clears all objects from the world.
Definition: GameWorld.cpp:892
Holds state objects of type for quick access by ObjectID.
Definition: GameWorld.h:31
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
DLLEXPORT void SetAutoExposure(float mineyeadaptation=0.003f, float maxeyeadaptation=2.0f, float eyeadaptationspeeddown=3.0f, float eyeadaptationspeedup=3.0f, float histogramlog2max=4.0f, float histogramlog2min=-8.0f, float histogrampcthigh=0.985f, float histogrampctlow=0.8f)
Sets the world camera eye adaptation settings.
Definition: GameWorld.cpp:368
Holder of state for a whole entity.
unsigned int uint32_t
Definition: core.h:40
Entity is sendable to clients.
Definition: Components.h:115
virtual DLLEXPORT void SetRunInBackground(bool tickinbackground)
Configures this world to run tick even when not attached to a window.
Definition: GameWorld.cpp:1857
DLLEXPORT bool DoesEntityExist(ObjectID id) const
Returns true if entity exists.
Definition: GameWorld.h:131
DLLEXPORT void SetSkybox(const std::string &skyboxname, float brightness=1.f)
Definition: GameWorld.cpp:305
virtual DLLEXPORT bool GetRemovedFor(COMPONENT_TYPE type, std::vector< std::tuple< void *, ObjectID >> &result)
Gets a list of destroyed components of type.
Definition: GameWorld.cpp:1112
DLLEXPORT void SetPlayerReceiveWorld(std::shared_ptr< ConnectedPlayer > ply)
Verifies that player is receiving this world.
Definition: GameWorld.cpp:567
virtual DLLEXPORT void _DoSystemsInit()
Called in Init when systems should run their initialization logic.
Definition: GameWorld.cpp:1160
virtual DLLEXPORT void _ResetSystems()
Resets stored nodes in systems. Used together with _ResetComponents.
Definition: GameWorld.cpp:817
const auto & GetConnectedPlayers() const
This is used by Sendable system to loop all players.
Definition: GameWorld.h:326
bool GraphicalMode
If false a graphical Ogre window hasn't been created and purely graphical stuff should be skipped.
Definition: GameWorld.h:574
DLLEXPORT bool UnregisterScriptSystem(const std::string &name)
Unregisters a script system that was registered with RegisterScriptSystem.
Definition: GameWorld.cpp:1754
DLLEXPORT void DestroyEntity(ObjectID id)
Destroys an entity and all of its components.
Definition: GameWorld.cpp:937
REFERENCE_HANDLE_UNCOUNTED_TYPE(GameWorld)
DLLEXPORT Scene * GetScene()
Definition: GameWorld.cpp:513
DLLEXPORT void SendToAllPlayers(const std::shared_ptr< NetworkResponse > &response, RECEIVE_GUARANTEE guarantee) const
Sends a packet to all connected players.
Definition: GameWorld.cpp:667
DLLEXPORT int GetPhysicalMaterial(const std::string &name)
Fetches the physical material ID from the material manager.
Definition: GameWorld.cpp:929
Represents a world that contains entities.
Definition: GameWorld.h:57
DLLEXPORT Scene * GetSceneWrapper()
Definition: GameWorld.cpp:519
TComponent * GetComponentPtr(ObjectID id)
Definition: GameWorld.h:170