File: BikeGhost.h

package info (click to toggle)
xmoto 0.5.11+dfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 80,908 kB
  • sloc: cpp: 96,757; ansic: 22,196; sh: 4,940; makefile: 1,073; yacc: 289; sed: 16
file content (133 lines) | stat: -rw-r--r-- 4,211 bytes parent folder | download | duplicates (2)
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
/*=============================================================================
XMOTO

This file is part of XMOTO.

XMOTO is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

XMOTO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with XMOTO; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
=============================================================================*/

#ifndef __BIKEGHOST_H__
#define __BIKEGHOST_H__

#include "Bike.h"

class Ghost : public Biker {
  public:
  Ghost(PhysicsSettings* i_physicsSettings,
	bool i_engineSound,
	Theme *i_theme, BikerTheme* i_bikerTheme,
	const TColor& i_colorFilter,
	const TColor& i_uglyColorFilter);
  ~Ghost();

  virtual bool diffToPlayerAvailable() const { return true; };
  virtual void updateDiffToPlayer(std::vector<float> &i_lastToTakeEntities) = 0;
  virtual bool isNetGhost() const { return false; };
  float diffToPlayer() const;
  virtual bool getRenderBikeFront();
  void setInfo(const std::string& i_info);

  void setReference(bool i_value);
  bool isReference() const;
  
  protected:
  float m_diffToPlayer; /* time diff between the ghost and the player */
  std::string m_info;
  bool m_reference;
};

class FileGhost : public Ghost {
 public:
  FileGhost(std::string i_replayFile,
	    PhysicsSettings* i_physicsSettings,
	    bool i_isActiv,
	    bool i_engineSound,
	    Theme *i_theme,
	    BikerTheme* i_bikerTheme,
	    const TColor& i_colorFilter,
	    const TColor& i_uglyColorFilter);
  ~FileGhost();

  std::string playerName();
  std::string levelId();
  int getFinishTime();
  void initLastToTakeEntities(Level* i_level);
  virtual void updateDiffToPlayer(std::vector<float> &i_lastToTakeEntities);
  virtual void updateToTime(int i_time, int i_timeStep,
			    CollisionSystem *i_collisionSystem, Vector2f i_gravity,
			    Scene *i_motogame);
  virtual bool isNetGhost() const { return false; };
  std::string getDescription() const;
  std::string getQuickDescription() const;
  std::string getVeryQuickDescription() const;
  float getBikeEngineSpeed();
  float getBikeLinearVel();
  float getTorsoVelocity();
  double getAngle();
  Replay* getReplay() { return m_replay; };

  virtual void initToPosition(Vector2f i_position, DriveDir i_direction, Vector2f i_gravity);

 protected:
  Replay* m_replay;

 private:
  std::vector<float> m_lastToTakeEntities;
  bool m_isActiv;
  double m_linearVelocity;
  bool m_teleportationOccured; // true if the teleportation occurred since the last update

 /* because we have not the real one, but the one before and the one after */
 std::vector<BikeState*> m_ghostBikeStates;

 void execReplayEvents(int i_time, Scene *i_motogame);
  
  //stuff needed for GhostTrail
 PhysicsSettings* m_pyhsicsSettings;
};

class ReplayBiker : public FileGhost {
 public:
  ReplayBiker(std::string i_replayFile, PhysicsSettings* i_physicsSettings,
	      bool i_engineSound,
	      Theme *i_theme, BikerTheme* i_bikerTheme);
  std::string getQuickDescription() const;
  std::string getVeryQuickDescription() const;
 private:
};

class NetGhost : public Ghost {
 public:
  NetGhost(PhysicsSettings* i_physicsSettings,
	   bool i_engineSound,
	   Theme *i_theme, BikerTheme* i_bikerTheme,
	   const TColor& i_colorFilter,
	   const TColor& i_uglyColorFilter);
  ~NetGhost();

  virtual bool diffToPlayerAvailable() const { return false; };
  virtual void updateDiffToPlayer(std::vector<float> &i_lastToTakeEntities);
  virtual bool isNetGhost() const { return true; };
  std::string getDescription() const;
  std::string getQuickDescription() const;
  std::string getVeryQuickDescription() const;
  float getBikeEngineSpeed();
  float getBikeLinearVel();
  float getTorsoVelocity();
  double getAngle();
 
 private:
};
#endif