File: TransportCAI.h

package info (click to toggle)
spring 98.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 41,928 kB
  • ctags: 60,665
  • sloc: cpp: 356,167; ansic: 39,434; python: 12,228; java: 12,203; awk: 5,856; sh: 1,719; xml: 997; perl: 405; php: 253; objc: 194; makefile: 72; sed: 2
file content (83 lines) | stat: -rw-r--r-- 2,567 bytes parent folder | download
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef TRANSPORT_CAI_H
#define TRANSPORT_CAI_H

#include "MobileCAI.h"
#include "System/float3.h"

#include <list>
#include <vector>

#define UNLOAD_LAND 0
#define UNLOAD_DROP 1
#define UNLOAD_LANDFLOOD 2
#define UNLOAD_CRASHFLOOD 3

class CTransportUnit;
class CUnit;
class CFeature;
struct Command;

class CTransportCAI : public CMobileCAI
{
public:
	CR_DECLARE(CTransportCAI)
	CTransportCAI(CUnit* owner);
	CTransportCAI();
	~CTransportCAI();

	void SetTransportee(CUnit* unit);
	void GiveCommandReal(const Command& c, bool fromSynced = true);
	void SlowUpdate();

	bool CanTransport(const CUnit* unit) const;
	bool FindEmptySpot(const float3& center, float radius, float spread, float3& found, const CUnit* unitToUnload, bool fromSynced = true);
	bool FindEmptyDropSpots(float3 startpos, float3 endpos, std::list<float3>& dropSpots);
	bool FindEmptyFloodSpots(float3 startpos, float3 endpos, std::list<float3>& dropSpots, std::vector<float3> exitDirs);
	CUnit* FindUnitToTransport(float3 center, float radius);
	int GetDefaultCmd(const CUnit* pointed, const CFeature* feature);
	void FinishCommand();
	bool IsBusyLoading(const CUnit* unit) const;
	bool LoadStillValid(CUnit* unit);

	virtual void ExecuteUnloadUnit(Command& c);
	virtual void ExecuteUnloadUnits(Command& c);
	virtual void ExecuteLoadUnits(Command& c);

	int unloadType;
	int toBeTransportedUnitId;
	int lastCall;

private:
	void UnloadUnits_Land(Command& c, CTransportUnit* transport);
	void UnloadUnits_Drop(Command& c, CTransportUnit* transport);
	void UnloadUnits_LandFlood(Command& c, CTransportUnit* transport);
	void UnloadUnits_CrashFlood(Command& c, CTransportUnit* transport); // FIXME incomplete

	void UnloadNormal(Command& c);
	void UnloadLand(Command& c);
	/// parachute drop units
	void UnloadDrop(Command& c);
	/// land and dispatch units all at once
	void UnloadLandFlood(Command& c);
	/// slam into landscape abruptly and dispatch units all at once (incomplete)
	void UnloadCrashFlood(Command& c);

	virtual bool AllowedCommand(const Command& c, bool fromSynced);
	bool SpotIsClear(float3 pos, CUnit* u);
	/**
	 * This is a version of SpotIsClear that ignores the tranport and all
	 * units it carries.
	 */
	bool SpotIsClearIgnoreSelf(float3 pos, CUnit* unitToUnload);
	std::list<float3> dropSpots;
	bool isFirstIteration;
	float3 startingDropPos;
	float3 lastDropPos;
	/// direction from which we travel to drop point
	float3 approachVector;
	float3 endDropPos;
};

#endif /* TRANSPORT_CAI_H */