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

121 lines
3.9 KiB
C++
Executable File

/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include "logger.h"
#include <AreaEffectSimulation/aes_dtc.h>
#include <Buildings/bld_dtc.h>
#include <Buildings/bld_ftc.h>
#include <ProjectDataManagement/pdm_dtc.h>
#include <TrainingAreaBase/tab_ftc.h>
#include <CentralEffectSimulation/dds_handler.h>
#include <CentralEffectSimulation/handler_building_data.h>
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QHash>
#include <QtCore/QVector>
#include <QPolygonF>
namespace LtsUtils
{
class QPoint3D;
}
// AES-Handling for buildings
namespace Ces2D
{
class HandlerAesData : public QObject
, protected Buildings::Interface::Ftc::SendCesHitOnBuildingReplyHandler
, protected TrainingAreaBase::Interface::Ftc::SendCesHitInformationReplyHandler
{
Q_OBJECT
public:
explicit HandlerAesData(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &buildingDataHandler,
QObject *parent = nullptr);
~HandlerAesData();
/**
* Initialize the handler to manage information from player management
*/
bool init();
AreaEffectSimulation::AesItemView itemView(const int &aesId) const { return m_aesItemViews.value(aesId); }
protected:
void onSendCesHitOnBuildingReply(const Core::FunctionReplyObject &replyObject) override final;
void onSendCesHitInformationReply(const Core::FunctionReplyObject &reply) override final;
private slots:
/**
* Handle the signals from 'AES'
*/
void onExplosionSingleChanged(const AreaEffectSimulation::ExplosionSingle &data, DataModification modType);
void onAirSupportImpactChanged(const AreaEffectSimulation::AirSupportImpact &data, DataModification modType);
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
void onTriggeredImpactsChanged(const AreaEffectSimulation::TriggeredImpacts &data, DataModification modType);
/**
* Handle MainFootprint from 'ISM'
*/
void onMainFootprintChanged(const InfrastructureManagement::MainFootprint &data, DataModification modType);
void removeStates(const AreaEffectSimulation::AesItemView &data);
private: // structs
struct Footprint
{
int mseId = -1;
int zone = -1;
Core::GeoPosition geoPosition;
QPolygonF polyUtm;
QRectF boundingBoxPolyUtm;
bool isValid() const { return mseId > 0; }
};
typedef QHash<int, QSet<int>> BitfieldStates;
private: // methoden
void handleExplosionSingleCentral(const AreaEffectSimulation::AesItemView &itemView);
void calculateFootprint(const InfrastructureManagement::MainFootprint &mainFootprint);
bool inFootprint(const Core::GeoPosition2D &geoPosition, const double radius, const Footprint &footPrint) const;
void preCalculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data);
void calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data, const Footprint &footprint);
double getRadiusOfMunition(const int32_t chargeTypeId) const;
private: // attributes
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
QHash<int, Footprint> m_footprints; // key = footprint.mseId
QHash<int, BitfieldStates> m_bitfieldStatesBld; // key = mseId, value = BitfieldState
// AES-Values
QHash<int, AreaEffectSimulation::AesItemView> m_aesItemViews; // key = aesItemId
QHash<int, AreaEffectSimulation::AesEffectState> m_explosionSingleState; // key = id value = state
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
};
} // namespace Ces2D