-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathCNinjaRope.h
147 lines (107 loc) · 2.94 KB
/
CNinjaRope.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/////////////////////////////////////////
//
// OpenLieroX
//
// code under LGPL, based on JasonBs work,
// enhanced by Dark Charlie and Albert Zeyer
//
//
/////////////////////////////////////////
// Ninja rope class
// Created 6/2/02
// Jason Boettcher
#ifndef __CNINJAROPE_H__
#define __CNINJAROPE_H__
#include "game/CGameObject.h"
#include "gusanos/events.h"
#include "CVec.h"
#include "util/angle.h"
#include "gusanos/timer_event.h"
#include "gusanos/particle.h"
#include <vector>
// Rope types
#define ROP_NONE 0x00
#define ROP_SHOOTING 0x01
#define ROP_HOOKED 0x02
#define ROP_FALLING 0x04
#define ROP_PLYHOOKED 0x08
#ifndef DEDICATED_ONLY
class SpriteSet;
class BaseAnimator;
#endif
#include "CVec.h"
class CWorm;
struct SDL_Surface;
class CBytestream;
class CNinjaRope : public CGameObject {
public:
CNinjaRope();
~CNinjaRope();
virtual BaseObject* parentObject() const;
CWorm* owner() const;
private:
ATTR(CNinjaRope, bool, Released, 1, {serverside = false;})
ATTR(CNinjaRope, bool, HookShooting, 2, {serverside = false;})
ATTR(CNinjaRope, bool, HookAttached, 3, {serverside = false;})
ATTR(CNinjaRope, int, PlayerAttached, 4, { serverside = false; defaultValue = -1; })
public:
// Methods
void Clear();
void Draw(SDL_Surface * bmpDest, CViewport *view, CVec ppos, bool drawHook) const;
void Shoot(CVec dir);
CVec GetForce() const;
bool isReleased() const { return Released; }
void UnAttachPlayer();
void AttachToPlayer(CWorm *worm);
void Attach();
void write(CBytestream *bs) const;
void read(CBytestream *bs, int owner);
CVec getHookPos() const { return getPos(); }
bool isAttached() const { return HookAttached; }
bool isShooting() const { return HookShooting; }
void setShooting(bool s) { HookShooting = s; }
void setAttached(bool a) { HookAttached = a; }
vVelocity_Type& hookVelocity() { return velocity(); }
vPos_Type& hookPos() { return pos(); }
bool isPlayerAttached() const;
CWorm* getAttachedPlayer() const;
void checkForWormAttachment();
virtual bool isInside(int x, int y) const;
virtual Color renderColorAt(/* relative coordinates */ int x, int y) const;
// ----------------------
// --------- Gusanos
// ----------------------
public:
static LuaReference metaTable;
void gusInit();
void remove() { Clear(); /* but dont delete */ }
#ifndef DEDICATED_ONLY
void draw(CViewport *viewport);
#endif
void think();
Angle getPointingAngle();
void addAngleSpeed(AngleDiff);
void addLength(float length_)
{
m_length += length_;
if ( m_length < 0.f )
m_length = 0.f;
}
int getColour() const;
float& getLengthReference()
{
return m_length;
}
void deleteThis();
private:
std::vector< TimerEvent::State > timer;
Angle m_angle;
AngleDiff m_angleSpeed;
float m_length;
#ifndef DEDICATED_ONLY
SpriteSet* m_sprite;
BaseAnimator* m_animator;
#endif
bool justCreated;
};
#endif // __CNINJAROPE_H__