# Housekeeping.

Jan and I implemented a number of changes:

- Converted SClassSet to vector.
- Refactored get/set ClassSet from string into methods in CClassSet.
- Turned pass-by-value string params in getCollisionObject, CEntity
constructor and CEntityManager into pointers.
- Simplified processChooseMovement.
- Merged CalculateRun and CalculateHealth into a single, simpler
CalculateRegen + helper functions.
- Changed the way regen works so the rates read in the XML act as rates
(before, they were the number of seconds until the entity will be fully
regenned, which is a bit counterintuitive).

This was SVN commit r4167.
This commit is contained in:
Matei
2006-07-24 01:33:26 +00:00
parent 1ce5ab6e0c
commit 2261231ffa
13 changed files with 237 additions and 195 deletions
+38 -29
View File
@@ -31,43 +31,52 @@ enum EGotoSituation
WOULD_LEAVE_MAP
};
bool CEntity::shouldRun(float distance)
{
if (!entf_get(ENTF_SHOULD_RUN))
return false;
// tired
if(m_staminaCurr <= 0)
return false;
if(distance >= m_runMaxRange)
return false;
// don't start running if less than minimum
if( distance <= m_runMinRange && !entf_get(ENTF_IS_RUNNING) )
return false;
return true;
}
float CEntity::processChooseMovement( float distance )
{
// Should we run or walk
if (entf_get(ENTF_SHOULD_RUN) && m_staminaCurr > 0 && distance < m_runMaxRange &&
( distance > m_runMinRange || entf_get(ENTF_IS_RUNNING) ) )
{
if ( m_actor )
{
if ( !m_actor->IsPlayingAnimation( "run" ) )
{
m_actor->SetEntitySelection( L"run" );
m_actor->SetRandomAnimation( "run", false, m_runSpeed );
bool should_run = shouldRun(distance);
const float speed = should_run? m_runSpeed : m_speed;
const char* anim_name = should_run? "run" : "walk";
// Animation desync
m_actor->GetModel()->Update( rand( 0, 1000 ) / 1000.0f );
entf_set(ENTF_IS_RUNNING);
}
}
return m_runSpeed;
}
else
// TODO: the animation code requires unicode for now. will be changed to
// 8bit later (for consistency; note that filenames etc. need not be
// unicode), so remove this then.
const CStrW u_anim_name = anim_name;
if ( m_actor )
{
if ( m_actor )
if ( !m_actor->IsPlayingAnimation( anim_name ) )
{
// Should we update animation?
if ( !m_actor->IsPlayingAnimation( "walk" ) )
{
m_actor->SetEntitySelection( L"walk" );
m_actor->SetRandomAnimation( "walk", false, m_speed );
m_actor->SetEntitySelection( u_anim_name );
m_actor->SetRandomAnimation( anim_name, false, speed );
// Animation desync
m_actor->GetModel()->Update( rand( 0, 1000 ) / 1000.0f );
entf_clear(ENTF_IS_RUNNING);
}
// Animation desync
m_actor->GetModel()->Update( rand( 0, 1000 ) / 1000.0f );
entf_set_to(ENTF_IS_RUNNING, should_run);
}
return m_speed;
}
return speed;
}
// Does all the shared processing for line-of-sight gotos