Files
qt5-legatus-legacy/Lts/Services/CentralEffectSimulation/Plugins/VirtualMines/handler_participant_booby_trap.h
T
2026-08-13 18:33:10 +02:00

101 lines
4.2 KiB
C++
Executable File

/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include <CentralEffectSimulation/logger.h>
#include <AreaEffectSimulation/aes_dtc.h>
#include <CentralEffectSimulation/aes_item_view_utm.h>
#include <CentralEffectSimulation/dds_handler.h>
#include <CentralEffectSimulation/handler_participant.h>
#include <QTimer>
#include <QObject>
#include <QHash>
#include <QRectF>
#include <QPolygonF>
// AES-Handling for participants
namespace CesVirtualMines
{
class HandlerParticipantBoobyTrap final : public QObject
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
, protected AreaEffectSimulation::Interface::Ftc::BoobyTrapTriggerReplyHandler
{
Q_OBJECT
public:
HandlerParticipantBoobyTrap(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
QObject *parent = nullptr);
~HandlerParticipantBoobyTrap();
/**
* Initialize the handler to manage information from player management
*/
bool init();
protected:
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
void onBoobyTrapTriggerReply(const Core::FunctionReplyObject &replyObject) override final;
private Q_SLOTS:
/**
* Handle the signals from 'ParticipantHandler'
*/
void onParticipantPositionChanged(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &partPos);
/**
* Handle the signals from 'AES'
*/
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data, DataModification modType);
void sendFtcBoobyTrapTrigger(int aesItemId);
/**
* Send Hit to participant
*/
void sendFtcCesHitRequestTimeout();
private: // methoden
void sendParticipantEvent(const CentralEffectSimulation::AesItemViewUtm &boobyTrapItem,
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
const ProjectDataManagement::EventType eventType);
void sendParticipantHit(const CentralEffectSimulation::AesItemViewUtm &boobyTrap,
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
const ProjectDataManagement::EventType eventType);
bool insideSecondaryArea(const QPolygonF &polygonf, const QPointF &participantPos) const;
bool enteredOrCrossedArea(const QPolygonF &polygonf, const QPolygonF &participantStep) const;
bool calculateBoobyTrapParticipant(const CentralEffectSimulation::AesItemViewUtm &aesItemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPos);
void calculateBoobyTrapParticipantSecondary(const CentralEffectSimulation::AesItemViewUtm &aesItemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPos);
void calculateBoobyTrapParticipantsSecondary(int aesItemId, int participantId);
bool intersectsBoundingBoxCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const int participantId);
private: // attributes
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
// AES-Values
QHash<int, AreaEffectSimulation::BoobyTrap> m_boobyTraps;
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_boobyTrapItems; // key = aesItemId
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_boobyTrapItemsSecondary; // key = aesItemId
QHash<int, int> m_triggeredMineParticipant; // key = aesItemId, value = participantId
QHash<int, TrainingAreaBase::SendCesHitRequest> m_requestMap; // Key = equipmentNumber
QTimer *m_timer;
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
};
} // namespace CesVirtualMines