BVB Source Codes

CRYENGINE Show ProceduralBreakingBaseListener.h Source code

Return Download CRYENGINE: download ProceduralBreakingBaseListener.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description:  network breakability: common listener code for procedural breaks
  8.    -------------------------------------------------------------------------
  9.    History:
  10.    - 22/01/2007   10:34 : Created by Craig Tiller
  11. *************************************************************************/
  12. #ifndef __PROCEDURALBREAKBASELISTENER_H__
  13. #define __PROCEDURALBREAKBASELISTENER_H__
  14.  
  15. #pragma once
  16.  
  17. #if !NET_USE_SIMPLE_BREAKAGE
  18.  
  19.         #include "IBreakReplicatorListener.h"
  20.         #include "IProceduralBreakType.h"
  21.         #include <CryCore/Containers/VectorMap.h>
  22.  
  23. void DumpSpawnRecs(const DynArray<SProceduralSpawnRec>& recs, const DynArray<SJointBreakRec>& joints, const char* title);
  24.  
  25. class CProceduralBreakingBaseListener : public IBreakReplicatorListener
  26. {
  27. public:
  28.         CProceduralBreakingBaseListener(IProceduralBreakTypePtr pBreakType);
  29.         ~CProceduralBreakingBaseListener();
  30.         bool            AcceptUpdateMesh(const EventPhysUpdateMesh* pEvent);
  31.         bool            AcceptCreateEntityPart(const EventPhysCreateEntityPart* pEvent);
  32.         bool            AcceptRemoveEntityParts(const EventPhysRemoveEntityParts* pEvent);
  33.         bool            AcceptJointBroken(const EventPhysJointBroken* pEvent);
  34.  
  35.         void            OnSpawn(IEntity* pEntity, SEntitySpawnParams& params);
  36.         void            OnRemove(IEntity* pEntity);
  37.  
  38.         void            EndEvent(INetContext* pCtx);
  39.  
  40.         virtual void    OnPostStep();
  41.         virtual void    OnStartFrame();
  42.         virtual bool    OnEndFrame();
  43.  
  44.         virtual void    OnTimeout();
  45.  
  46.         CObjectSelector GetObjectSelector(int idx);
  47.  
  48.         const char*     GetName()
  49.         {
  50.                 if (m_name.empty())
  51.                         m_name.Format("ProceduralBreaking.%s.%s", GetListenerName(), m_pBreakType->GetName());
  52.                 return m_name.c_str();
  53.         }
  54.  
  55. protected:
  56.         IProceduralBreakType* GetBreakType()           { return m_pBreakType; }
  57.         void                  DisallowAdditions()      { m_allowAdditions = false; }
  58.         int                   GetNumEmptySteps() const { return m_numEmptySteps; }
  59.  
  60. private:
  61.         VectorMap<EntityId, int> m_localEntityIds;
  62.         IProceduralBreakTypePtr  m_pBreakType;
  63.         #if BREAK_HIERARCHICAL_TRACKING
  64.         int                      m_physTime;
  65.         int                      m_activityThisStep;
  66.         int                      m_numEmptySteps;
  67.         #endif
  68.         ENetBreakOperation       m_curBreakOp;
  69.         int                      m_curBreakId;
  70.         int                      m_curBreakPart;
  71.         bool                     m_allowAdditions;
  72.         string                   m_name; // usually empty
  73.  
  74.         struct SJustSpawnedObject
  75.         {
  76.                 ENetBreakOperation op;
  77.                 int                idxRef;
  78.                 EntityId           to;
  79.                 int                virtId;
  80.         };
  81.         std::vector<SJustSpawnedObject> m_justSpawnedObjects;
  82.  
  83.         virtual int         GotBreakOp(ENetBreakOperation op, int idxRef, int partid, EntityId to) = 0;
  84.         virtual void        FinishBreakOp(ENetBreakOperation op, int idxRef, EntityId to, int virtId) = 0;
  85.         virtual void        GotJointBreak(int idxRef, int id, int epicenter) = 0;
  86.         virtual void        GotJointBreakParticle(const EventPhysCreateEntityPart* pEvent) = 0;
  87.         virtual void        Complete() = 0;
  88.         virtual bool        AllowComplete() = 0;
  89.         virtual const char* GetListenerName() = 0;
  90.  
  91.         bool                AcceptIfRelated(IPhysicalEntity* pEnt, ENetBreakOperation breakOp, int partid);
  92. };
  93.  
  94. #endif // !NET_USE_SIMPLE_BREAKAGE
  95.  
  96. #endif
  97.  
downloadProceduralBreakingBaseListener.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