forked from 0ad/0ad
- Terrain conformance should now work in Atlas as well.
- Renamed Passive stance to Hold (which is what it's called in the design doc and GUI). This was SVN commit r4345.
This commit is contained in:
parent
58c159faa0
commit
6b73ba0296
@ -51,7 +51,7 @@ CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation,
|
||||
m_player = NULL;
|
||||
|
||||
m_productionQueue = new CProductionQueue( this );
|
||||
m_stance = new CPassiveStance( this );
|
||||
m_stance = new CHoldStance( this );
|
||||
|
||||
for( int t = 0; t < EVENT_LAST; t++ )
|
||||
{
|
||||
@ -109,7 +109,7 @@ CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation,
|
||||
m_visible = true;
|
||||
|
||||
m_associatedTerritory = 0;
|
||||
|
||||
|
||||
m_player = g_Game->GetPlayer( 0 );
|
||||
}
|
||||
|
||||
@ -287,6 +287,18 @@ void CEntity::snapToGround()
|
||||
m_graphics_position.Y = getAnchorLevel( m_graphics_position.X, m_graphics_position.Z );
|
||||
}
|
||||
|
||||
void CEntity::updateXZOrientation()
|
||||
{
|
||||
// Make sure m_ahead is correct
|
||||
m_ahead.x = sin( m_orientation.Y );
|
||||
m_ahead.y = cos( m_orientation.Y );
|
||||
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->getSlopeAngleFace(this);
|
||||
m_orientation.X = clamp( targetXZ.x, -m_base->m_anchorConformX, m_base->m_anchorConformX );
|
||||
m_orientation.Z = clamp( targetXZ.y, -m_base->m_anchorConformZ, m_base->m_anchorConformZ );
|
||||
m_orientation_unclamped.x = targetXZ.x;
|
||||
m_orientation_unclamped.y = targetXZ.y;
|
||||
}
|
||||
|
||||
jsval CEntity::getClassSet()
|
||||
{
|
||||
@ -816,9 +828,9 @@ void CEntity::stanceChanged()
|
||||
{
|
||||
m_stance = new CStandStance( this );
|
||||
}
|
||||
else
|
||||
else // m_stanceName == "hold" or undefined stance
|
||||
{
|
||||
m_stance = new CPassiveStance( this );
|
||||
m_stance = new CHoldStance( this );
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,6 +883,8 @@ void CEntity::interpolate( float relativeoffset )
|
||||
while( m_orientation.Z > m_orientation_previous.Z + PI )
|
||||
m_orientation_previous.Z += 2 * PI;
|
||||
|
||||
updateXZOrientation();
|
||||
|
||||
m_graphics_orientation = Interpolate<CVector3D>( m_orientation_previous, m_orientation, relativeoffset );
|
||||
|
||||
// Mark the actor transform data as invalid if the entity has moved since
|
||||
|
@ -312,6 +312,7 @@ public:
|
||||
|
||||
void snapToGround();
|
||||
void updateActorTransforms();
|
||||
void updateXZOrientation();
|
||||
|
||||
// Getter and setter for the class sets
|
||||
jsval getClassSet();
|
||||
|
@ -295,19 +295,8 @@ void CEntityManager::conformAll()
|
||||
{
|
||||
if( isEntityRefd(i) )
|
||||
{
|
||||
CEntity* entity = m_entities[i].m_entity;
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->getSlopeAngleFace(entity );
|
||||
|
||||
while( targetXZ.x > PI ) targetXZ.x -= 2 * PI;
|
||||
while( targetXZ.x < -PI ) targetXZ.x += 2 * PI;
|
||||
while( targetXZ.y > PI ) targetXZ.y -= 2 * PI;
|
||||
while( targetXZ.y < -PI ) targetXZ.y += 2 * PI;
|
||||
|
||||
entity->m_orientation.X = clamp( targetXZ.x, -entity->m_base->m_anchorConformX, entity->m_base->m_anchorConformX );
|
||||
entity->m_orientation.Z = clamp( targetXZ.y, -entity->m_base->m_anchorConformZ, entity->m_base->m_anchorConformZ );
|
||||
entity->m_orientation_unclamped.x = targetXZ.x;
|
||||
entity->m_orientation_unclamped.y = targetXZ.y;
|
||||
entity->updateActorTransforms();
|
||||
m_entities[i].m_entity->updateXZOrientation();
|
||||
m_entities[i].m_entity->updateActorTransforms();
|
||||
}
|
||||
}
|
||||
PROFILE_END("conform all");
|
||||
|
@ -152,21 +152,8 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
m_ahead = delta / len;
|
||||
m_orientation.Y = m_targetorientation;
|
||||
}
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->getSlopeAngleFace(this);
|
||||
|
||||
while( targetXZ.x > PI ) targetXZ.x -= 2 * PI;
|
||||
while( targetXZ.x < -PI ) targetXZ.x += 2 * PI;
|
||||
while( targetXZ.y > PI ) targetXZ.y -= 2 * PI;
|
||||
while( targetXZ.y < -PI ) targetXZ.y += 2 * PI;
|
||||
|
||||
float cX = m_base->m_anchorConformX, cZ = m_base->m_anchorConformZ;
|
||||
m_orientation.X = clamp( targetXZ.x, -cX, cX );
|
||||
m_orientation.Z = clamp( targetXZ.y, -cZ, cZ );
|
||||
m_orientation_unclamped.x = targetXZ.x;
|
||||
m_orientation_unclamped.y = targetXZ.y;
|
||||
|
||||
//CMovementEvent evt( m_orientation_unclamped.x );
|
||||
//DispatchEvent(&evt);
|
||||
updateXZOrientation();
|
||||
|
||||
if( m_bounds && m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
||||
((CBoundingBox*)m_bounds)->setOrientation( m_ahead );
|
||||
|
@ -36,13 +36,13 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Passive stance: Unit never attacks, not even to fight back.
|
||||
* Hold Fire stance: Unit never attacks, not even to fight back.
|
||||
**/
|
||||
class CPassiveStance : public CStance
|
||||
class CHoldStance : public CStance
|
||||
{
|
||||
public:
|
||||
CPassiveStance(CEntity* ent): CStance(ent) {};
|
||||
virtual ~CPassiveStance() {};
|
||||
CHoldStance(CEntity* ent): CStance(ent) {};
|
||||
virtual ~CHoldStance() {};
|
||||
virtual void onIdle() {};
|
||||
virtual void onDamaged(CEntity* UNUSED(source)) {};
|
||||
virtual bool allowsMovement() { return false; };
|
||||
|
Loading…
Reference in New Issue
Block a user