BVB Source Codes

CRYENGINE Show IGameObjectSystem.h Source code

Return Download CRYENGINE: download IGameObjectSystem.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __IGAMEOBJECTSYSTEM_H__
  4. #define __IGAMEOBJECTSYSTEM_H__
  5.  
  6. #pragma once
  7.  
  8. #include <CryEntitySystem/IEntityClass.h>
  9. #include <CryGame/IGameFramework.h>
  10. #include <CryNetwork/INetwork.h>
  11.  
  12. enum EGameObjectEventFlags
  13. {
  14.         eGOEF_ToScriptSystem     = 0x0001,
  15.         eGOEF_ToGameObject       = 0x0002,
  16.         eGOEF_ToExtensions       = 0x0004,
  17.         eGOEF_LoggedPhysicsEvent = 0x0008, // was this a logged or immediate physics event
  18.  
  19.         eGOEF_ToAll              = eGOEF_ToScriptSystem | eGOEF_ToGameObject | eGOEF_ToExtensions
  20. };
  21.  
  22. struct IGameObject;
  23. struct SGameObjectEvent;
  24.  
  25. struct IGameObjectBoxListener
  26. {
  27.         virtual ~IGameObjectBoxListener(){}
  28.         virtual void OnEnter(int id, EntityId entity) = 0;
  29.         virtual void OnLeave(int id, EntityId entity) = 0;
  30.         virtual void OnRemoveParent() = 0;
  31. };
  32.  
  33. // Description:
  34. //              A callback interface for a class that wants to be aware when new game objects are being spawned. A class that implements
  35. //              this interface will be called every time a new game object is spawned.
  36. struct IGameObjectSystemSink
  37. {
  38.         // This callback is called after this game object is initialized.
  39.         virtual void OnAfterInit(IGameObject* object) = 0;
  40.         virtual ~IGameObjectSystemSink(){}
  41. };
  42.  
  43. struct IGameObjectSystem
  44. {
  45.         virtual ~IGameObjectSystem(){}
  46.         // If this is set as the user data for a GameObject with Preactivated Extension
  47.         // spawn, then it will be called back to provide additional initialization.
  48.         struct SEntitySpawnParamsForGameObjectWithPreactivatedExtension
  49.         {
  50.                 // If the user wants to extend this spawn parameters using this as a base class,
  51.                 // make sure to override 'm_type' member with your own typeID starting at 'eSpawnParamsType_Custom'
  52.                 enum EType
  53.                 {
  54.                         eSpawnParamsType_Default = 0,
  55.                         eSpawnParamsType_Custom,
  56.                 };
  57.  
  58.                 bool  (* hookFunction)(IEntity* pEntity, IGameObject*, void* pUserData);
  59.                 void* pUserData;
  60.                 TSerialize *pSpawnSerializer;
  61.  
  62.                 SEntitySpawnParamsForGameObjectWithPreactivatedExtension()
  63.                         : m_type(eSpawnParamsType_Default)
  64.                         , pUserData(nullptr)
  65.                         , hookFunction(nullptr)
  66.                         , pSpawnSerializer(nullptr)
  67.                 {
  68.                 }
  69.  
  70.                 uint32 IsOfType(const uint32 type) const { return (m_type == type); };
  71.  
  72.         protected:
  73.                 uint32 m_type;
  74.         };
  75.  
  76.         typedef uint16                  ExtensionID;
  77.         static const ExtensionID InvalidExtensionID = ~ExtensionID(0);
  78.         typedef IGameObjectExtension*(* GameObjectExtensionFactory)();
  79.  
  80.         virtual IGameObjectSystem::ExtensionID GetID(const char* name) = 0;
  81.         virtual const char*                    GetName(IGameObjectSystem::ExtensionID id) = 0;
  82.         virtual uint32                         GetExtensionSerializationPriority(IGameObjectSystem::ExtensionID id) = 0;
  83.         virtual IGameObjectExtension*        Instantiate(IGameObjectSystem::ExtensionID id, IGameObject* pObject, TSerialize* pSpawnSerializer) = 0;
  84.         virtual void                           BroadcastEvent(const SGameObjectEvent& evt) = 0;
  85.  
  86.         static const uint32                    InvalidEventID = ~uint32(0);
  87.         virtual void              RegisterEvent(uint32 id, const char* name) = 0;
  88.         virtual uint32            GetEventID(const char* name) = 0;
  89.         virtual const char*       GetEventName(uint32 id) = 0;
  90.  
  91.         virtual IGameObject*      CreateGameObjectForEntity(EntityId entityId) = 0;
  92.         virtual IEntityComponent* CreateGameObjectEntityProxy(IEntity& entity, IGameObject** ppGameObject = NULL) = 0;
  93.  
  94.         virtual void            RegisterExtension(const char* szName, IGameObjectExtensionCreatorBase* pCreator, IEntityClassRegistry::SEntityClassDesc* pEntityCls) = 0;
  95.         virtual void            RegisterSchedulingProfile(const char* szEntityClassName, const char* szNormalPolicy, const char* szOwnedPolicy) = 0;
  96.         virtual void            DefineProtocol(bool server, IProtocolBuilder* pBuilder) = 0;
  97.  
  98.         virtual void              PostUpdate(float frameTime) = 0;
  99.         virtual void              SetPostUpdate(IGameObject* pGameObject, bool enable) = 0;
  100.  
  101.         virtual void              Reset() = 0;
  102.  
  103.         virtual void              AddSink(IGameObjectSystemSink* pSink) = 0;
  104.         virtual void              RemoveSink(IGameObjectSystemSink* pSink) = 0;
  105. };
  106.  
  107. // Summary
  108. //   Structure used to define a game object event
  109. struct SGameObjectEvent
  110. {
  111.         SGameObjectEvent(uint32 event, uint16 flags, IGameObjectSystem::ExtensionID target = IGameObjectSystem::InvalidExtensionID, void* _param = 0)
  112.         {
  113.                 this->event = event;
  114.                 this->target = target;
  115.                 this->flags = flags;
  116.                 this->ptr = 0;
  117.                 this->param = _param;
  118.         }
  119.         uint32                         event;
  120.         IGameObjectSystem::ExtensionID target;
  121.         uint16                         flags;
  122.         void*                          ptr;
  123.         // optional parameter of event (ugly)
  124.         union
  125.         {
  126.                 void* param;
  127.                 bool  paramAsBool;
  128.         };
  129. };
  130.  
  131. #endif
  132.  
downloadIGameObjectSystem.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top