effectclock,bgm -> effect follows beat
effectoffset -> beat offset
This commit is contained in:
+29
-3
@@ -21,6 +21,8 @@
|
||||
#include "RageLog.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
|
||||
#include "GameState.h" /* XXX: ugly dependency */
|
||||
|
||||
/* This is Reset instead of Init since many derived classes have Init() functions
|
||||
* that shouldn't change the position of the actor. */
|
||||
void Actor::Reset()
|
||||
@@ -42,6 +44,8 @@ void Actor::Reset()
|
||||
m_Effect = no_effect;
|
||||
m_fSecsIntoEffect = 0;
|
||||
m_fEffectPeriodSeconds = 1;
|
||||
m_fEffectPerfectOffset = 0;
|
||||
m_EffectClock = CLOCK_TIMER;
|
||||
m_vEffectMagnitude = RageVector3(0,0,10);
|
||||
m_effectColor1 = RageColor(1,1,1,1);
|
||||
m_effectColor2 = RageColor(1,1,1,1);
|
||||
@@ -96,6 +100,9 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties
|
||||
m_tempState = m_current;
|
||||
|
||||
float fPercentThroughEffect = m_fSecsIntoEffect / m_fEffectPeriodSeconds;
|
||||
fPercentThroughEffect += m_fEffectPerfectOffset;
|
||||
fPercentThroughEffect = fmodfp( fPercentThroughEffect, 1 );
|
||||
|
||||
bool bBlinkOn = fPercentThroughEffect > 0.5f;
|
||||
float fPercentBetweenColors = (fPercentThroughEffect==0) ? 0 : (sinf( fPercentThroughEffect * 2 * PI ) / 2 + 0.5f);
|
||||
ASSERT( fPercentBetweenColors >= 0 && fPercentBetweenColors <= 1 );
|
||||
@@ -291,9 +298,18 @@ void Actor::Update( float fDeltaTime )
|
||||
case bounce:
|
||||
case bob:
|
||||
case pulse:
|
||||
m_fSecsIntoEffect += fDeltaTime;
|
||||
while( m_fSecsIntoEffect >= m_fEffectPeriodSeconds )
|
||||
m_fSecsIntoEffect -= m_fEffectPeriodSeconds;
|
||||
switch( m_EffectClock )
|
||||
{
|
||||
case CLOCK_TIMER:
|
||||
m_fSecsIntoEffect += fDeltaTime;
|
||||
m_fSecsIntoEffect = fmodfp( m_fSecsIntoEffect, m_fEffectPeriodSeconds );
|
||||
break;
|
||||
|
||||
case CLOCK_BGM:
|
||||
m_fSecsIntoEffect = GAMESTATE->m_fSongBeat;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case spin:
|
||||
m_current.rotation += fDeltaTime*m_vEffectMagnitude;
|
||||
@@ -422,6 +438,14 @@ void Actor::SetVertAlign( CString s )
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
void Actor::SetEffectClock( CString s )
|
||||
{
|
||||
s.MakeLower();
|
||||
if (s=="timer") SetEffectClock( CLOCK_TIMER );
|
||||
else if(s=="bgm") SetEffectClock( CLOCK_BGM );
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
void Actor::StretchTo( const RectI &r )
|
||||
{
|
||||
RectF r2( (float)r.left, (float)r.top, (float)r.right, (float)r.bottom );
|
||||
@@ -814,6 +838,8 @@ void Actor::HandleCommand( const CStringArray &asTokens )
|
||||
else if( sName=="effectcolor1" ) SetEffectColor1( cParam(1) );
|
||||
else if( sName=="effectcolor2" ) SetEffectColor2( cParam(1) );
|
||||
else if( sName=="effectperiod" ) SetEffectPeriod( fParam(1) );
|
||||
else if( sName=="effectoffset" ) SetEffectOffset( fParam(1) );
|
||||
else if( sName=="effectclock" ) SetEffectClock( sParam(1) );
|
||||
else if( sName=="effectmagnitude" ) SetEffectMagnitude( RageVector3(fParam(1),fParam(2),fParam(3)) );
|
||||
else if( sName=="scaletocover" ) { RectI R(iParam(1), iParam(2), iParam(3), iParam(4)); ScaleToCover(R); }
|
||||
else if( sName=="scaletofit" ) { RectI R(iParam(1), iParam(2), iParam(3), iParam(4)); ScaleToFitInside(R); }
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween );
|
||||
};
|
||||
|
||||
enum EffectClock { CLOCK_TIMER, CLOCK_BGM };
|
||||
|
||||
// let subclasses override
|
||||
virtual void Draw(); // calls, BeginDraw, DrawPrimitives, EndDraw
|
||||
virtual void BeginDraw(); // pushes transform onto world matrix stack
|
||||
@@ -216,6 +218,10 @@ public:
|
||||
void SetEffectColor1( RageColor c ) { m_effectColor1 = c; }
|
||||
void SetEffectColor2( RageColor c ) { m_effectColor2 = c; }
|
||||
void SetEffectPeriod( float fSecs ) { m_fEffectPeriodSeconds = fSecs; }
|
||||
void SetEffectOffset( float fPercent ) { m_fEffectPerfectOffset = fPercent; }
|
||||
void SetEffectClock( EffectClock c ) { m_EffectClock = c; }
|
||||
void SetEffectClock( CString s );
|
||||
|
||||
void SetEffectMagnitude( RageVector3 vec ) { m_vEffectMagnitude = vec; }
|
||||
|
||||
void SetEffectDiffuseBlink(
|
||||
@@ -335,6 +341,9 @@ protected:
|
||||
Effect m_Effect;
|
||||
float m_fSecsIntoEffect;
|
||||
float m_fEffectPeriodSeconds;
|
||||
float m_fEffectPerfectOffset;
|
||||
EffectClock m_EffectClock;
|
||||
|
||||
RageColor m_effectColor1;
|
||||
RageColor m_effectColor2;
|
||||
RageVector3 m_vEffectMagnitude;
|
||||
|
||||
Reference in New Issue
Block a user