2021-12-05 17:54:36 +00:00
|
|
|
#pragma once
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
#include "NiPoint3.h"
|
|
|
|
#include "Entity.h"
|
2023-06-23 15:30:03 +00:00
|
|
|
#include "ActivityComponent.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parameters for the shooting gallery that change during playtime
|
|
|
|
*/
|
|
|
|
struct DynamicShootingGalleryParams {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The distance from the camera to the barrel
|
|
|
|
*/
|
|
|
|
Vector3 cameraBarrelOffset;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The area the barrel is looking at
|
|
|
|
*/
|
|
|
|
Vector3 facing;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The velocity of the cannonballs
|
|
|
|
*/
|
|
|
|
double_t cannonVelocity;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The max firerate of the cannon
|
|
|
|
*/
|
|
|
|
double_t cannonRefireRate;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The min distance the cannonballs traverse
|
|
|
|
*/
|
|
|
|
double_t cannonMinDistance;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The angle at which the cannon is shooting
|
|
|
|
*/
|
|
|
|
float_t cannonAngle;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The timeout between cannon shots
|
|
|
|
*/
|
|
|
|
float_t cannonTimeout;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The FOV while in the canon
|
|
|
|
*/
|
|
|
|
float_t cannonFOV;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parameters for the shooting gallery that don't change over time
|
|
|
|
*/
|
|
|
|
struct StaticShootingGalleryParams {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The position of the camera
|
|
|
|
*/
|
|
|
|
Vector3 cameraPosition;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The position that the camera is looking at
|
|
|
|
*/
|
|
|
|
Vector3 cameraLookatPosition;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A very ancient component that was used to guide shooting galleries, it's still kind of used but a lot of logic is
|
|
|
|
* also in the related scripts.
|
|
|
|
*/
|
2023-06-23 15:30:03 +00:00
|
|
|
class ShootingGalleryComponent : public ActivityComponent {
|
2021-12-05 17:54:36 +00:00
|
|
|
public:
|
2023-06-09 08:22:45 +00:00
|
|
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-27 05:39:15 +00:00
|
|
|
explicit ShootingGalleryComponent(Entity* parent, int32_t componentId);
|
2021-12-05 17:54:36 +00:00
|
|
|
~ShootingGalleryComponent();
|
|
|
|
void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Returns the static params for the shooting gallery
|
|
|
|
* @return the static params for the shooting gallery
|
|
|
|
*/
|
|
|
|
const StaticShootingGalleryParams& GetStaticParams() const { return m_StaticParams; };
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Sets the static parameters for the shooting gallery, see `StaticShootingGalleryParams`
|
|
|
|
* @param params the params to set
|
|
|
|
*/
|
|
|
|
void SetStaticParams(const StaticShootingGalleryParams& params);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Returns the dynamic params for the shooting gallery
|
|
|
|
* @return the dynamic params for the shooting gallery
|
|
|
|
*/
|
|
|
|
const DynamicShootingGalleryParams& GetDynamicParams() const { return m_DynamicParams; };
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Sets the mutable params for the shooting gallery, see `DynamicShootingGalleryParams`
|
|
|
|
* @param params the params to set
|
|
|
|
*/
|
|
|
|
void SetDynamicParams(const DynamicShootingGalleryParams& params);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Sets the entity that's currently playing the shooting gallery
|
|
|
|
* @param playerID the entity to set
|
|
|
|
*/
|
|
|
|
void SetCurrentPlayerID(LWOOBJID playerID) { m_CurrentPlayerID = playerID; m_Dirty = true; };
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Returns the player that's currently playing the shooting gallery
|
|
|
|
* @return the player that's currently playing the shooting gallery
|
|
|
|
*/
|
|
|
|
LWOOBJID GetCurrentPlayerID() const { return m_CurrentPlayerID; };
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The player that's currently playing the shooting gallery
|
|
|
|
*/
|
|
|
|
LWOOBJID m_CurrentPlayerID = LWOOBJID_EMPTY;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The static parameters for the shooting gallery, see `StaticShootingGalleryParams`
|
|
|
|
*/
|
|
|
|
StaticShootingGalleryParams m_StaticParams{};
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* The dynamic params for the shooting gallery, see `DynamicShootingGalleryParams`
|
|
|
|
*/
|
|
|
|
DynamicShootingGalleryParams m_DynamicParams{};
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the component should be serialized
|
|
|
|
*/
|
|
|
|
bool m_Dirty = false;
|
|
|
|
};
|