File: WeaponProjectile.h

package info (click to toggle)
spring 88.0%2Bdfsg1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 41,524 kB
  • sloc: cpp: 343,114; ansic: 38,414; python: 12,257; java: 12,203; awk: 5,748; sh: 1,204; xml: 997; perl: 405; objc: 192; makefile: 181; php: 134; sed: 2
file content (78 lines) | stat: -rwxr-xr-x 2,170 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
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef WEAPON_PROJECTILE_H
#define WEAPON_PROJECTILE_H

#include "Sim/Projectiles/Projectile.h"

struct WeaponDef;
class CPlasmaRepulser;

/**
 * Base class for all projectiles originating from a weapon or having
 * weapon-properties. Uses data from a weapon definition.
 */
class CWeaponProjectile : public CProjectile
{
	CR_DECLARE(CWeaponProjectile);
public:
	enum {
		WEAPON_BASE_PROJECTILE           = (1 <<  0),
		WEAPON_BEAMLASER_PROJECTILE      = (1 <<  1),
		WEAPON_EMG_PROJECTILE            = (1 <<  2),
		WEAPON_EXPLOSIVE_PROJECTILE      = (1 <<  3),
		WEAPON_FIREBALL_PROJECTILE       = (1 <<  4),
		WEAPON_FLAME_PROJECTILE          = (1 <<  5),
		WEAPON_LARGEBEAMLASER_PROJECTILE = (1 <<  6),
		WEAPON_LASER_PROJECTILE          = (1 <<  7),
		WEAPON_LIGHTNING_PROJECTILE      = (1 <<  8),
		WEAPON_MISSILE_PROJECTILE        = (1 <<  9),
		WEAPON_STARBURST_PROJECTILE      = (1 << 10),
		WEAPON_TORPEDO_PROJECTILE        = (1 << 11),
	};

	CWeaponProjectile();
	CWeaponProjectile(const float3& pos, const float3& speed, CUnit* owner,
			CUnit* target, const float3& targetPos, const WeaponDef* weaponDef,
			CWeaponProjectile* interceptTarget, int ttl);
	virtual ~CWeaponProjectile() {}

	virtual void Collision();
	virtual void Collision(CFeature* feature);
	virtual void Collision(CUnit* unit);
	virtual void Update();
	/// @return 0=unaffected, 1=instant repulse, 2=gradual repulse
	virtual int ShieldRepulse(CPlasmaRepulser* shield, float3 shieldPos, float shieldForce, float shieldMaxSpeed) { return 0; }

	virtual void DrawOnMinimap(CVertexArray& lines, CVertexArray& points);

	/// true if we are a nuke and an anti is on the way
	bool targeted;
	const WeaponDef* weaponDef;
	std::string weaponDefName;
	CUnit* target;
	float3 targetPos;

	std::string cegTag;
	unsigned int cegID;

	int colorTeam;

protected:
	float3 startpos;

	int ttl;
	int bounces;
	bool keepBouncing;

	virtual void UpdateGroundBounce();

	bool TraveledRange();
	CWeaponProjectile* interceptTarget;

public:
	void DependentDied(CObject* o);
	void PostLoad();
};

#endif /* WEAPON_PROJECTILE_H */