Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+155
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CentralEffectSimulation/logger.h>
|
||||
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/aes_item_view_utm.h>
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QQueue>
|
||||
#include <QtCore/QPointF>
|
||||
#include <QtGui/QPolygonF>
|
||||
|
||||
// AES-Handling for participants
|
||||
namespace CesMineAreas
|
||||
{
|
||||
enum class EffectType
|
||||
{
|
||||
Unknown = 0,
|
||||
EffectiveMineRangeEnter = 0xf0000 | 1, // AtMineAreaSingleMines = 15 = 0xf
|
||||
EffectiveMineRangeLeave = 0xf0000 | 2, // AtMineAreaSingleMines = 15 = 0xf
|
||||
NContaminationLeave = 0x10000 | 0, // AtNContamination = 1
|
||||
NContaminationEnterArea1 = 0x10000 | 1,
|
||||
NContaminationEnterArea2 = 0x10000 | 2,
|
||||
NContaminationDetonation = 0x10000 | 255,
|
||||
FunctionalAreaLeave = 0xc0000 | 0, // AtReconArea = 12 = 0xc
|
||||
FunctionalAreaEnter = 0xc0000 | 1,
|
||||
ExplosionArea = 0x30000 | 2, // AtExplosionArea = 3
|
||||
ExplosionSingle = 0x40000 | 3, // AtExplosionSingle = 4
|
||||
BCContaminationLeave = 0x20000 | 0, // AtBCContamination = 2
|
||||
BCContaminationEnterFloating = 0x20000 | 1,
|
||||
BCContaminationEnterResident = 0x20000 | 2,
|
||||
BCContaminationEnterFloatingArea = 0x20000 | 3,
|
||||
BeStillWarning = 11,
|
||||
};
|
||||
QString toString(EffectType et);
|
||||
|
||||
struct MineListItem
|
||||
{
|
||||
int aesItemId;
|
||||
qint64 time;
|
||||
qreal distance; // distance from last Position to mine
|
||||
int mineIndex;
|
||||
QPointF minePos;
|
||||
};
|
||||
|
||||
class HandlerMineAreas final: public QObject
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
|
||||
, protected AreaEffectSimulation::Interface::Ftc::MineTriggeredReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HandlerMineAreas(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerMineAreas();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
|
||||
protected:
|
||||
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onMineTriggeredReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Handle the signals from 'AES'
|
||||
*/
|
||||
void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
|
||||
void onTriggeredImpactsChanged(const AreaEffectSimulation::TriggeredImpacts &data, DataModification modType);
|
||||
void sendFtcMineTrigger(int aesItemId, int mineIndex);
|
||||
|
||||
private: // methoden
|
||||
void calculateImpacts(const AreaEffectSimulation::TriggeredImpacts &data);
|
||||
void calculateImpacts(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const QVector<int> &impactsToCheck,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
void onNewOutdoorPosition(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
void onNewParticipantState(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPos);
|
||||
|
||||
// Checks if a mine has been crossed.
|
||||
// If so, the mine with the smallest distance to the last position should be taken.
|
||||
bool intersectMineRadiusCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
|
||||
qreal crossCircle(const QPointF ¢erUtm, const double radius, const int participantId, int zone);
|
||||
bool inCircle(const QPointF ¢erUtm, const double radius, const QPointF &pointUtm);
|
||||
bool intersectsBoundingBoxCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const int participantId);
|
||||
bool inBoundingBoxCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
bool inFormCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition);
|
||||
bool inExtededFormCheck(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition) const;
|
||||
double distancePointLine(const QPointF &p, const QPointF &l1,
|
||||
const QPointF &l2) const;
|
||||
double squareLen(const QPointF &p1, const QPointF &p2) const;
|
||||
|
||||
bool intersectFormCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const int participantId);
|
||||
void sendCesHitRequest(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
qint64 effectTime,
|
||||
int mineFieldBitIndex = 0);
|
||||
void sendCesHitRequest(const AreaEffectSimulation::AesItemView &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
qint64 effectTime,
|
||||
int mineFieldBitIndex = 0);
|
||||
void sendParticipantEventEnterLeave(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
const bool inFormCheckResult);
|
||||
void sendParticipantEvent(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition, const ProjectDataManagement::EventType eventType);
|
||||
void sendEffectTypeEvent(const CentralEffectSimulation::AesItemViewUtm &itemView,
|
||||
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPosition,
|
||||
EffectType effectType,
|
||||
int mineFieldBitIndex,
|
||||
qint64 effectTime);
|
||||
|
||||
ProjectDataManagement::EventType leaveEventTypeForAesType(AreaEffectSimulation::AesType aesTypeId);
|
||||
EffectType leaveEffectTypeForAesType(AreaEffectSimulation::AesType aesTypeId);
|
||||
|
||||
void aesItemViewRemoved(int aesItemId);
|
||||
|
||||
void printAesItemViews();
|
||||
private: // attributes
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
|
||||
|
||||
QHash<int32_t, int> m_aesItemId2partIdMap;
|
||||
QHash<int, AreaEffectSimulation::TriggeredImpacts> m_triggeredImpacts; // key = aesItemId
|
||||
|
||||
|
||||
// AES-Values
|
||||
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_aesItemViews; // key = aesItemId
|
||||
QQueue<TrainingAreaBase::SendCesHitRequest> m_sendCesHitRequestQueue;
|
||||
QHash<int, QHash<int, ProjectDataManagement::EventType>> m_eventStates; // QHash<aesItemId, QHash<participantId, QSet<EventType>>>
|
||||
QHash<int, QHash<int, QSet<EffectType>>> m_effectTypeStates; // QHash<aesItemId, QHash<participantId, QSet<effectStates>>>
|
||||
QHash<int, QHash<int, QSet<int>>> m_effectTypeBitFieldIndexes; // QHash<aesItemId, QHash<participantId, QSet<mineFieldBitIdx>>>
|
||||
QHash<int, QVector<MineListItem>> m_mineLists; // Key = ParticipantId
|
||||
|
||||
|
||||
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
} // namespace CesMineAreas
|
||||
|
||||
Reference in new issue
Block a user