Add code for copying check structures
This commit is contained in:
parent
3d13686af7
commit
f325a0fa14
@ -57,6 +57,7 @@ CheckCannon::CheckCannon(const XMLNode &node, unsigned int index)
|
|||||||
/*reverse*/race_manager->getReverseTrack());
|
/*reverse*/race_manager->getReverseTrack());
|
||||||
|
|
||||||
#if defined(DEBUG) && !defined(SERVER_ONLY)
|
#if defined(DEBUG) && !defined(SERVER_ONLY)
|
||||||
|
m_show_curve = NULL;
|
||||||
if(UserConfigParams::m_track_debug)
|
if(UserConfigParams::m_track_debug)
|
||||||
{
|
{
|
||||||
m_show_curve = new ShowCurve(0.5f, 0.5f);
|
m_show_curve = new ShowCurve(0.5f, 0.5f);
|
||||||
@ -98,8 +99,7 @@ CheckCannon::~CheckCannon()
|
|||||||
{
|
{
|
||||||
delete m_curve;
|
delete m_curve;
|
||||||
#if defined(DEBUG) && !defined(SERVER_ONLY)
|
#if defined(DEBUG) && !defined(SERVER_ONLY)
|
||||||
if(UserConfigParams::m_track_debug)
|
delete m_show_curve;
|
||||||
delete m_show_curve;
|
|
||||||
if (m_debug_target_dy_dc)
|
if (m_debug_target_dy_dc)
|
||||||
m_debug_target_dy_dc->removeFromSP();
|
m_debug_target_dy_dc->removeFromSP();
|
||||||
#endif
|
#endif
|
||||||
@ -173,3 +173,17 @@ void CheckCannon::update(float dt)
|
|||||||
flyable->setAnimation(animation);
|
flyable->setAnimation(animation);
|
||||||
} // for i in all flyables
|
} // for i in all flyables
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
CheckStructure* CheckCannon::clone()
|
||||||
|
{
|
||||||
|
CheckCannon* cc = new CheckCannon(*this);
|
||||||
|
#if defined(DEBUG) && !defined(SERVER_ONLY)
|
||||||
|
// Remove unsupported stuff when cloning
|
||||||
|
cc->m_show_curve = NULL;
|
||||||
|
cc->m_debug_target_dy_dc = nullptr;
|
||||||
|
#endif
|
||||||
|
// IPO curve needs to be copied manually
|
||||||
|
cc->m_curve = m_curve->clone();
|
||||||
|
return cc;
|
||||||
|
} // clone
|
||||||
|
@ -52,7 +52,7 @@ private:
|
|||||||
/** Stores the cannon curve data. */
|
/** Stores the cannon curve data. */
|
||||||
Ipo *m_curve;
|
Ipo *m_curve;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#if defined(DEBUG) && !defined(SERVER_ONLY)
|
||||||
/** If track debugging is enabled, this will show the the curve of
|
/** If track debugging is enabled, this will show the the curve of
|
||||||
* the cannon in the race. */
|
* the cannon in the race. */
|
||||||
ShowCurve* m_show_curve;
|
ShowCurve* m_show_curve;
|
||||||
@ -90,6 +90,8 @@ public:
|
|||||||
const Vec3& getTargetRight() const { return m_target_right; }
|
const Vec3& getTargetRight() const { return m_target_right; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
Ipo* getIpo() const { return m_curve; }
|
Ipo* getIpo() const { return m_curve; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone() OVERRIDE;
|
||||||
}; // CheckCannon
|
}; // CheckCannon
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,6 +65,15 @@ public:
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
/** Returns the square of the radius of this sphere. */
|
/** Returns the square of the radius of this sphere. */
|
||||||
float getRadius2() const { return m_radius2; }
|
float getRadius2() const { return m_radius2; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone()
|
||||||
|
{
|
||||||
|
CheckCylinder* cc = new CheckCylinder(*this);
|
||||||
|
// Drop unneeded stuff ( trigger function is not supported in server,
|
||||||
|
// no scripting atm)
|
||||||
|
cc->m_triggering_function = nullptr;
|
||||||
|
return cc;
|
||||||
|
}
|
||||||
}; // CheckCylinder
|
}; // CheckCylinder
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,13 +69,16 @@ public:
|
|||||||
virtual void reset(const Track &track) OVERRIDE;
|
virtual void reset(const Track &track) OVERRIDE;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool getTeam() const { return m_first_goal; }
|
bool getTeam() const { return m_first_goal; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const Vec3& getPoint(PointLocation point) const
|
const Vec3& getPoint(PointLocation point) const
|
||||||
{
|
{
|
||||||
return (point == POINT_LAST ? m_p3 :
|
return (point == POINT_LAST ? m_p3 :
|
||||||
(point == POINT_CENTER ? m_p2 : m_p1));
|
(point == POINT_CENTER ? m_p2 : m_p1));
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone() OVERRIDE
|
||||||
|
{ return new CheckGoal(*this); }
|
||||||
}; // CheckGoal
|
}; // CheckGoal
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,7 +44,9 @@ public:
|
|||||||
int indx) OVERRIDE;
|
int indx) OVERRIDE;
|
||||||
virtual void reset(const Track &track) OVERRIDE;
|
virtual void reset(const Track &track) OVERRIDE;
|
||||||
virtual bool triggeringCheckline() const OVERRIDE { return true; }
|
virtual bool triggeringCheckline() const OVERRIDE { return true; }
|
||||||
}; // CheckLine
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone() OVERRIDE { return new CheckLap(*this); }
|
||||||
|
}; // CheckLap
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -109,7 +109,14 @@ public:
|
|||||||
const Vec3 &getLeftPoint() const { return m_left_point; }
|
const Vec3 &getLeftPoint() const { return m_left_point; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const Vec3 &getRightPoint() const { return m_right_point; }
|
const Vec3 &getRightPoint() const { return m_right_point; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone() OVERRIDE
|
||||||
|
{
|
||||||
|
CheckLine* cl = new CheckLine(*this);
|
||||||
|
// Drop unneeded stuff
|
||||||
|
cl->m_debug_dy_dc = nullptr;
|
||||||
|
return cl;
|
||||||
|
}
|
||||||
}; // CheckLine
|
}; // CheckLine
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,6 +59,8 @@ public:
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
/** Returns the square of the radius of this sphere. */
|
/** Returns the square of the radius of this sphere. */
|
||||||
float getRadius2() const { return m_radius2; }
|
float getRadius2() const { return m_radius2; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone() { return new CheckSphere(*this); }
|
||||||
}; // CheckSphere
|
}; // CheckSphere
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -146,6 +146,9 @@ public:
|
|||||||
void restoreIsActive(int kart_id, const BareNetworkString& b);
|
void restoreIsActive(int kart_id, const BareNetworkString& b);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
int getIndex() const { return m_index; }
|
int getIndex() const { return m_index; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Clone to child process for server usage (atm no sound or scripting). */
|
||||||
|
virtual CheckStructure* clone() = 0;
|
||||||
}; // CheckStructure
|
}; // CheckStructure
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,7 +38,7 @@ private:
|
|||||||
const float m_distance2;
|
const float m_distance2;
|
||||||
|
|
||||||
/** Function to call when triggered. */
|
/** Function to call when triggered. */
|
||||||
const std::function<void(int)> m_triggering_function;
|
std::function<void(int)> m_triggering_function;
|
||||||
|
|
||||||
/** Time since last trigger, if any triggering between 2 seconds ignored
|
/** Time since last trigger, if any triggering between 2 seconds ignored
|
||||||
* (like items). */
|
* (like items). */
|
||||||
@ -55,10 +55,20 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
virtual void trigger(unsigned int kart_index) OVERRIDE
|
virtual void trigger(unsigned int kart_index) OVERRIDE
|
||||||
{
|
{
|
||||||
|
if (!m_triggering_function) return;
|
||||||
m_triggering_function(kart_index);
|
m_triggering_function(kart_index);
|
||||||
CheckStructure::trigger(kart_index);
|
CheckStructure::trigger(kart_index);
|
||||||
}
|
}
|
||||||
}; // CheckSphere
|
// ------------------------------------------------------------------------
|
||||||
|
virtual CheckStructure* clone() OVERRIDE
|
||||||
|
{
|
||||||
|
CheckTrigger* ct = new CheckTrigger(*this);
|
||||||
|
// Drop unneeded stuff ( trigger function is not supported in server,
|
||||||
|
// no scripting atm)
|
||||||
|
ct->m_triggering_function = nullptr;
|
||||||
|
return ct;
|
||||||
|
}
|
||||||
|
}; // CheckTrigger
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user