Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
autodocking.h
Go to the documentation of this file.
1
// -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2
3
#ifndef VEGASTRIKE_CMD_AI_AUTODOCKING_H
4
#define VEGASTRIKE_CMD_AI_AUTODOCKING_H
5
6
#include <deque>
7
#include <boost/shared_ptr.hpp>
8
#include "
cmd/ai/order.h
"
9
10
class
Unit
;
11
class
QVector
;
12
13
namespace
Orders
14
{
15
16
// Navigate the player to the closest auto-dockable port.
17
//
18
// If the station is too far away, the normal auto pilot will move the player
19
// to the station.
20
//
21
// An auto-dockable port may have a row of waypoints associated with it. This
22
// order will face and move towards the first waypoint. When this is reached,
23
// it will face and move towards the next waypoint, and so on until the docking
24
// port is reached.
25
//
26
// When the docking port is reached the player is docked at the station.
27
//
28
// Pre-condition:
29
// o A station has been selected.
30
// o Docking clearance has been obtained.
31
// o The station has at least one docking port that is auto-dockable, available,
32
// and big enough to fit the player.
33
// o The nearest available docking port must be in line-of-sight.
34
//
35
// Post-condition:
36
// o One of
37
// - The player has been docked.
38
// - No suitable docking port is available.
39
// - The player or the station has been destroyed.
40
//
41
// Limitations:
42
// o The player moves directly towards the first waypoint. If the station is
43
// between the player and the waypoint, the player will collide with the
44
// station.
45
// o If auto-docking is disengaged after travelling through a couple of
46
// waypoints and then re-engaged, then the player will start by moving directly
47
// towards the first waypoint.
48
// o The player cannot auto-dock on capital ships. It cannot handle moving
49
// stations, and it does not request clearance at fixed intervals to prevent
50
// the capital ship from moving away.
51
// o Cannot dock capital ships. A capital ship must align one of its docking
52
// ports with one of the station's docking ports to dock, and this order does
53
// not do that.
54
55
class
AutoDocking
:
public
Order
56
{
57
typedef
void (
AutoDocking
::*StateFunction)(
Unit
*,
Unit
*);
58
59
public
:
60
typedef
std::deque<size_t>
DockingPath
;
61
62
AutoDocking
(
Unit
*destination);
63
64
void
Execute
();
65
66
static
bool
CanDock
(
Unit
*player,
Unit
*station);
67
68
protected
:
69
// States
70
void
InitialState
(
Unit
*player,
Unit
*station);
71
void
SelectionState
(
Unit
*,
Unit
*);
72
void
ApproachState
(
Unit
*,
Unit
*);
73
void
DockingState
(
Unit
*,
Unit
*);
74
void
DockedState
(
Unit
*,
Unit
*);
75
void
UndockingState
(
Unit
*,
Unit
*);
76
void
DepartureState
(
Unit
*,
Unit
*);
77
void
AbortState
(
Unit
*,
Unit
*);
78
void
EndState
(
Unit
*,
Unit
*);
79
80
void
EnqueuePort
(
Unit
*,
Unit
*,
size_t
);
81
void
EraseOrders
();
82
83
private
:
84
StateFunction state;
85
UnitContainer
target;
86
// waypoints followed by docking port (back)
87
DockingPath
dockingPath;
88
};
89
90
}
// namespace Orders
91
92
#endif
src
cmd
ai
autodocking.h
Generated on Fri May 29 2015 23:07:07 for Vegastrike 0.5.1 rc1 by
1.8.4