Some syntax sugar for iterating through all objects
parent
0c9a9bce98
commit
304542afe2
|
@ -243,9 +243,8 @@ void CCamera::SetType(CameraType type)
|
||||||
|
|
||||||
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
|
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
|
||||||
{
|
{
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck())
|
if (obj->GetTruck())
|
||||||
continue; // battery or cargo?
|
continue; // battery or cargo?
|
||||||
|
|
||||||
|
@ -888,11 +887,9 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
|
||||||
max.z = Math::Max(m_actualEye.z, m_actualLookat.z);
|
max.z = Math::Max(m_actualEye.z, m_actualLookat.z);
|
||||||
|
|
||||||
m_transparency = false;
|
m_transparency = false;
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if (obj->GetTruck()) continue; // battery or cargo?
|
if (obj->GetTruck()) continue; // battery or cargo?
|
||||||
|
|
||||||
SetTransparency(obj, 0.0f); // opaque object
|
SetTransparency(obj, 0.0f); // opaque object
|
||||||
|
@ -965,9 +962,8 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
|
||||||
|
|
||||||
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
|
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
|
||||||
{
|
{
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj == m_cameraObj) continue;
|
if (obj == m_cameraObj) continue;
|
||||||
|
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
|
|
|
@ -317,9 +317,8 @@ CObject* CLightning::SearchObject(Math::Vector pos)
|
||||||
// Seeking the object closest to the point of impact of lightning.
|
// Seeking the object closest to the point of impact of lightning.
|
||||||
CObject* bestObj = 0;
|
CObject* bestObj = 0;
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (!obj->GetActif()) continue; // inactive object?
|
if (!obj->GetActif()) continue; // inactive object?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object transported?
|
if (obj->GetTruck() != nullptr) continue; // object transported?
|
||||||
|
|
||||||
|
|
|
@ -3658,9 +3658,8 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos,
|
||||||
|
|
||||||
CObject* best = 0;
|
CObject* best = 0;
|
||||||
bool shield = false;
|
bool shield = false;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj == father) continue;
|
if (obj == father) continue;
|
||||||
|
|
||||||
|
@ -3781,11 +3780,9 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
|
||||||
box2.x += min;
|
box2.x += min;
|
||||||
box2.y += min;
|
box2.y += min;
|
||||||
box2.z += min;
|
box2.z += min;
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj == father) continue;
|
if (obj == father) continue;
|
||||||
|
|
||||||
|
|
|
@ -2211,14 +2211,12 @@ void CPyro::FallStart()
|
||||||
CObject* CPyro::FallSearchBeeExplo()
|
CObject* CPyro::FallSearchBeeExplo()
|
||||||
{
|
{
|
||||||
Math::Vector iPos;
|
Math::Vector iPos;
|
||||||
float iRadius;
|
float iRadius = 0.0f;
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* pObj = it.second.get();
|
|
||||||
|
|
||||||
ObjectType oType = pObj->GetType();
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
|
ObjectType oType = obj->GetType();
|
||||||
if ( oType != OBJECT_HUMAN &&
|
if ( oType != OBJECT_HUMAN &&
|
||||||
oType != OBJECT_MOBILEfa &&
|
oType != OBJECT_MOBILEfa &&
|
||||||
oType != OBJECT_MOBILEta &&
|
oType != OBJECT_MOBILEta &&
|
||||||
|
@ -2268,40 +2266,41 @@ CObject* CPyro::FallSearchBeeExplo()
|
||||||
oType != OBJECT_POWER &&
|
oType != OBJECT_POWER &&
|
||||||
oType != OBJECT_ATOMIC ) continue;
|
oType != OBJECT_ATOMIC ) continue;
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( obj->GetTruck() != nullptr ) continue; // object transported?
|
||||||
|
|
||||||
Math::Vector oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
|
|
||||||
float distance;
|
float shieldRadius = obj->GetShieldRadius();
|
||||||
|
|
||||||
float shieldRadius = pObj->GetShieldRadius();
|
|
||||||
if ( shieldRadius > 0.0f )
|
if ( shieldRadius > 0.0f )
|
||||||
{
|
{
|
||||||
distance = Math::Distance(oPos, iPos);
|
float distance = Math::Distance(oPos, iPos);
|
||||||
if (distance <= shieldRadius) return pObj;
|
if (distance <= shieldRadius)
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( oType == OBJECT_BASE )
|
if ( oType == OBJECT_BASE )
|
||||||
{
|
{
|
||||||
distance = Math::Distance(oPos, iPos);
|
float distance = Math::Distance(oPos, iPos);
|
||||||
if (distance < 25.0f) return pObj;
|
if (distance < 25.0f)
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the center of the object, which is necessary for objects
|
// Test the center of the object, which is necessary for objects
|
||||||
// that have no sphere in the center (station).
|
// that have no sphere in the center (station).
|
||||||
distance = Math::Distance(oPos, iPos)-4.0f;
|
float distance = Math::Distance(oPos, iPos)-4.0f;
|
||||||
if (distance < 5.0f) return pObj;
|
if (distance < 5.0f)
|
||||||
|
return obj;
|
||||||
|
|
||||||
// Test with all spheres of the object.
|
// Test with all spheres of the object.
|
||||||
Math::Vector ooPos;
|
Math::Vector ooPos;
|
||||||
float ooRadius;
|
float ooRadius = 0.0f;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (pObj->GetCrashSphere(j++, ooPos, ooRadius))
|
while (obj->GetCrashSphere(j++, ooPos, ooRadius))
|
||||||
{
|
{
|
||||||
distance = Math::Distance(ooPos, iPos);
|
distance = Math::Distance(ooPos, iPos);
|
||||||
if (distance <= iRadius+ooRadius)
|
if (distance <= iRadius+ooRadius)
|
||||||
{
|
{
|
||||||
return pObj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1237,35 +1237,28 @@ void CAutoBase::UpdateInterface()
|
||||||
|
|
||||||
// Freeze or frees all cargo.
|
// Freeze or frees all cargo.
|
||||||
|
|
||||||
void CAutoBase::FreezeCargo(bool bFreeze)
|
void CAutoBase::FreezeCargo(bool freeze)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
CPhysics* physics;
|
|
||||||
Math::Vector oPos;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
obj->SetCargo(false);
|
||||||
|
|
||||||
pObj->SetCargo(false);
|
if ( obj == m_object ) continue; // yourself?
|
||||||
|
if ( obj->GetTruck() != nullptr ) continue; // transport object?
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // transport object?
|
float dist = Math::DistanceProjected(m_pos, oPos);
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::DistanceProjected(m_pos, oPos);
|
|
||||||
if ( dist < 32.0f )
|
if ( dist < 32.0f )
|
||||||
{
|
{
|
||||||
if ( bFreeze )
|
if ( freeze )
|
||||||
{
|
{
|
||||||
pObj->SetCargo(true);
|
obj->SetCargo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
physics = pObj->GetPhysics();
|
CPhysics* physics = obj->GetPhysics();
|
||||||
if ( physics != 0 )
|
if ( physics != nullptr )
|
||||||
{
|
{
|
||||||
physics->SetFreeze(bFreeze);
|
physics->SetFreeze(freeze);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1275,23 +1268,18 @@ void CAutoBase::FreezeCargo(bool bFreeze)
|
||||||
|
|
||||||
void CAutoBase::MoveCargo()
|
void CAutoBase::MoveCargo()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector sPos = m_object->GetPosition(0);
|
||||||
Math::Vector oPos, sPos;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetCargo() ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetCargo() ) continue;
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
oPos.y = sPos.y+30.0f;
|
oPos.y = sPos.y+30.0f;
|
||||||
oPos.y += pObj->GetCharacter()->height;
|
oPos.y += obj->GetCharacter()->height;
|
||||||
oPos.x += sPos.x-m_lastPos.x;
|
oPos.x += sPos.x-m_lastPos.x;
|
||||||
oPos.z += sPos.z-m_lastPos.z;
|
oPos.z += sPos.z-m_lastPos.z;
|
||||||
pObj->SetPosition(0, oPos);
|
obj->SetPosition(0, oPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastPos = sPos;
|
m_lastPos = sPos;
|
||||||
|
@ -1302,26 +1290,20 @@ void CAutoBase::MoveCargo()
|
||||||
|
|
||||||
Error CAutoBase::CheckCloseDoor()
|
Error CAutoBase::CheckCloseDoor()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float oRad, dist;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj == m_object ) continue; // yourself?
|
||||||
|
if ( !obj->GetActif() ) continue; // inactive?
|
||||||
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
ObjectType type = obj->GetType();
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_PORTICO ) continue;
|
if ( type == OBJECT_PORTICO ) continue;
|
||||||
|
|
||||||
j = 0;
|
int j = 0;
|
||||||
while ( pObj->GetCrashSphere(j++, oPos, oRad) )
|
Math::Vector oPos;
|
||||||
|
float oRad = 0.0f;
|
||||||
|
while ( obj->GetCrashSphere(j++, oPos, oRad) )
|
||||||
{
|
{
|
||||||
dist = Math::DistanceProjected(m_pos, oPos);
|
float dist = Math::DistanceProjected(m_pos, oPos);
|
||||||
if ( dist+oRad > 32.0f &&
|
if ( dist+oRad > 32.0f &&
|
||||||
dist-oRad < 72.0f )
|
dist-oRad < 72.0f )
|
||||||
{
|
{
|
||||||
|
|
|
@ -395,46 +395,32 @@ bool CAutoConvert::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
CObject* CAutoConvert::SearchStone(ObjectType type)
|
CObject* CAutoConvert::SearchStone(ObjectType type)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType oType = obj->GetType();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( oType != type ) continue;
|
if ( oType != type ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, cPos);
|
float dist = Math::Distance(oPos, cPos);
|
||||||
|
|
||||||
if ( dist <= 5.0f ) return pObj;
|
if ( dist <= 5.0f ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search if a vehicle is too close.
|
// Search if a vehicle is too close.
|
||||||
|
|
||||||
bool CAutoConvert::SearchVehicle()
|
bool CAutoConvert::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float oRadius, dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
type != OBJECT_MOBILEfa &&
|
type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
|
@ -476,8 +462,10 @@ bool CAutoConvert::SearchVehicle()
|
||||||
type != OBJECT_BEE &&
|
type != OBJECT_BEE &&
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
Math::Vector oPos;
|
||||||
dist = Math::Distance(oPos, cPos)-oRadius;
|
float oRadius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
||||||
|
float dist = Math::Distance(oPos, cPos)-oRadius;
|
||||||
|
|
||||||
if ( dist < 8.0f ) return true;
|
if ( dist < 8.0f ) return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,47 +461,35 @@ bool CAutoDerrick::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
CObject* CAutoDerrick::SearchFret()
|
CObject* CAutoDerrick::SearchFret()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_DERRICK ) continue;
|
if ( type == OBJECT_DERRICK ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
|
|
||||||
if ( oPos.x == m_fretPos.x &&
|
if ( oPos.x == m_fretPos.x &&
|
||||||
oPos.z == m_fretPos.z ) return pObj;
|
oPos.z == m_fretPos.z ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seeks if a site is free.
|
// Seeks if a site is free.
|
||||||
|
|
||||||
bool CAutoDerrick::SearchFree(Math::Vector pos)
|
bool CAutoDerrick::SearchFree(Math::Vector pos)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector sPos;
|
|
||||||
ObjectType type;
|
|
||||||
float sRadius, distance;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_DERRICK ) continue;
|
if ( type == OBJECT_DERRICK ) continue;
|
||||||
|
|
||||||
j = 0;
|
int j = 0;
|
||||||
while ( pObj->GetCrashSphere(j++, sPos, sRadius) )
|
Math::Vector sPos;
|
||||||
|
float sRadius = 0.0f;
|
||||||
|
while ( obj->GetCrashSphere(j++, sPos, sRadius) )
|
||||||
{
|
{
|
||||||
distance = Math::Distance(sPos, pos);
|
float distance = Math::Distance(sPos, pos);
|
||||||
distance -= sRadius;
|
distance -= sRadius;
|
||||||
if ( distance < 2.0f ) return false; // location occupied
|
if ( distance < 2.0f ) return false; // location occupied
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,18 +272,11 @@ bool CAutoDestroyer::CreateInterface(bool bSelect)
|
||||||
|
|
||||||
CObject* CAutoDestroyer::SearchPlastic()
|
CObject* CAutoDestroyer::SearchPlastic()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector sPos = m_object->GetPosition(0);
|
||||||
Math::Vector sPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
//if ( type != OBJECT_SCRAP4 &&
|
//if ( type != OBJECT_SCRAP4 &&
|
||||||
// type != OBJECT_SCRAP5 ) continue;
|
// type != OBJECT_SCRAP5 ) continue;
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -334,9 +327,9 @@ CObject* CAutoDestroyer::SearchPlastic()
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, sPos);
|
float dist = Math::Distance(oPos, sPos);
|
||||||
if ( dist <= 5.0f ) return pObj;
|
if ( dist <= 5.0f ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -271,36 +271,28 @@ Error CAutoEgg::GetError()
|
||||||
|
|
||||||
CObject* CAutoEgg::SearchAlien()
|
CObject* CAutoEgg::SearchAlien()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
CObject* pBest;
|
float min = 100000.0f;
|
||||||
Math::Vector cPos, oPos;
|
CObject* best = nullptr;
|
||||||
ObjectType type;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
float dist, min;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
|
||||||
min = 100000.0f;
|
|
||||||
pBest = 0;
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_ANT &&
|
if ( type != OBJECT_ANT &&
|
||||||
type != OBJECT_BEE &&
|
type != OBJECT_BEE &&
|
||||||
type != OBJECT_SPIDER &&
|
type != OBJECT_SPIDER &&
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
float dist = Math::DistanceProjected(oPos, cPos);
|
||||||
if ( dist < 8.0f && dist < min )
|
if ( dist < 8.0f && dist < min )
|
||||||
{
|
{
|
||||||
min = dist;
|
min = dist;
|
||||||
pBest = pObj;
|
best = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pBest;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -394,18 +394,11 @@ CObject* CAutoEnergy::SearchMetal()
|
||||||
|
|
||||||
bool CAutoEnergy::SearchVehicle()
|
bool CAutoEnergy::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float oRadius, dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
type != OBJECT_MOBILEfa &&
|
type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
|
@ -440,8 +433,10 @@ bool CAutoEnergy::SearchVehicle()
|
||||||
type != OBJECT_BEE &&
|
type != OBJECT_BEE &&
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
Math::Vector oPos;
|
||||||
dist = Math::Distance(oPos, cPos)-oRadius;
|
float oRadius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
||||||
|
float dist = Math::Distance(oPos, cPos)-oRadius;
|
||||||
|
|
||||||
if ( dist < 10.0f ) return true;
|
if ( dist < 10.0f ) return true;
|
||||||
}
|
}
|
||||||
|
@ -468,30 +463,24 @@ void CAutoEnergy::CreatePower()
|
||||||
|
|
||||||
CObject* CAutoEnergy::SearchPower()
|
CObject* CAutoEnergy::SearchPower()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetLock() ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_POWER ) continue;
|
if ( type != OBJECT_POWER ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
if ( oPos.x == cPos.x &&
|
if ( oPos.x == cPos.x &&
|
||||||
oPos.z == cPos.z )
|
oPos.z == cPos.z )
|
||||||
{
|
{
|
||||||
return pObj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -547,25 +547,18 @@ bool CAutoFactory::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
CObject* CAutoFactory::SearchFret()
|
CObject* CAutoFactory::SearchFret()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_METAL ) continue;
|
if ( type != OBJECT_METAL ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, m_fretPos);
|
float dist = Math::Distance(oPos, m_fretPos);
|
||||||
|
|
||||||
if ( dist < 8.0f ) return pObj;
|
if ( dist < 8.0f ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,18 +566,11 @@ CObject* CAutoFactory::SearchFret()
|
||||||
|
|
||||||
bool CAutoFactory::NearestVehicle()
|
bool CAutoFactory::NearestVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float oRadius, dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
type != OBJECT_MOBILEfa &&
|
type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
|
@ -619,8 +605,10 @@ bool CAutoFactory::NearestVehicle()
|
||||||
type != OBJECT_BEE &&
|
type != OBJECT_BEE &&
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
Math::Vector oPos;
|
||||||
dist = Math::Distance(oPos, cPos)-oRadius;
|
float oRadius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
||||||
|
float dist = Math::Distance(oPos, cPos)-oRadius;
|
||||||
|
|
||||||
if ( dist < 10.0f ) return true;
|
if ( dist < 10.0f ) return true;
|
||||||
}
|
}
|
||||||
|
@ -680,29 +668,22 @@ bool CAutoFactory::CreateVehicle()
|
||||||
// Seeking the vehicle during manufacture.
|
// Seeking the vehicle during manufacture.
|
||||||
|
|
||||||
CObject* CAutoFactory::SearchVehicle()
|
CObject* CAutoFactory::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetLock() ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != m_type ) continue;
|
if ( type != m_type ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, m_fretPos);
|
float dist = Math::Distance(oPos, m_fretPos);
|
||||||
|
|
||||||
if ( dist < 8.0f ) return pObj;
|
if ( dist < 8.0f ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates all the interface when the object is selected.
|
// Creates all the interface when the object is selected.
|
||||||
|
|
|
@ -225,20 +225,13 @@ bool CAutoMush::EventProcess(const Event &event)
|
||||||
|
|
||||||
bool CAutoMush::SearchTarget()
|
bool CAutoMush::SearchTarget()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector iPos = m_object->GetPosition(0);
|
||||||
Math::Vector iPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj->GetLock() ) continue;
|
||||||
|
|
||||||
if ( pObj->GetLock() ) continue;
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_MOBILEfa &&
|
if ( type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
type != OBJECT_MOBILEwa &&
|
type != OBJECT_MOBILEwa &&
|
||||||
|
@ -282,8 +275,8 @@ bool CAutoMush::SearchTarget()
|
||||||
type != OBJECT_PARA &&
|
type != OBJECT_PARA &&
|
||||||
type != OBJECT_HUMAN ) continue;
|
type != OBJECT_HUMAN ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, iPos);
|
float dist = Math::Distance(oPos, iPos);
|
||||||
if ( dist < 50.0f ) return true;
|
if ( dist < 50.0f ) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,23 +148,17 @@ bool CAutoNest::EventProcess(const Event &event)
|
||||||
|
|
||||||
bool CAutoNest::SearchFree(Math::Vector pos)
|
bool CAutoNest::SearchFree(Math::Vector pos)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector sPos;
|
|
||||||
ObjectType type;
|
|
||||||
float sRadius, distance;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_NEST ) continue;
|
if ( type == OBJECT_NEST ) continue;
|
||||||
|
|
||||||
j = 0;
|
int j = 0;
|
||||||
while ( pObj->GetCrashSphere(j++, sPos, sRadius) )
|
Math::Vector sPos;
|
||||||
|
float sRadius = 0.0f;
|
||||||
|
while ( obj->GetCrashSphere(j++, sPos, sRadius) )
|
||||||
{
|
{
|
||||||
distance = Math::Distance(sPos, pos);
|
float distance = Math::Distance(sPos, pos);
|
||||||
distance -= sRadius;
|
distance -= sRadius;
|
||||||
if ( distance < 2.0f ) return false; // location occupied
|
if ( distance < 2.0f ) return false; // location occupied
|
||||||
}
|
}
|
||||||
|
@ -186,28 +180,22 @@ void CAutoNest::CreateFret(Math::Vector pos, float angle, ObjectType type)
|
||||||
|
|
||||||
CObject* CAutoNest::SearchFret()
|
CObject* CAutoNest::SearchFret()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetLock() ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetLock() ) continue;
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_BULLET ) continue;
|
if ( type != OBJECT_BULLET ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
if ( oPos.x == m_fretPos.x &&
|
if ( oPos.x == m_fretPos.x &&
|
||||||
oPos.z == m_fretPos.z )
|
oPos.z == m_fretPos.z )
|
||||||
{
|
{
|
||||||
return pObj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -331,16 +331,9 @@ CObject* CAutoNuclear::SearchUranium()
|
||||||
|
|
||||||
bool CAutoNuclear::SearchVehicle()
|
bool CAutoNuclear::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float oRadius, dist;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
type != OBJECT_MOBILEfa &&
|
type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
|
@ -375,8 +368,10 @@ bool CAutoNuclear::SearchVehicle()
|
||||||
type != OBJECT_BEE &&
|
type != OBJECT_BEE &&
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
Math::Vector oPos;
|
||||||
dist = Math::Distance(oPos, m_pos)-oRadius;
|
float oRadius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
||||||
|
float dist = Math::Distance(oPos, m_pos)-oRadius;
|
||||||
|
|
||||||
if ( dist < 10.0f ) return true;
|
if ( dist < 10.0f ) return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,42 +243,35 @@ Error CAutoPara::GetError()
|
||||||
|
|
||||||
void CAutoPara::ChargeObject(float rTime)
|
void CAutoPara::ChargeObject(float rTime)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector sPos = m_object->GetPosition(0);
|
||||||
CObject* power;
|
|
||||||
Math::Vector sPos, oPos;
|
|
||||||
float dist, energy;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
|
float dist = Math::Distance(oPos, sPos);
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::Distance(oPos, sPos);
|
|
||||||
if ( dist > 20.0f ) continue;
|
if ( dist > 20.0f ) continue;
|
||||||
|
|
||||||
if ( pObj->GetTruck() == 0 && pObj->GetType() == OBJECT_POWER )
|
if ( obj->GetTruck() == nullptr && obj->GetType() == OBJECT_POWER )
|
||||||
{
|
{
|
||||||
energy = pObj->GetEnergy();
|
float energy = obj->GetEnergy();
|
||||||
energy += rTime/2.0f;
|
energy += rTime/2.0f;
|
||||||
if ( energy > 1.0f ) energy = 1.0f;
|
if ( energy > 1.0f ) energy = 1.0f;
|
||||||
pObj->SetEnergy(energy);
|
obj->SetEnergy(energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
power = pObj->GetPower();
|
CObject* power = obj->GetPower();
|
||||||
if ( power != 0 && power->GetType() == OBJECT_POWER )
|
if ( power != nullptr && power->GetType() == OBJECT_POWER )
|
||||||
{
|
{
|
||||||
energy = power->GetEnergy();
|
float energy = power->GetEnergy();
|
||||||
energy += rTime/2.0f;
|
energy += rTime/2.0f;
|
||||||
if ( energy > 1.0f ) energy = 1.0f;
|
if ( energy > 1.0f ) energy = 1.0f;
|
||||||
power->SetEnergy(energy);
|
power->SetEnergy(energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
power = pObj->GetFret();
|
power = obj->GetFret();
|
||||||
if ( power != 0 && power->GetType() == OBJECT_POWER )
|
if ( power != nullptr && power->GetType() == OBJECT_POWER )
|
||||||
{
|
{
|
||||||
energy = power->GetEnergy();
|
float energy = power->GetEnergy();
|
||||||
energy += rTime/2.0f;
|
energy += rTime/2.0f;
|
||||||
if ( energy > 1.0f ) energy = 1.0f;
|
if ( energy > 1.0f ) energy = 1.0f;
|
||||||
power->SetEnergy(energy);
|
power->SetEnergy(energy);
|
||||||
|
|
|
@ -264,23 +264,16 @@ void CAutoRadar::UpdateInterface()
|
||||||
|
|
||||||
bool CAutoRadar::SearchEnemy(Math::Vector &pos)
|
bool CAutoRadar::SearchEnemy(Math::Vector &pos)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector iPos = m_object->GetPosition(0);
|
||||||
CObject* pBest = 0;
|
float min = 1000000.0f;
|
||||||
Math::Vector iPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float distance, min;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
|
||||||
min = 1000000.0f;
|
|
||||||
m_totalDetect = 0;
|
m_totalDetect = 0;
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
CObject* best = nullptr;
|
||||||
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetActif() ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
ObjectType oType = obj->GetType();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( oType != OBJECT_ANT &&
|
if ( oType != OBJECT_ANT &&
|
||||||
oType != OBJECT_SPIDER &&
|
oType != OBJECT_SPIDER &&
|
||||||
oType != OBJECT_BEE &&
|
oType != OBJECT_BEE &&
|
||||||
|
@ -289,19 +282,19 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
|
||||||
|
|
||||||
m_totalDetect ++;
|
m_totalDetect ++;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
distance = Math::Distance(oPos, iPos);
|
float distance = Math::Distance(oPos, iPos);
|
||||||
if ( distance < min )
|
if ( distance < min )
|
||||||
{
|
{
|
||||||
min = distance;
|
min = distance;
|
||||||
pBest = pObj;
|
best = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateInterface();
|
UpdateInterface();
|
||||||
|
|
||||||
if ( pBest == 0 ) return false;
|
if ( best == nullptr ) return false;
|
||||||
pos = pBest->GetPosition(0);
|
pos = best->GetPosition(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,19 +234,11 @@ bool CAutoRepair::CreateInterface(bool bSelect)
|
||||||
|
|
||||||
CObject* CAutoRepair::SearchVehicle()
|
CObject* CAutoRepair::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector sPos = m_object->GetPosition(0);
|
||||||
CPhysics* physics;
|
|
||||||
Math::Vector sPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_MOBILEfa &&
|
if ( type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
type != OBJECT_MOBILEwa &&
|
type != OBJECT_MOBILEwa &&
|
||||||
|
@ -275,15 +267,15 @@ CObject* CAutoRepair::SearchVehicle()
|
||||||
type != OBJECT_MOBILEit &&
|
type != OBJECT_MOBILEit &&
|
||||||
type != OBJECT_MOBILEdr ) continue;
|
type != OBJECT_MOBILEdr ) continue;
|
||||||
|
|
||||||
physics = pObj->GetPhysics();
|
CPhysics* physics = obj->GetPhysics();
|
||||||
if ( physics != 0 && !physics->GetLand() ) continue; // in flight?
|
if ( physics != nullptr && !physics->GetLand() ) continue; // in flight?
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, sPos);
|
float dist = Math::Distance(oPos, sPos);
|
||||||
if ( dist <= 5.0f ) return pObj;
|
if ( dist <= 5.0f ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -385,38 +385,32 @@ bool CAutoSafe::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
int CAutoSafe::CountKeys()
|
int CAutoSafe::CountKeys()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
float cAngle = m_object->GetAngleY(0);
|
||||||
Math::Point rot;
|
|
||||||
ObjectType oType;
|
|
||||||
float dist, angle, limit = 0.0f, cAngle, oAngle = 0.0f;
|
|
||||||
int i, index;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (int index = 0; index < 4; index++)
|
||||||
cAngle = m_object->GetAngleY(0);
|
|
||||||
|
|
||||||
for ( index=0 ; index<4 ; index++ )
|
|
||||||
{
|
{
|
||||||
m_bKey[index] = false;
|
m_bKey[index] = false;
|
||||||
m_keyPos[index] = cPos;
|
m_keyPos[index] = cPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
ObjectType oType = obj->GetType();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( oType != OBJECT_KEYa &&
|
if ( oType != OBJECT_KEYa &&
|
||||||
oType != OBJECT_KEYb &&
|
oType != OBJECT_KEYb &&
|
||||||
oType != OBJECT_KEYc &&
|
oType != OBJECT_KEYc &&
|
||||||
oType != OBJECT_KEYd ) continue;
|
oType != OBJECT_KEYd ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
float dist = Math::DistanceProjected(oPos, cPos);
|
||||||
if ( dist > 20.0f ) continue;
|
if ( dist > 20.0f ) continue;
|
||||||
|
|
||||||
|
float limit = 0.0f;
|
||||||
|
float oAngle = 0.0f;
|
||||||
|
int index = 0;
|
||||||
if ( oType == OBJECT_KEYa )
|
if ( oType == OBJECT_KEYa )
|
||||||
{
|
{
|
||||||
limit = Math::PI*1.0f;
|
limit = Math::PI*1.0f;
|
||||||
|
@ -442,23 +436,23 @@ int CAutoSafe::CountKeys()
|
||||||
index = 3;
|
index = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
angle = Math::RotateAngle(oPos.x-cPos.x, oPos.z-cPos.z)+cAngle;
|
float angle = Math::RotateAngle(oPos.x-cPos.x, oPos.z-cPos.z)+cAngle;
|
||||||
if ( !Math::TestAngle(angle, limit-8.0f*Math::PI/180.0f, limit+8.0f*Math::PI/180.0f) ) continue;
|
if ( !Math::TestAngle(angle, limit-8.0f*Math::PI/180.0f, limit+8.0f*Math::PI/180.0f) ) continue;
|
||||||
|
|
||||||
// Key changes the shape of the base.
|
// Key changes the shape of the base.
|
||||||
rot = Math::RotatePoint(Math::Point(cPos.x, cPos.z), limit-cAngle, Math::Point(cPos.x+16.0f, cPos.z));
|
Math::Point rot = Math::RotatePoint(Math::Point(cPos.x, cPos.z), limit-cAngle, Math::Point(cPos.x+16.0f, cPos.z));
|
||||||
oPos.x = rot.x;
|
oPos.x = rot.x;
|
||||||
oPos.z = rot.y;
|
oPos.z = rot.y;
|
||||||
oPos.y = cPos.y+1.0f;
|
oPos.y = cPos.y+1.0f;
|
||||||
pObj->SetPosition(0, oPos);
|
obj->SetPosition(0, oPos);
|
||||||
pObj->SetAngleY(0, oAngle+cAngle);
|
obj->SetAngleY(0, oAngle+cAngle);
|
||||||
m_keyPos[index] = oPos;
|
m_keyPos[index] = oPos;
|
||||||
|
|
||||||
m_bKey[index] = true;
|
m_bKey[index] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
int i = 0;
|
||||||
for ( index=0 ; index<4 ; index++ )
|
for (int index = 0; index < 4; index++)
|
||||||
{
|
{
|
||||||
if ( m_bKey[index] ) i++;
|
if ( m_bKey[index] ) i++;
|
||||||
}
|
}
|
||||||
|
@ -469,30 +463,23 @@ int CAutoSafe::CountKeys()
|
||||||
|
|
||||||
void CAutoSafe::LockKeys()
|
void CAutoSafe::LockKeys()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType oType = obj->GetType();
|
||||||
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
|
||||||
|
|
||||||
if ( oType != OBJECT_KEYa &&
|
if ( oType != OBJECT_KEYa &&
|
||||||
oType != OBJECT_KEYb &&
|
oType != OBJECT_KEYb &&
|
||||||
oType != OBJECT_KEYc &&
|
oType != OBJECT_KEYc &&
|
||||||
oType != OBJECT_KEYd ) continue;
|
oType != OBJECT_KEYd ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
float dist = Math::DistanceProjected(oPos, cPos);
|
||||||
if ( dist > 20.0f ) continue;
|
if ( dist > 20.0f ) continue;
|
||||||
|
|
||||||
pObj->SetLock(true);
|
obj->SetLock(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,31 +487,24 @@ void CAutoSafe::LockKeys()
|
||||||
|
|
||||||
void CAutoSafe::DownKeys(float progress)
|
void CAutoSafe::DownKeys(float progress)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType oType = obj->GetType();
|
||||||
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
|
||||||
|
|
||||||
if ( oType != OBJECT_KEYa &&
|
if ( oType != OBJECT_KEYa &&
|
||||||
oType != OBJECT_KEYb &&
|
oType != OBJECT_KEYb &&
|
||||||
oType != OBJECT_KEYc &&
|
oType != OBJECT_KEYc &&
|
||||||
oType != OBJECT_KEYd ) continue;
|
oType != OBJECT_KEYd ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
float dist = Math::DistanceProjected(oPos, cPos);
|
||||||
if ( dist > 20.0f ) continue;
|
if ( dist > 20.0f ) continue;
|
||||||
|
|
||||||
oPos.y = cPos.y+1.0f-progress*2.2f;
|
oPos.y = cPos.y+1.0f-progress*2.2f;
|
||||||
pObj->SetPosition(0, oPos);
|
obj->SetPosition(0, oPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,10 +518,8 @@ void CAutoSafe::DeleteKeys()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
haveDeleted = false;
|
haveDeleted = false;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
ObjectType oType = obj->GetType();
|
ObjectType oType = obj->GetType();
|
||||||
if ( obj->GetTruck() != nullptr ) continue;
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
|
@ -566,23 +544,17 @@ void CAutoSafe::DeleteKeys()
|
||||||
|
|
||||||
CObject* CAutoSafe::SearchVehicle()
|
CObject* CAutoSafe::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector cPos = m_object->GetPosition(0);
|
||||||
Math::Vector cPos, oPos;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
cPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj == m_object ) continue;
|
||||||
|
if ( obj->GetTruck() != nullptr ) continue;
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
float dist = Math::DistanceProjected(oPos, cPos);
|
||||||
|
if ( dist <= 4.0f ) return obj;
|
||||||
oPos = pObj->GetPosition(0);
|
|
||||||
dist = Math::DistanceProjected(oPos, cPos);
|
|
||||||
if ( dist <= 4.0f ) return pObj;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,18 +241,11 @@ bool CAutoStation::EventProcess(const Event &event)
|
||||||
|
|
||||||
CObject* CAutoStation::SearchVehicle()
|
CObject* CAutoStation::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector sPos = m_object->GetPosition(0);
|
||||||
Math::Vector sPos, oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float dist;
|
|
||||||
|
|
||||||
sPos = m_object->GetPosition(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
type != OBJECT_MOBILEfa &&
|
type != OBJECT_MOBILEfa &&
|
||||||
type != OBJECT_MOBILEta &&
|
type != OBJECT_MOBILEta &&
|
||||||
|
@ -281,9 +274,9 @@ CObject* CAutoStation::SearchVehicle()
|
||||||
type != OBJECT_MOBILEit &&
|
type != OBJECT_MOBILEit &&
|
||||||
type != OBJECT_MOBILEdr ) continue;
|
type != OBJECT_MOBILEdr ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, sPos);
|
float dist = Math::Distance(oPos, sPos);
|
||||||
if ( dist <= 5.0f ) return pObj;
|
if ( dist <= 5.0f ) return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -267,53 +267,47 @@ bool CAutoTower::EventProcess(const Event &event)
|
||||||
|
|
||||||
CObject* CAutoTower::SearchTarget(Math::Vector &impact)
|
CObject* CAutoTower::SearchTarget(Math::Vector &impact)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector iPos = m_object->GetPosition(0);
|
||||||
CObject* pBest = 0;
|
float min = 1000000.0f;
|
||||||
CPhysics* physics;
|
|
||||||
Math::Vector iPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float distance, min, radius, speed;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
CObject* best = nullptr;
|
||||||
min = 1000000.0f;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType oType = obj->GetType();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( oType != OBJECT_MOTHER &&
|
if ( oType != OBJECT_MOTHER &&
|
||||||
oType != OBJECT_ANT &&
|
oType != OBJECT_ANT &&
|
||||||
oType != OBJECT_SPIDER &&
|
oType != OBJECT_SPIDER &&
|
||||||
oType != OBJECT_BEE &&
|
oType != OBJECT_BEE &&
|
||||||
oType != OBJECT_WORM ) continue;
|
oType != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !obj->GetActif() ) continue; // inactive?
|
||||||
|
|
||||||
//? if ( g_researchDone & RESEARCH_QUICK )
|
//? if ( g_researchDone & RESEARCH_QUICK )
|
||||||
if ( false )
|
if ( false )
|
||||||
{
|
{
|
||||||
physics = pObj->GetPhysics();
|
CPhysics* physics = obj->GetPhysics();
|
||||||
if ( physics != 0 )
|
if ( physics != nullptr )
|
||||||
{
|
{
|
||||||
speed = fabs(physics->GetLinMotionX(MO_REASPEED));
|
float speed = fabs(physics->GetLinMotionX(MO_REASPEED));
|
||||||
if ( speed > 20.0f ) continue; // moving too fast?
|
if ( speed > 20.0f ) continue; // moving too fast?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, radius) ) continue;
|
Math::Vector oPos;
|
||||||
distance = Math::Distance(oPos, iPos);
|
float radius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, radius) ) continue;
|
||||||
|
float distance = Math::Distance(oPos, iPos);
|
||||||
if ( distance > TOWER_SCOPE ) continue; // too far
|
if ( distance > TOWER_SCOPE ) continue; // too far
|
||||||
if ( distance < min )
|
if ( distance < min )
|
||||||
{
|
{
|
||||||
min = distance;
|
min = distance;
|
||||||
pBest = pObj;
|
best = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( pBest == 0 ) return 0;
|
if ( best == nullptr ) return nullptr;
|
||||||
|
|
||||||
impact = pBest->GetPosition(0);
|
impact = best->GetPosition(0);
|
||||||
return pBest;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -347,8 +347,6 @@ CObject::~CObject()
|
||||||
|
|
||||||
void CObject::DeleteObject(bool bAll)
|
void CObject::DeleteObject(bool bAll)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
Gfx::CPyro* pPyro;
|
|
||||||
if ( m_botVar != 0 )
|
if ( m_botVar != 0 )
|
||||||
{
|
{
|
||||||
m_botVar->SetUserPtr(OBJECTDELETED);
|
m_botVar->SetUserPtr(OBJECTDELETED);
|
||||||
|
@ -361,12 +359,10 @@ void CObject::DeleteObject(bool bAll)
|
||||||
|
|
||||||
|
|
||||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
pObj->DeleteDeselList(this);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
|
obj->DeleteDeselList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !bAll )
|
if ( !bAll )
|
||||||
|
@ -379,25 +375,25 @@ void CObject::DeleteObject(bool bAll)
|
||||||
type == Gfx::CAM_TYPE_ONBOARD) &&
|
type == Gfx::CAM_TYPE_ONBOARD) &&
|
||||||
m_camera->GetControllingObject() == this )
|
m_camera->GetControllingObject() == this )
|
||||||
{
|
{
|
||||||
pObj = m_main->SearchNearest(GetPosition(0), this);
|
obj = m_main->SearchNearest(GetPosition(0), this);
|
||||||
if ( pObj == 0 )
|
if ( obj == 0 )
|
||||||
{
|
{
|
||||||
m_camera->SetControllingObject(0);
|
m_camera->SetControllingObject(0);
|
||||||
m_camera->SetType(Gfx::CAM_TYPE_FREE);
|
m_camera->SetType(Gfx::CAM_TYPE_FREE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_camera->SetControllingObject(pObj);
|
m_camera->SetControllingObject(obj);
|
||||||
m_camera->SetType(Gfx::CAM_TYPE_BACK);
|
m_camera->SetType(Gfx::CAM_TYPE_BACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for (int i=0 ; i<1000000 ; i++ )
|
for (int i=0 ; i<1000000 ; i++ )
|
||||||
{
|
{
|
||||||
pPyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, i));
|
Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, i));
|
||||||
if ( pPyro == 0 ) break;
|
if ( pyro == nullptr ) break;
|
||||||
|
|
||||||
pPyro->CutObjectLink(this); // the object no longer exists
|
pyro->CutObjectLink(this); // the object no longer exists
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_bSelect )
|
if ( m_bSelect )
|
||||||
|
|
|
@ -54,10 +54,10 @@ bool CObjectManager::DeleteObject(CObject* instance)
|
||||||
|
|
||||||
instance->DeleteObject();
|
instance->DeleteObject();
|
||||||
|
|
||||||
auto it = m_table.find(instance->GetID());
|
auto it = m_objects.find(instance->GetID());
|
||||||
if (it != m_table.end())
|
if (it != m_objects.end())
|
||||||
{
|
{
|
||||||
m_table.erase(it);
|
m_objects.erase(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,27 +66,27 @@ bool CObjectManager::DeleteObject(CObject* instance)
|
||||||
|
|
||||||
void CObjectManager::DeleteAllObjects()
|
void CObjectManager::DeleteAllObjects()
|
||||||
{
|
{
|
||||||
for (auto& it : m_table)
|
for (auto& it : m_objects)
|
||||||
{
|
{
|
||||||
bool all = true;
|
bool all = true;
|
||||||
it.second->DeleteObject(all);
|
it.second->DeleteObject(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_table.clear();
|
m_objects.clear();
|
||||||
|
|
||||||
m_nextId = 0;
|
m_nextId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::GetObjectById(unsigned int id)
|
CObject* CObjectManager::GetObjectById(unsigned int id)
|
||||||
{
|
{
|
||||||
if(m_table.count(id) == 0) return nullptr;
|
if(m_objects.count(id) == 0) return nullptr;
|
||||||
return m_table[id].get();
|
return m_objects[id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
CObject* CObjectManager::GetObjectByRank(unsigned int id)
|
||||||
{
|
{
|
||||||
if(id >= m_table.size()) return nullptr;
|
if(id >= m_objects.size()) return nullptr;
|
||||||
auto it = m_table.begin();
|
auto it = m_objects.begin();
|
||||||
for(unsigned int i = 0; i < id; i++, ++it);
|
for(unsigned int i = 0; i < id; i++, ++it);
|
||||||
return it->second.get();
|
return it->second.get();
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos,
|
||||||
m_nextId++;
|
m_nextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(m_table.find(id) == m_table.end());
|
assert(m_objects.find(id) == m_objects.end());
|
||||||
|
|
||||||
ObjectCreateParams params;
|
ObjectCreateParams params;
|
||||||
params.pos = pos;
|
params.pos = pos;
|
||||||
|
@ -125,7 +125,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos,
|
||||||
auto objectUPtr = m_objectFactory->CreateObject(params);
|
auto objectUPtr = m_objectFactory->CreateObject(params);
|
||||||
CObject* objectPtr = objectUPtr.get();
|
CObject* objectPtr = objectUPtr.get();
|
||||||
|
|
||||||
m_table[id] = std::move(objectUPtr);
|
m_objects[id] = std::move(objectUPtr);
|
||||||
|
|
||||||
return objectPtr;
|
return objectPtr;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float
|
||||||
if ( !furthest ) best = 100000.0f;
|
if ( !furthest ) best = 100000.0f;
|
||||||
else best = 0.0f;
|
else best = 0.0f;
|
||||||
pBest = nullptr;
|
pBest = nullptr;
|
||||||
for ( auto it = m_table.begin() ; it != m_table.end() ; ++it )
|
for ( auto it = m_objects.begin() ; it != m_objects.end() ; ++it )
|
||||||
{
|
{
|
||||||
pObj = it->second.get();
|
pObj = it->second.get();
|
||||||
if ( pObj == pThis ) continue; // pThis may be nullptr but it doesn't matter
|
if ( pObj == pThis ) continue; // pThis may be nullptr but it doesn't matter
|
||||||
|
|
|
@ -54,6 +54,59 @@ enum RadarFilter
|
||||||
};
|
};
|
||||||
|
|
||||||
using CObjectMap = std::map<int, std::unique_ptr<CObject>>;
|
using CObjectMap = std::map<int, std::unique_ptr<CObject>>;
|
||||||
|
using CObjectMapCIt = std::map<int, std::unique_ptr<CObject>>::const_iterator;
|
||||||
|
|
||||||
|
class CObjectIteratorProxy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline CObject* operator*()
|
||||||
|
{
|
||||||
|
return m_it->second.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void operator++()
|
||||||
|
{
|
||||||
|
++m_it;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const CObjectIteratorProxy& other)
|
||||||
|
{
|
||||||
|
return m_it != other.m_it;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class CObjectContainerProxy;
|
||||||
|
|
||||||
|
CObjectIteratorProxy(CObjectMapCIt it)
|
||||||
|
: m_it(it)
|
||||||
|
{}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CObjectMapCIt m_it;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CObjectContainerProxy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline CObjectIteratorProxy begin() const
|
||||||
|
{
|
||||||
|
return CObjectIteratorProxy(m_map.begin());
|
||||||
|
}
|
||||||
|
inline CObjectIteratorProxy end() const
|
||||||
|
{
|
||||||
|
return CObjectIteratorProxy(m_map.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class CObjectManager;
|
||||||
|
|
||||||
|
inline CObjectContainerProxy(const CObjectMap& map)
|
||||||
|
: m_map(map)
|
||||||
|
{}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const CObjectMap& m_map;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class ObjectManager
|
* \class ObjectManager
|
||||||
|
@ -89,13 +142,13 @@ public:
|
||||||
//! Finds object by id (CObject::GetID())
|
//! Finds object by id (CObject::GetID())
|
||||||
CObject* GetObjectById(unsigned int id);
|
CObject* GetObjectById(unsigned int id);
|
||||||
|
|
||||||
//! Gets object by id in range <0; number of objects - 1)
|
//! Gets object by id in range <0; number of objects - 1>
|
||||||
CObject* GetObjectByRank(unsigned int id);
|
CObject* GetObjectByRank(unsigned int id);
|
||||||
|
|
||||||
//! Returns all objects
|
//! Returns all objects
|
||||||
inline const CObjectMap& GetAllObjects()
|
inline CObjectContainerProxy GetAllObjects()
|
||||||
{
|
{
|
||||||
return m_table;
|
return CObjectContainerProxy(m_objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Finds an object, like radar() in CBot
|
//! Finds an object, like radar() in CBot
|
||||||
|
@ -164,7 +217,7 @@ public:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CObjectMap m_table;
|
CObjectMap m_objects;
|
||||||
std::unique_ptr<CObjectFactory> m_objectFactory;
|
std::unique_ptr<CObjectFactory> m_objectFactory;
|
||||||
int m_nextId;
|
int m_nextId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1806,9 +1806,8 @@ CObject* CRobotMain::GetSelectObject()
|
||||||
CObject* CRobotMain::DeselectAll()
|
CObject* CRobotMain::DeselectAll()
|
||||||
{
|
{
|
||||||
CObject* prev = nullptr;
|
CObject* prev = nullptr;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetSelect()) prev = obj;
|
if (obj->GetSelect()) prev = obj;
|
||||||
obj->SetSelect(false);
|
obj->SetSelect(false);
|
||||||
}
|
}
|
||||||
|
@ -1962,9 +1961,8 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
||||||
{
|
{
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
CObject* best = 0;
|
CObject* best = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj == exclu) continue;
|
if (obj == exclu) continue;
|
||||||
if (!IsSelectable(obj)) continue;
|
if (!IsSelectable(obj)) continue;
|
||||||
|
|
||||||
|
@ -1985,9 +1983,8 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
|
||||||
//! Returns the selected object
|
//! Returns the selected object
|
||||||
CObject* CRobotMain::GetSelect()
|
CObject* CRobotMain::GetSelect()
|
||||||
{
|
{
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetSelect())
|
if (obj->GetSelect())
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -2003,11 +2000,9 @@ CObject* CRobotMain::SearchObject(ObjectType type)
|
||||||
CObject* CRobotMain::DetectObject(Math::Point pos)
|
CObject* CRobotMain::DetectObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
int objRank = m_engine->DetectObject(pos);
|
int objRank = m_engine->DetectObject(pos);
|
||||||
|
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
|
{
|
||||||
if (!obj->GetActif()) continue;
|
if (!obj->GetActif()) continue;
|
||||||
CObject* truck = obj->GetTruck();
|
CObject* truck = obj->GetTruck();
|
||||||
if (truck != nullptr) if (!truck->GetActif()) continue;
|
if (truck != nullptr) if (!truck->GetActif()) continue;
|
||||||
|
@ -2243,11 +2238,9 @@ void CRobotMain::HiliteClear()
|
||||||
|
|
||||||
int rank = -1;
|
int rank = -1;
|
||||||
m_engine->SetHighlightRank(&rank); // nothing more selected
|
m_engine->SetHighlightRank(&rank); // nothing more selected
|
||||||
|
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
|
{
|
||||||
obj->SetHilite(false);
|
obj->SetHilite(false);
|
||||||
m_map->SetHighlight(0);
|
m_map->SetHighlight(0);
|
||||||
m_short->SetHighlight(0);
|
m_short->SetHighlight(0);
|
||||||
|
@ -2404,9 +2397,8 @@ void CRobotMain::HelpObject()
|
||||||
//! Change the mode of the camera
|
//! Change the mode of the camera
|
||||||
void CRobotMain::ChangeCamera()
|
void CRobotMain::ChangeCamera()
|
||||||
{
|
{
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetSelect())
|
if (obj->GetSelect())
|
||||||
{
|
{
|
||||||
if (obj->GetCameraLock()) return;
|
if (obj->GetCameraLock()) return;
|
||||||
|
@ -2548,9 +2540,8 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
|
||||||
//! Cancels the current movie
|
//! Cancels the current movie
|
||||||
void CRobotMain::AbortMovie()
|
void CRobotMain::AbortMovie()
|
||||||
{
|
{
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
CAuto* automat = obj->GetAuto();
|
CAuto* automat = obj->GetAuto();
|
||||||
if (automat != 0)
|
if (automat != 0)
|
||||||
automat->Abort();
|
automat->Abort();
|
||||||
|
@ -2635,9 +2626,8 @@ bool CRobotMain::EventFrame(const Event &event)
|
||||||
if (!m_freePhoto)
|
if (!m_freePhoto)
|
||||||
{
|
{
|
||||||
// Advances all the robots, but not toto.
|
// Advances all the robots, but not toto.
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (pm != nullptr) pm->UpdateObject(obj);
|
if (pm != nullptr) pm->UpdateObject(obj);
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
|
@ -2647,9 +2637,8 @@ bool CRobotMain::EventFrame(const Event &event)
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
// Advances all objects transported by robots.
|
// Advances all objects transported by robots.
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck() == nullptr) continue;
|
if (obj->GetTruck() == nullptr) continue;
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
|
@ -2806,11 +2795,9 @@ bool CRobotMain::EventObject(const Event &event)
|
||||||
if (m_freePhoto) return true;
|
if (m_freePhoto) return true;
|
||||||
|
|
||||||
m_resetCreate = false;
|
m_resetCreate = false;
|
||||||
|
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
|
{
|
||||||
obj->EventProcess(event);
|
obj->EventProcess(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4203,9 +4190,8 @@ bool CRobotMain::TestGadgetQuantity(int rank)
|
||||||
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
|
||||||
{
|
{
|
||||||
float min = 100000.0f;
|
float min = 100000.0f;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object carries?
|
if (obj->GetTruck() != nullptr) continue; // object carries?
|
||||||
if (obj == exclu) continue;
|
if (obj == exclu) continue;
|
||||||
|
@ -4352,9 +4338,8 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
|
||||||
// Calculates the maximum radius possible depending on other items.
|
// Calculates the maximum radius possible depending on other items.
|
||||||
float oMax = 30.0f; // radius to build the biggest building
|
float oMax = 30.0f; // radius to build the biggest building
|
||||||
float tMax;
|
float tMax;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (!obj->GetActif()) continue; // inactive?
|
if (!obj->GetActif()) continue; // inactive?
|
||||||
if (obj->GetTruck() != nullptr) continue; // object carried?
|
if (obj->GetTruck() != nullptr) continue; // object carried?
|
||||||
if (obj == metal) continue;
|
if (obj == metal) continue;
|
||||||
|
@ -4557,9 +4542,8 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
{
|
{
|
||||||
lastError = nbError;
|
lastError = nbError;
|
||||||
nbError = 0;
|
nbError = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4585,9 +4569,8 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
// Load all solutions.
|
// Load all solutions.
|
||||||
if (soluce)
|
if (soluce)
|
||||||
{
|
{
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck() != 0) continue;
|
if (obj->GetTruck() != 0) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4602,9 +4585,8 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start all programs according to the command "run".
|
// Start all programs according to the command "run".
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
|
@ -4683,9 +4665,8 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank,
|
||||||
//! Saves all programs of all the robots
|
//! Saves all programs of all the robots
|
||||||
void CRobotMain::SaveAllScript()
|
void CRobotMain::SaveAllScript()
|
||||||
{
|
{
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
SaveOneScript(obj);
|
SaveOneScript(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4834,11 +4815,9 @@ char* CRobotMain::GetNewScriptName(ObjectType type, int rank)
|
||||||
bool CRobotMain::IsBusy()
|
bool CRobotMain::IsBusy()
|
||||||
{
|
{
|
||||||
if (CScriptFunctions::m_CompteurFileOpen > 0) return true;
|
if (CScriptFunctions::m_CompteurFileOpen > 0) return true;
|
||||||
|
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
|
{
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
if (brain != nullptr)
|
if (brain != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -4969,9 +4948,8 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
|
|
||||||
|
|
||||||
int objRank = 0;
|
int objRank = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
@ -5020,9 +4998,8 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
fWrite(&version, sizeof(long), 1, file); // version of CBOT
|
fWrite(&version, sizeof(long), 1, file); // version of CBOT
|
||||||
|
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
@ -5186,9 +5163,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
{
|
{
|
||||||
lastError = nbError;
|
lastError = nbError;
|
||||||
nbError = 0;
|
nbError = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
|
||||||
objRank = obj->GetDefRank();
|
objRank = obj->GetDefRank();
|
||||||
|
@ -5200,9 +5176,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
while (nbError > 0 && nbError != lastError);
|
while (nbError > 0 && nbError != lastError);
|
||||||
|
|
||||||
// Starts scripts
|
// Starts scripts
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
if (obj->GetDefRank() == -1) continue;
|
if (obj->GetDefRank() == -1) continue;
|
||||||
|
|
||||||
|
@ -5228,9 +5203,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
if (version == CBotProgram::GetVersion())
|
if (version == CBotProgram::GetVersion())
|
||||||
{
|
{
|
||||||
objRank = 0;
|
objRank = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
if (obj->GetType() == OBJECT_TOTO) continue;
|
if (obj->GetType() == OBJECT_TOTO) continue;
|
||||||
if (obj->GetType() == OBJECT_FIX) continue;
|
if (obj->GetType() == OBJECT_FIX) continue;
|
||||||
if (obj->GetTruck() != nullptr) continue;
|
if (obj->GetTruck() != nullptr) continue;
|
||||||
|
@ -5423,11 +5397,9 @@ void CRobotMain::ResetCreate()
|
||||||
CreateScene(m_dialog->GetSceneSoluce(), false, true);
|
CreateScene(m_dialog->GetSceneSoluce(), false, true);
|
||||||
|
|
||||||
if (!GetNiceReset()) return;
|
if (!GetNiceReset()) return;
|
||||||
|
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
|
{
|
||||||
ResetCap cap = obj->GetResetCap();
|
ResetCap cap = obj->GetResetCap();
|
||||||
if (cap == RESET_NONE) continue;
|
if (cap == RESET_NONE) continue;
|
||||||
|
|
||||||
|
@ -5456,9 +5428,8 @@ void CRobotMain::UpdateAudio(bool frame)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
// Do not use GetActif () because an invisible worm (underground)
|
// Do not use GetActif () because an invisible worm (underground)
|
||||||
// should be regarded as existing here!
|
// should be regarded as existing here!
|
||||||
if (obj->GetLock()) continue;
|
if (obj->GetLock()) continue;
|
||||||
|
@ -5580,9 +5551,8 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
Math::Vector oPos;
|
Math::Vector oPos;
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
// Do not use GetActif () because an invisible worm (underground)
|
// Do not use GetActif () because an invisible worm (underground)
|
||||||
// should be regarded as existing here!
|
// should be regarded as existing here!
|
||||||
if (obj->GetLock()) continue;
|
if (obj->GetLock()) continue;
|
||||||
|
@ -5858,11 +5828,9 @@ bool CRobotMain::GetRadar()
|
||||||
{
|
{
|
||||||
if (m_cheatRadar)
|
if (m_cheatRadar)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for(auto& it : m_objMan->GetAllObjects())
|
|
||||||
{
|
|
||||||
CObject* obj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* obj : m_objMan->GetAllObjects())
|
||||||
|
{
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
if (type == OBJECT_RADAR && !obj->GetLock())
|
if (type == OBJECT_RADAR && !obj->GetLock())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -548,7 +548,6 @@ bool CTaskBuild::Abort()
|
||||||
|
|
||||||
Error CTaskBuild::FlatFloor()
|
Error CTaskBuild::FlatFloor()
|
||||||
{
|
{
|
||||||
CObject *pObj;
|
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
Math::Vector center, pos, oPos, bPos;
|
Math::Vector center, pos, oPos, bPos;
|
||||||
Math::Point c, p;
|
Math::Point c, p;
|
||||||
|
@ -589,9 +588,8 @@ Error CTaskBuild::FlatFloor()
|
||||||
|
|
||||||
max = 100000.0f;
|
max = 100000.0f;
|
||||||
bBase = false;
|
bBase = false;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
if ( pObj == m_metal ) continue;
|
if ( pObj == m_metal ) continue;
|
||||||
|
@ -635,9 +633,8 @@ Error CTaskBuild::FlatFloor()
|
||||||
}
|
}
|
||||||
|
|
||||||
max = 100000.0f;
|
max = 100000.0f;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
if ( pObj == m_metal ) continue;
|
if ( pObj == m_metal ) continue;
|
||||||
|
@ -691,7 +688,7 @@ Error CTaskBuild::FlatFloor()
|
||||||
CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
|
CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
|
||||||
float aLimit, Error &err)
|
float aLimit, Error &err)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
CObject *pBest;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, a, aa, aBest, distance, magic;
|
float min, iAngle, a, aa, aBest, distance, magic;
|
||||||
|
@ -704,9 +701,8 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bMetal = false;
|
bMetal = false;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
if ( !pObj->GetActif() ) continue; // objet inactive?
|
if ( !pObj->GetActif() ) continue; // objet inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
|
||||||
|
@ -759,9 +755,8 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
|
||||||
{
|
{
|
||||||
std::vector<CObject*> objectsToDelete;
|
std::vector<CObject*> objectsToDelete;
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
CObject* obj = it.second.get();
|
|
||||||
ObjectType type = obj->GetType();
|
ObjectType type = obj->GetType();
|
||||||
if ( type != OBJECT_MARKSTONE &&
|
if ( type != OBJECT_MARKSTONE &&
|
||||||
type != OBJECT_MARKURANIUM &&
|
type != OBJECT_MARKURANIUM &&
|
||||||
|
|
|
@ -150,18 +150,12 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
|
||||||
|
|
||||||
int CTaskFlag::CountObject(ObjectType type)
|
int CTaskFlag::CountObject(ObjectType type)
|
||||||
{
|
{
|
||||||
ObjectType oType;
|
int count = 0;
|
||||||
CObject *pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
for (auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetEnable() ) continue;
|
||||||
if ( !pObj->GetEnable() ) continue;
|
|
||||||
|
|
||||||
oType = pObj->GetType();
|
ObjectType oType = obj->GetType();
|
||||||
if ( type == OBJECT_NULL )
|
if ( type == OBJECT_NULL )
|
||||||
{
|
{
|
||||||
if ( oType != OBJECT_FLAGb &&
|
if ( oType != OBJECT_FLAGb &&
|
||||||
|
|
|
@ -499,20 +499,13 @@ bool CTaskGoto::EventProcess(const Event &event)
|
||||||
|
|
||||||
CObject* CTaskGoto::WormSearch(Math::Vector &impact)
|
CObject* CTaskGoto::WormSearch(Math::Vector &impact)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Vector iPos = m_object->GetPosition(0);
|
||||||
CObject* pBest = 0;
|
float min = 1000000.0f;
|
||||||
Math::Vector iPos, oPos;
|
|
||||||
ObjectType oType;
|
|
||||||
float distance, min, radius;
|
|
||||||
|
|
||||||
iPos = m_object->GetPosition(0);
|
CObject* best = nullptr;
|
||||||
min = 1000000.0f;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType oType = obj->GetType();
|
||||||
|
|
||||||
oType = pObj->GetType();
|
|
||||||
if ( oType != OBJECT_MOBILEfa &&
|
if ( oType != OBJECT_MOBILEfa &&
|
||||||
oType != OBJECT_MOBILEta &&
|
oType != OBJECT_MOBILEta &&
|
||||||
oType != OBJECT_MOBILEwa &&
|
oType != OBJECT_MOBILEwa &&
|
||||||
|
@ -557,20 +550,22 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
|
||||||
oType != OBJECT_SAFE &&
|
oType != OBJECT_SAFE &&
|
||||||
oType != OBJECT_HUSTON ) continue;
|
oType != OBJECT_HUSTON ) continue;
|
||||||
|
|
||||||
if ( pObj->GetVirusMode() ) continue; // object infected?
|
if ( obj->GetVirusMode() ) continue; // object infected?
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, radius) ) continue;
|
Math::Vector oPos;
|
||||||
distance = Math::DistanceProjected(oPos, iPos);
|
float radius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, radius) ) continue;
|
||||||
|
float distance = Math::DistanceProjected(oPos, iPos);
|
||||||
if ( distance < min )
|
if ( distance < min )
|
||||||
{
|
{
|
||||||
min = distance;
|
min = distance;
|
||||||
pBest = pObj;
|
best = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( pBest == 0 ) return 0;
|
if ( best == nullptr ) return nullptr;
|
||||||
|
|
||||||
impact = pBest->GetPosition(0);
|
impact = best->GetPosition(0);
|
||||||
return pBest;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contaminate objects near the worm.
|
// Contaminate objects near the worm.
|
||||||
|
@ -1150,22 +1145,18 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
|
||||||
|
|
||||||
bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
|
bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
float dist, suppl;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetActif() ) continue;
|
||||||
|
if ( obj->GetTruck() != nullptr ) continue; // object transported?
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
Math::Vector oPos;
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
float suppl = 0.0f;
|
||||||
|
if ( !GetHotPoint(obj, oPos, false, 0.0f, suppl) ) continue;
|
||||||
if ( !GetHotPoint(pObj, oPos, false, 0.0f, suppl) ) continue;
|
float dist = Math::DistanceProjected(pos, oPos);
|
||||||
dist = Math::DistanceProjected(pos, oPos);
|
|
||||||
if ( dist <= margin )
|
if ( dist <= margin )
|
||||||
{
|
{
|
||||||
GetHotPoint(pObj, pos, true, distance, suppl);
|
GetHotPoint(obj, pos, true, distance, suppl);
|
||||||
distance += suppl;
|
distance += suppl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1314,9 +1305,8 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
|
||||||
|
|
||||||
min = 100000.0f;
|
min = 100000.0f;
|
||||||
bRadius = 0.0f;
|
bRadius = 0.0f;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
@ -1406,7 +1396,6 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
|
||||||
ObjectType iType, oType;
|
ObjectType iType, oType;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
Math::Point repulse;
|
Math::Point repulse;
|
||||||
CObject *pObj;
|
|
||||||
float gDist, add, addi, fac, dist, iRadius, oRadius;
|
float gDist, add, addi, fac, dist, iRadius, oRadius;
|
||||||
int j;
|
int j;
|
||||||
bool bAlien;
|
bool bAlien;
|
||||||
|
@ -1492,11 +1481,9 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
|
||||||
{
|
{
|
||||||
bAlien = true;
|
bAlien = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
||||||
|
@ -1574,7 +1561,6 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
|
||||||
{
|
{
|
||||||
ObjectType oType;
|
ObjectType oType;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
CObject *pObj;
|
|
||||||
float add, fac, dist, iRadius, oRadius, repulse;
|
float add, fac, dist, iRadius, oRadius, repulse;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
@ -1583,11 +1569,9 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
|
||||||
add = 0.0f;
|
add = 0.0f;
|
||||||
fac = 1.5f;
|
fac = 1.5f;
|
||||||
dir = 0.0f;
|
dir = 0.0f;
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( pObj->GetTruck() != 0 ) continue;
|
if ( pObj->GetTruck() != 0 ) continue;
|
||||||
|
|
||||||
|
@ -1889,18 +1873,15 @@ bool CTaskGoto::BitmapTestLine(const Math::Vector &start, const Math::Vector &go
|
||||||
|
|
||||||
void CTaskGoto::BitmapObject()
|
void CTaskGoto::BitmapObject()
|
||||||
{
|
{
|
||||||
CObject *pObj;
|
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
float iRadius, oRadius, h;
|
float iRadius, oRadius, h;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
m_object->GetCrashSphere(0, iPos, iRadius);
|
m_object->GetCrashSphere(0, iPos, iRadius);
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
|
|
|
@ -724,7 +724,7 @@ bool CTaskManip::Abort()
|
||||||
|
|
||||||
CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
|
CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
CObject *pBest;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, distance;
|
float min, distance;
|
||||||
|
@ -733,9 +733,8 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
|
||||||
|
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -777,7 +776,7 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
|
||||||
CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
||||||
float &distance, float &angle)
|
float &distance, float &angle)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
CObject *pBest;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, bAngle, aLimit, dLimit, f;
|
float min, iAngle, bAngle, aLimit, dLimit, f;
|
||||||
|
@ -801,9 +800,8 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -866,7 +864,7 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
|
||||||
CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
|
CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
|
||||||
float &distance, float &angle)
|
float &distance, float &angle)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
CObject *pBest;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, bAngle, aLimit, dLimit, f;
|
float min, iAngle, bAngle, aLimit, dLimit, f;
|
||||||
|
@ -889,9 +887,8 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -956,7 +953,6 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
|
||||||
float &height)
|
float &height)
|
||||||
{
|
{
|
||||||
Character* character;
|
Character* character;
|
||||||
CObject* pObj;
|
|
||||||
CObject* pPower;
|
CObject* pPower;
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
|
@ -982,11 +978,9 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
|
||||||
aLimit = 7.0f*Math::PI/180.0f;
|
aLimit = 7.0f*Math::PI/180.0f;
|
||||||
dLimit = MARGIN_FRIEND;
|
dLimit = MARGIN_FRIEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
@ -1329,25 +1323,19 @@ bool CTaskManip::TruckDeposeObject()
|
||||||
|
|
||||||
bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
|
bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
Math::Matrix* mat = m_object->GetWorldMatrix(0);
|
||||||
Math::Matrix* mat;
|
Math::Vector iPos = Transform(*mat, pos);
|
||||||
Math::Vector iPos, oPos;
|
|
||||||
float oRadius;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
mat = m_object->GetWorldMatrix(0);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
iPos = Transform(*mat, pos);
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj == m_object ) continue;
|
||||||
|
if ( !obj->GetActif() ) continue; // inactive?
|
||||||
|
if ( obj->GetTruck() != nullptr ) continue; // object transported?
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
Math::Vector oPos;
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
float oRadius = 0.0f;
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
int j = 0;
|
||||||
|
while ( obj->GetCrashSphere(j++, oPos, oRadius) )
|
||||||
j = 0;
|
|
||||||
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
|
|
||||||
{
|
{
|
||||||
if ( Math::Distance(iPos, oPos)-(oRadius+1.0f) < 2.0f )
|
if ( Math::Distance(iPos, oPos)-(oRadius+1.0f) < 2.0f )
|
||||||
{
|
{
|
||||||
|
|
|
@ -278,18 +278,11 @@ Error CTaskReset::IsEnded()
|
||||||
|
|
||||||
bool CTaskReset::SearchVehicle()
|
bool CTaskReset::SearchVehicle()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
Math::Vector oPos;
|
|
||||||
ObjectType type;
|
|
||||||
float oRadius, dist;
|
|
||||||
|
|
||||||
for (auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( obj == m_object ) continue;
|
||||||
|
|
||||||
if ( pObj == m_object ) continue;
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type != OBJECT_HUMAN &&
|
if ( type != OBJECT_HUMAN &&
|
||||||
type != OBJECT_TECH &&
|
type != OBJECT_TECH &&
|
||||||
type != OBJECT_MOBILEfa &&
|
type != OBJECT_MOBILEfa &&
|
||||||
|
@ -325,8 +318,10 @@ bool CTaskReset::SearchVehicle()
|
||||||
type != OBJECT_BEE &&
|
type != OBJECT_BEE &&
|
||||||
type != OBJECT_WORM ) continue;
|
type != OBJECT_WORM ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
Math::Vector oPos;
|
||||||
dist = Math::Distance(oPos, m_goal)-oRadius;
|
float oRadius = 0.0f;
|
||||||
|
if ( !obj->GetCrashSphere(0, oPos, oRadius) ) continue;
|
||||||
|
float dist = Math::Distance(oPos, m_goal)-oRadius;
|
||||||
|
|
||||||
if ( dist < 5.0f ) return true;
|
if ( dist < 5.0f ) return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,30 +551,23 @@ bool CTaskShield::CreateLight(Math::Vector pos)
|
||||||
|
|
||||||
void CTaskShield::IncreaseShield()
|
void CTaskShield::IncreaseShield()
|
||||||
{
|
{
|
||||||
ObjectType type;
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
CObject* pObj;
|
|
||||||
Math::Vector oPos;
|
|
||||||
float dist, shield;
|
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
ObjectType type = obj->GetType();
|
||||||
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_MOTHER ||
|
if ( type == OBJECT_MOTHER ||
|
||||||
type == OBJECT_ANT ||
|
type == OBJECT_ANT ||
|
||||||
type == OBJECT_SPIDER ||
|
type == OBJECT_SPIDER ||
|
||||||
type == OBJECT_BEE ||
|
type == OBJECT_BEE ||
|
||||||
type == OBJECT_WORM ) continue;
|
type == OBJECT_WORM ) continue;
|
||||||
|
|
||||||
oPos = pObj->GetPosition(0);
|
Math::Vector oPos = obj->GetPosition(0);
|
||||||
dist = Math::Distance(oPos, m_shieldPos);
|
float dist = Math::Distance(oPos, m_shieldPos);
|
||||||
if ( dist <= GetRadius()+10.0f )
|
if ( dist <= GetRadius()+10.0f )
|
||||||
{
|
{
|
||||||
shield = pObj->GetShield();
|
float shield = obj->GetShield();
|
||||||
shield += 0.1f;
|
shield += 0.1f;
|
||||||
if ( shield > 1.0f ) shield = 1.0f;
|
if ( shield > 1.0f ) shield = 1.0f;
|
||||||
pObj->SetShield(shield);
|
obj->SetShield(shield);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ bool CTaskTake::Abort()
|
||||||
CObject* CTaskTake::SearchTakeObject(float &angle,
|
CObject* CTaskTake::SearchTakeObject(float &angle,
|
||||||
float dLimit, float aLimit)
|
float dLimit, float aLimit)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pBest;
|
CObject *pBest;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
float min, iAngle, bAngle, a, distance;
|
float min, iAngle, bAngle, a, distance;
|
||||||
|
@ -311,9 +311,8 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
|
||||||
min = 1000000.0f;
|
min = 1000000.0f;
|
||||||
pBest = 0;
|
pBest = 0;
|
||||||
bAngle = 0.0f;
|
bAngle = 0.0f;
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
|
||||||
if ( type != OBJECT_FRET &&
|
if ( type != OBJECT_FRET &&
|
||||||
|
@ -363,7 +362,6 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
|
||||||
float dLimit, float aLimit)
|
float dLimit, float aLimit)
|
||||||
{
|
{
|
||||||
Character* character;
|
Character* character;
|
||||||
CObject* pObj;
|
|
||||||
CObject* pPower;
|
CObject* pPower;
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
|
@ -373,11 +371,9 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
|
||||||
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
|
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
|
||||||
iAngle = m_object->GetAngleY(0);
|
iAngle = m_object->GetAngleY(0);
|
||||||
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
|
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
|
@ -559,7 +555,6 @@ bool CTaskTake::TruckDeposeObject()
|
||||||
|
|
||||||
bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
|
bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
Math::Matrix* mat;
|
Math::Matrix* mat;
|
||||||
Math::Vector iPos, oPos;
|
Math::Vector iPos, oPos;
|
||||||
float oRadius;
|
float oRadius;
|
||||||
|
@ -567,11 +562,9 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
|
||||||
|
|
||||||
mat = m_object->GetWorldMatrix(0);
|
mat = m_object->GetWorldMatrix(0);
|
||||||
iPos = Transform(*mat, pos);
|
iPos = Transform(*mat, pos);
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if ( pObj == m_object ) continue;
|
if ( pObj == m_object ) continue;
|
||||||
if ( !pObj->GetActif() ) continue; // inactive?
|
if ( !pObj->GetActif() ) continue; // inactive?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
|
|
|
@ -339,7 +339,6 @@ bool CTaskTerraform::Abort()
|
||||||
|
|
||||||
bool CTaskTerraform::Terraform()
|
bool CTaskTerraform::Terraform()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
CBrain* brain;
|
CBrain* brain;
|
||||||
CMotion* motion;
|
CMotion* motion;
|
||||||
Gfx::CPyro* pyro;
|
Gfx::CPyro* pyro;
|
||||||
|
@ -349,11 +348,9 @@ bool CTaskTerraform::Terraform()
|
||||||
m_camera->StartEffect(Gfx::CAM_EFFECT_TERRAFORM, m_terraPos, 1.0f);
|
m_camera->StartEffect(Gfx::CAM_EFFECT_TERRAFORM, m_terraPos, 1.0f);
|
||||||
|
|
||||||
m_sound->Play(SOUND_THUMP, m_terraPos);
|
m_sound->Play(SOUND_THUMP, m_terraPos);
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
type = pObj->GetType();
|
type = pObj->GetType();
|
||||||
if ( type == OBJECT_NULL ) continue;
|
if ( type == OBJECT_NULL ) continue;
|
||||||
|
|
||||||
|
|
|
@ -2507,7 +2507,6 @@ void CPhysics::FloorAngle(const Math::Vector &pos, Math::Vector &angle)
|
||||||
|
|
||||||
int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
Gfx::CPyro* pyro;
|
Gfx::CPyro* pyro;
|
||||||
CPhysics* ph;
|
CPhysics* ph;
|
||||||
Math::Matrix matRotate;
|
Math::Matrix matRotate;
|
||||||
|
@ -2526,10 +2525,8 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
||||||
iPos = iiPos + (pos - m_object->GetPosition(0));
|
iPos = iiPos + (pos - m_object->GetPosition(0));
|
||||||
iType = m_object->GetType();
|
iType = m_object->GetType();
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
for(auto &it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
|
||||||
if ( pObj == m_object ) continue; // yourself?
|
if ( pObj == m_object ) continue; // yourself?
|
||||||
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
if ( pObj->GetTruck() != 0 ) continue; // object transported?
|
||||||
if ( !pObj->GetEnable() ) continue; // inactive?
|
if ( !pObj->GetEnable() ) continue; // inactive?
|
||||||
|
|
|
@ -94,7 +94,6 @@ static EventType table_sc_em[20] =
|
||||||
|
|
||||||
bool CMainShort::CreateShortcuts()
|
bool CMainShort::CreateShortcuts()
|
||||||
{
|
{
|
||||||
CObject* pObj;
|
|
||||||
CControl* pc;
|
CControl* pc;
|
||||||
ObjectType type;
|
ObjectType type;
|
||||||
Math::Point pos, dim;
|
Math::Point pos, dim;
|
||||||
|
@ -137,11 +136,9 @@ bool CMainShort::CreateShortcuts()
|
||||||
pos.x += dim.x*1.2f;
|
pos.x += dim.x*1.2f;
|
||||||
m_shortcuts[rank] = 0;
|
m_shortcuts[rank] = 0;
|
||||||
rank ++;
|
rank ++;
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
|
||||||
pObj = it.second.get();
|
|
||||||
|
|
||||||
|
for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
{
|
||||||
if ( !pObj->GetActif() ) continue;
|
if ( !pObj->GetActif() ) continue;
|
||||||
if ( !pObj->GetSelectable() ) continue;
|
if ( !pObj->GetSelectable() ) continue;
|
||||||
if ( pObj->GetProxyActivate() ) continue;
|
if ( pObj->GetProxyActivate() ) continue;
|
||||||
|
|
|
@ -185,22 +185,16 @@ bool CTarget::GetTooltip(Math::Point pos, std::string &name)
|
||||||
|
|
||||||
CObject* CTarget::DetectFriendObject(Math::Point pos)
|
CObject* CTarget::DetectFriendObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
ObjectType type;
|
int objRank = m_engine->DetectObject(pos);
|
||||||
CObject *pObj, *pTarget;
|
|
||||||
int objRank, j, rank;
|
|
||||||
|
|
||||||
objRank = m_engine->DetectObject(pos);
|
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||||
|
|
||||||
for(auto& it : CObjectManager::GetInstancePointer()->GetAllObjects())
|
|
||||||
{
|
{
|
||||||
pObj = it.second.get();
|
if ( !obj->GetActif() ) continue;
|
||||||
|
if ( obj->GetProxyActivate() ) continue;
|
||||||
|
if ( obj->GetSelect() ) continue;
|
||||||
|
|
||||||
if ( !pObj->GetActif() ) continue;
|
CObject* target = nullptr;
|
||||||
if ( pObj->GetProxyActivate() ) continue;
|
ObjectType type = obj->GetType();
|
||||||
if ( pObj->GetSelect() ) continue;
|
|
||||||
|
|
||||||
pTarget = 0;
|
|
||||||
type = pObj->GetType();
|
|
||||||
if ( type == OBJECT_DERRICK ||
|
if ( type == OBJECT_DERRICK ||
|
||||||
type == OBJECT_FACTORY ||
|
type == OBJECT_FACTORY ||
|
||||||
type == OBJECT_REPAIR ||
|
type == OBJECT_REPAIR ||
|
||||||
|
@ -247,29 +241,29 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
|
||||||
type == OBJECT_MOBILEit ||
|
type == OBJECT_MOBILEit ||
|
||||||
type == OBJECT_MOBILEdr )
|
type == OBJECT_MOBILEdr )
|
||||||
{
|
{
|
||||||
pTarget = pObj;
|
target = obj;
|
||||||
}
|
}
|
||||||
else if ( (type == OBJECT_POWER ||
|
else if ( (type == OBJECT_POWER ||
|
||||||
type == OBJECT_ATOMIC ) &&
|
type == OBJECT_ATOMIC ) &&
|
||||||
pObj->GetTruck() != 0 ) // battery used?
|
obj->GetTruck() != nullptr ) // battery used?
|
||||||
{
|
{
|
||||||
pTarget = pObj->GetTruck();
|
target = obj->GetTruck();
|
||||||
if ( pTarget->GetType() == OBJECT_MOBILEtg )
|
if ( target->GetType() == OBJECT_MOBILEtg )
|
||||||
{
|
{
|
||||||
pTarget = 0;
|
target = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( j=0 ; j<OBJECTMAXPART ; j++ )
|
for (int j=0 ; j<OBJECTMAXPART ; j++ )
|
||||||
{
|
{
|
||||||
rank = pObj->GetObjectRank(j);
|
int rank = obj->GetObjectRank(j);
|
||||||
if ( rank == -1 ) continue;
|
if ( rank == -1 ) continue;
|
||||||
if ( rank != objRank ) continue;
|
if ( rank != objRank ) continue;
|
||||||
return pTarget;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue