140 lines
6.0 KiB
C++
Executable File
140 lines
6.0 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 <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 <CentralEffectSimulation/aes_item_view_utm.h>
|
|
#include <LtsCoordinate/lts_coordinate.h>
|
|
|
|
#include <QtCore/QObject>
|
|
#include <QtCore/QMap>
|
|
#include <QtCore/QHash>
|
|
#include <QtCore/QVector>
|
|
#include <QPolygonF>
|
|
#include <QTimer>
|
|
|
|
namespace LtsUtils
|
|
{
|
|
class QPoint3D;
|
|
}
|
|
|
|
// AES-Handling for buildings
|
|
|
|
namespace CesBuildings
|
|
{
|
|
|
|
|
|
class HandlerAesData : public QObject
|
|
, protected Buildings::Interface::Ftc::SendCesHitOnBuildingReplyHandler
|
|
, protected Buildings::Interface::Ftc::SendCesHit3DonBuildingReplyHandler
|
|
, protected TrainingAreaBase::Interface::Ftc::SendCesHitInformationReplyHandler
|
|
, protected Buildings::Interface::Ftc::SetBuildingStatesReplyHandler
|
|
{
|
|
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); }
|
|
ProjectDataManagement::IgniterFunctionBase igniterFunctionBaseExplosionCluster(const int &aesId) const
|
|
{
|
|
auto chargeStruct = m_ddsHandler->dtcAes()->explosionCluster(aesId).chargeStruct();
|
|
return m_ddsHandler->dtcPdm()->getChargeTypeIgniterTypeIgniterFunction(chargeStruct.chargeTypeId(),
|
|
chargeStruct.igniterTypeId(),
|
|
chargeStruct.igniterFunctionId()).igniterFunctionBaseId();
|
|
}
|
|
int chargeTypeId(const int &aesId) const
|
|
{
|
|
return m_ddsHandler->dtcAes()->explosionCluster(aesId).chargeStruct().chargeTypeId();
|
|
}
|
|
|
|
protected:
|
|
void onSendCesHitOnBuildingReply(const Core::FunctionReplyObject &replyObject) override final;
|
|
void onSendCesHit3DonBuildingReply(const Core::FunctionReplyObject &replyObject) override final;
|
|
void onSendCesHitInformationReply(const Core::FunctionReplyObject &reply) override final;
|
|
void onSetBuildingStatesReply(const Core::FunctionReplyObject &reply) override final;
|
|
|
|
private slots:
|
|
/**
|
|
* Handle the signals from 'AES'
|
|
*/
|
|
void onChargeEffectChanged(const AreaEffectSimulation::ChargeEffect &data, DataModification modType);
|
|
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);
|
|
void onEffectsChanged(const AreaEffectSimulation::Effects &effects, DataModification modType);
|
|
void onBoobyTrapChanged(const AreaEffectSimulation::BoobyTrap &data, DataModification modType);
|
|
void onStartTimeReached();
|
|
|
|
void removeStates(const AreaEffectSimulation::AesItemView &data);
|
|
|
|
//private: // structs
|
|
|
|
// typedef QHash<int, QSet<int>> BitfieldStates; shift to aes_item_view_utm.h
|
|
|
|
private: // methoden
|
|
bool inFootprint(const Core::GeoPosition2D &geoPosition,
|
|
const CentralEffectSimulation::HandlerBuildingData::Footprint &footPrint,
|
|
const double radius) const;
|
|
|
|
bool inBoundingBox(const Core::GeoPosition2D& impactPosition,
|
|
const CentralEffectSimulation::HandlerBuildingData::Footprint &footprint,
|
|
const double impactRadius) const;
|
|
|
|
|
|
void preCalculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data);
|
|
void calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data,
|
|
const AreaEffectSimulation::AesItemView &aesItemView,
|
|
const CentralEffectSimulation::HandlerBuildingData::Footprint &footprint);
|
|
void calculateImpacts(const AreaEffectSimulation::Effects &effects,
|
|
const CentralEffectSimulation::HandlerBuildingData::Footprint &footprint);
|
|
|
|
void checkBuildingsHit(const AreaEffectSimulation::AesItemView &data);
|
|
|
|
QVector<int> findBuildingsBetween(const LtsCoordTrans::LtsCoordinate &impactPosition,
|
|
const CentralEffectSimulation::HandlerBuildingData::Footprint &targetFootprint);
|
|
void calculateBuildingExplosion(const AreaEffectSimulation::ChargeStruct &chargeStruct, const Core::GeoPosition2D &impactPosition, const int id);
|
|
void startTimer(int id, int msec);
|
|
|
|
private: // attributes
|
|
|
|
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
|
|
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
|
|
|
|
QHash<int, CentralEffectSimulation::BitfieldStates> m_bitfieldStatesBld; // key = mseId, value = BitfieldState
|
|
|
|
// AES-Values
|
|
QHash<int, AreaEffectSimulation::AesItemView> m_aesItemViews; // key = aesItemId
|
|
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_aesItemViewsUtm; // key = aesItemId
|
|
QHash<int, AreaEffectSimulation::AesEffectState> m_explosionSingleState; // key = id value = state
|
|
|
|
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
|
QHash<int, AreaEffectSimulation::ChargeEffect> m_chargeEffects; // key = onChargeEffectChanged.id value ChargeEffect
|
|
|
|
};
|
|
|
|
} // namespace CesBuildings
|
|
|