1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef SELECTED_UNITS_AI_H
#define SELECTED_UNITS_AI_H
#include "Sim/Units/CommandAI/Command.h"
#include "System/float3.h"
#include <vector>
class CUnit;
/// handles giving commands to the currently selected group of units.
class CSelectedUnitsHandlerAI {
public:
bool GiveCommandNet(Command& c, int playerNum);
private:
void CalculateGroupData(int playerNum, bool queueing);
void MakeFormationFrontOrder(Command* c, int playerNum);
void CreateUnitOrder(std::vector< std::pair<float, int> >& out, int playerNum);
float3 MoveToPos(float3 nextCornerPos, float3 dir, const CUnit* unit, Command* command, std::vector<std::pair<int, Command> >* frontcmds, bool* newline);
void SetUnitWantedMaxSpeedNet(CUnit* unit);
void SetUnitGroupWantedMaxSpeedNet(CUnit* unit);
bool SelectAttackNet(const Command& cmd, int playerNum);
void SelectCircleUnits(const float3& pos, float radius, int playerNum, std::vector<int>& units);
void SelectRectangleUnits(const float3& pos0, const float3& pos1, int playerNum, std::vector<int>& units);
float3 LastQueuePosition(const CUnit* unit);
private:
float3 groupCenterCoor;
float3 formationCenterPos;
float3 formationRightPos;
float groupSumLength = 0.0f;
float groupAvgLength = 0.0f;
float groupFrontLength = 0.0f;
float groupAddedSpace = 0.0f;
float groupMinMaxSpeed = 0.0f;
float groupColumnDist = 64.0f;
std::vector< std::pair<float, int> > sortedUnitPairs; // <priority, unitID>
std::vector< std::pair<float, std::vector<int>> > sortedUnitGroups;
std::vector< std::pair<int, Command> > frontMoveCommands;
std::vector<size_t> mixedUnitIDs;
std::vector<size_t> mixedGroupSizes;
std::vector<int> targetUnitIDs;
};
extern CSelectedUnitsHandlerAI selectedUnitsAI;
#endif // SELECTED_UNITS_AI_H
|