add lights as an effect source

This commit is contained in:
Glenn Maynard
2005-04-28 23:55:47 +00:00
parent f56990b3fb
commit 4bba3fbaa8
2 changed files with 44 additions and 3 deletions
+32 -1
View File
@@ -25,6 +25,19 @@ LUA_REGISTER_CLASS( Actor )
float Actor::g_fCurrentBGMTime = 0, Actor::g_fCurrentBGMBeat;
static float g_bCabinetLights[NUM_CABINET_LIGHTS];
void Actor::SetBGMTime( float fTime, float fBeat )
{
g_fCurrentBGMTime = fTime;
g_fCurrentBGMBeat = fBeat;
}
void Actor::SetBGMLights( const float *bCabinetLights )
{
memcpy( g_bCabinetLights, bCabinetLights, sizeof(float) * NUM_CABINET_LIGHTS );
}
/* 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()
@@ -476,6 +489,14 @@ void Actor::Update( float fDeltaTime )
m_fEffectDelta = g_fCurrentBGMTime - m_fSecsIntoEffect;
m_fSecsIntoEffect = g_fCurrentBGMTime;
break;
default:
if( m_EffectClock >= CLOCK_LIGHT_1 && m_EffectClock <= CLOCK_LIGHT_LAST )
{
int i = m_EffectClock - CLOCK_LIGHT_1;
m_fEffectDelta = g_bCabinetLights[i] - m_fSecsIntoEffect;
m_fSecsIntoEffect = g_bCabinetLights[i];
}
break;
}
// update effect
@@ -609,7 +630,17 @@ void Actor::SetEffectClockString( const CString &s )
else if(s.CompareNoCase("beat")==0) this->SetEffectClock( CLOCK_BGM_BEAT );
else if(s.CompareNoCase("music")==0) this->SetEffectClock( CLOCK_BGM_TIME );
else if(s.CompareNoCase("bgm")==0) this->SetEffectClock( CLOCK_BGM_BEAT ); // compat, deprecated
else ASSERT(0);
else
{
CabinetLight cl = StringToCabinetLight( s );
if( cl != LIGHT_INVALID )
{
this->SetEffectClock( (EffectClock) (cl + CLOCK_LIGHT_1) );
return;
}
else
ASSERT(0);
}
}
void Actor::StretchTo( const RectF &r )
+12 -2
View File
@@ -31,7 +31,8 @@ public:
virtual void Reset();
void LoadFromNode( const CString& sDir, const XNode* pNode );
static void SetBGMTime( float fTime, float fBeat ) { g_fCurrentBGMTime = fTime; g_fCurrentBGMBeat = fBeat; }
static void SetBGMTime( float fTime, float fBeat );
static void SetBGMLights( const float *abCabinetLights );
enum TweenType {
TWEEN_LINEAR,
@@ -66,7 +67,15 @@ public:
static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween );
};
enum EffectClock { CLOCK_TIMER, CLOCK_BGM_TIME, CLOCK_BGM_BEAT, NUM_CLOCKS };
enum EffectClock
{
CLOCK_TIMER,
CLOCK_BGM_TIME,
CLOCK_BGM_BEAT,
CLOCK_LIGHT_1 = 1000,
CLOCK_LIGHT_LAST = 1100,
NUM_CLOCKS
};
void Draw(); // calls, NeedsDraw, BeginDraw, DrawPrimitives, EndDraw
virtual bool EarlyAbortDraw() { return false; } // return true to early abort drawing of this Actor
@@ -448,6 +457,7 @@ protected:
//
static float g_fCurrentBGMTime, g_fCurrentBGMBeat;
private:
//
// commands
//