BVB Source Codes

CRYENGINE Show VehicleSeatActionWeapons.h Source code

Return Download CRYENGINE: download VehicleSeatActionWeapons.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: Implements a seat action to control vehicle weapons
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 06:12:2005: Created by Mathieu Pinard
  12.  
  13. *************************************************************************/
  14. #ifndef __VEHICLESEATACTIONWEAPONS_H__
  15. #define __VEHICLESEATACTIONWEAPONS_H__
  16.  
  17. struct IWeapon;
  18.  
  19. struct SWeaponAction
  20. {
  21.         std::vector<string> animations;
  22.  
  23.         void                GetMemoryUsage(ICrySizer* s) const
  24.         {
  25.                 s->AddObject(animations);
  26.                 for (size_t i = 0; i < animations.size(); i++)
  27.                         s->Add(animations[i]);
  28.         }
  29. };
  30. typedef std::map<string, SWeaponAction> TWeaponActionMap;
  31.  
  32. typedef std::vector<IVehicleHelper*>    TVehicleHelperVector;
  33.  
  34. struct SVehicleWeapon
  35. {
  36.         TWeaponActionMap     actions;
  37.         TVehicleHelperVector helpers;
  38.         IEntityClass*        pEntityClass;
  39.         EntityId             weaponEntityId;
  40.         IVehiclePart*        pPart;
  41.         bool                 inheritVelocity;
  42.         float                m_respawnTime;
  43.  
  44.         TagID                contextID;
  45.  
  46.         //Network dependency parent and child ID's
  47.         EntityId networkChildId;
  48.         EntityId networkParentId;
  49.  
  50.         SVehicleWeapon()
  51.         {
  52.                 pEntityClass = NULL;
  53.                 weaponEntityId = 0;
  54.                 pPart = 0;
  55.                 inheritVelocity = true;
  56.                 m_respawnTime = 0.f;
  57.                 networkChildId = 0;
  58.                 networkParentId = 0;
  59.                 contextID = TAG_ID_INVALID;
  60.         }
  61.  
  62.         void GetMemoryUsage(ICrySizer* s) const
  63.         {
  64.                 s->AddObject(actions);
  65.                 s->AddObject(helpers);
  66.         }
  67. };
  68.  
  69. class CVehicleSeatActionWeapons
  70.         :
  71.           public IVehicleSeatAction,
  72.           public IWeaponFiringLocator,
  73.           public IWeaponEventListener
  74. {
  75.         IMPLEMENT_VEHICLEOBJECT
  76.  
  77.         enum EAttackInput
  78.         {
  79.                 eAI_Primary = 0,
  80.                 eAI_Secondary,
  81.         };
  82.  
  83. public:
  84.  
  85.         CVehicleSeatActionWeapons();
  86.         virtual ~CVehicleSeatActionWeapons();
  87.  
  88.         // IVehicleSeatAction
  89.         virtual bool Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table) override;
  90.         virtual void OnSpawnComplete() override;
  91.         virtual void Reset() override;
  92.         virtual void Release() override { delete this; }
  93.  
  94.         virtual void StartUsing(EntityId passengerId) override;
  95.         void         StartUsing();
  96.  
  97.         virtual void ForceUsage() override;
  98.         virtual void StopUsing() override;
  99.         virtual void OnAction(const TVehicleActionId actionId, int activationMode, float value) override;
  100.  
  101.         virtual void Serialize(TSerialize ser, EEntityAspects aspects) override;
  102.         virtual void PostSerialize() override;
  103.         virtual void Update(const float deltaTime) override;
  104.         virtual void UpdateFromPassenger(const float frameTime, EntityId playerId) override;
  105.  
  106.         virtual void GetMemoryUsage(ICrySizer* s) const override;
  107.         // ~IVehicleSeatAction
  108.  
  109.         // IWeaponFiringLocator
  110.         virtual bool GetProbableHit(EntityId weaponId, const IFireMode* pFireMode, Vec3& hit) override;
  111.         virtual bool GetFiringPos(EntityId weaponId, const IFireMode* pFireMode, Vec3& pos) override;
  112.         virtual bool GetFiringDir(EntityId weaponId, const IFireMode* pFireMode, Vec3& dir, const Vec3& probableHit, const Vec3& firingPos) override;
  113.         virtual bool GetActualWeaponDir(EntityId weaponId, const IFireMode* pFireMode, Vec3& dir, const Vec3& probableHit, const Vec3& firingPos) override;
  114.         virtual bool GetFiringVelocity(EntityId weaponId, const IFireMode* pFireMode, Vec3& vel, const Vec3& firingDir) override;
  115.         virtual void WeaponReleased() override {}
  116.         // ~IWeaponFiringLocator
  117.  
  118.         // IWeaponEventListener
  119.         virtual void OnShoot(IWeapon* pWeapon, EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType,
  120.                              const Vec3& pos, const Vec3& dir, const Vec3& vel) override;
  121.         virtual void OnStartFire(IWeapon* pWeapon, EntityId shooterId) override                            {}
  122.         virtual void OnStopFire(IWeapon* pWeapon, EntityId shooterId) override                             {}
  123.         virtual void OnFireModeChanged(IWeapon* pWeapon, int currentFireMode) override                     {}
  124.         virtual void OnStartReload(IWeapon* pWeapon, EntityId shooterId, IEntityClass* pAmmoType) override {}
  125.         virtual void OnEndReload(IWeapon* pWeapon, EntityId shooterId, IEntityClass* pAmmoType) override   {}
  126.         virtual void OnSetAmmoCount(IWeapon* pWeapon, EntityId shooterId) override                         {}
  127.         virtual void OnOutOfAmmo(IWeapon* pWeapon, IEntityClass* pAmmoType) override;
  128.         virtual void OnReadyToFire(IWeapon* pWeapon) override                                              {}
  129.         virtual void OnPickedUp(IWeapon* pWeapon, EntityId actorId, bool destroyed) override               {}
  130.         virtual void OnDropped(IWeapon* pWeapon, EntityId actorId) override                                {}
  131.         virtual void OnMelee(IWeapon* pWeapon, EntityId shooterId) override                                {}
  132.         virtual void OnStartTargetting(IWeapon* pWeapon) override                                          {}
  133.         virtual void OnStopTargetting(IWeapon* pWeapon) override                                           {}
  134.         virtual void OnSelected(IWeapon* pWeapon, bool select) override                                    {}
  135.         virtual void OnEndBurst(IWeapon* pWeapon, EntityId shooterId) override                             {}
  136.         // ~IWeaponEventListener
  137.  
  138.         void            BindWeaponToNetwork(EntityId weaponId);
  139.         Vec3            GetAverageFiringPos();
  140.  
  141.         virtual void    OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params) override;
  142.  
  143.         void            StartFire();
  144.         void            StopFire();
  145.         bool            IsFiring() const                  { return m_isShooting; }
  146.         void            SetFireTarget(const Vec3& target) { m_fireTarget = target; }
  147.  
  148.         bool            IsSecondary() const               { return m_isSecondary; }
  149.  
  150.         bool            CanFireWeapon() const;
  151.  
  152.         unsigned int    GetWeaponCount() const;
  153.         unsigned int    GetCurrentWeapon() const { return m_weaponIndex; }
  154.  
  155.         EntityId        GetCurrentWeaponEntityId() const;
  156.         EntityId        GetWeaponEntityId(unsigned int index) const;
  157.         void            ClSetupWeapon(unsigned int index, EntityId weaponId);
  158.  
  159.         IItem*          GetIItem(unsigned int index);
  160.         IWeapon*        GetIWeapon(unsigned int index);
  161.  
  162.         IItem*          GetIItem(const SVehicleWeapon& vehicleWeapon);
  163.         IWeapon*        GetIWeapon(const SVehicleWeapon& vehicleWeapon);
  164.  
  165.         SVehicleWeapon* GetVehicleWeapon(EntityId weaponId);
  166.         bool            ForcedUsage() const { return m_Forced; }
  167.  
  168.         ILINE bool      IsMounted() const
  169.         {
  170.                 return m_isMounted;
  171.         }
  172.  
  173.         void OnWeaponRespawned(int weaponIndex, EntityId newWeaponEntityId);
  174.         void OnVehicleActionControllerDeleted();
  175.  
  176. protected:
  177.  
  178.         IEntity*        SpawnWeapon(SVehicleWeapon& weapon, IEntity* pVehicleEntity, const string& partName, int weaponIndex);
  179.         void            SetupWeapon(SVehicleWeapon& weapon);
  180.  
  181.         SVehicleWeapon& GetVehicleWeapon();
  182.         SVehicleWeapon& GetWeaponInfo(int weaponIndex);
  183.  
  184.         IVehicleHelper* GetHelper(SVehicleWeapon& vehicleWeapon);
  185.         IActor*         GetUserActor();
  186.  
  187. protected:
  188.  
  189.         int          GetSkipEntities(IPhysicalEntity** pSkipEnts, int nMaxSkip);
  190.  
  191.         void         DoUpdate(const float deltaTime);
  192.  
  193.         virtual void UpdateWeaponTM(SVehicleWeapon& weapon);
  194.         IEntity*     GetEntity(const SVehicleWeapon& weapon);
  195.  
  196.         bool         CanTriggerActionFire(const TVehicleActionId actionId) const;
  197.         bool         CanTriggerActionFiremode(const TVehicleActionId actionId) const;
  198.         bool         CanTriggerActionZoom(const TVehicleActionId actionId) const;
  199.  
  200.         IVehicle*     m_pVehicle;
  201.         string        m_partName;
  202.         IVehicleSeat* m_pSeat;
  203.  
  204.         EntityId      m_passengerId;
  205.  
  206.         typedef std::vector<SVehicleWeapon> TVehicleWeaponVector;
  207.         TVehicleWeaponVector m_weapons;
  208.         TVehicleWeaponVector m_weaponsCopy;
  209.         Vec3                 m_fireTarget;
  210.  
  211.         int                  m_lastActionActivationMode;
  212.         int                  m_weaponIndex;
  213.  
  214.         float                m_shotDelay;
  215.         float                m_nextShotTimer;
  216.         float                m_respawnTimer;
  217.  
  218.         EAttackInput         m_attackInput;
  219.  
  220.         bool                 m_isUsingShootingByUpdate;
  221.         bool                 m_isSecondary;
  222.         bool                 m_isShootingToCrosshair;
  223.         bool                 m_isShooting;
  224.         bool                 m_Forced;
  225.         bool                 m_isMounted;
  226. };
  227.  
  228. #endif
  229.  
downloadVehicleSeatActionWeapons.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