mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 19:50:00 +00:00
removed duplicate code
This commit is contained in:
parent
5abd466b5d
commit
03c4a979c8
|
@ -386,6 +386,34 @@ const int32 gFrequencyOfAttractorAttempt = 11;
|
||||||
const float gDistanceToSeekAttractors = 50.0f;
|
const float gDistanceToSeekAttractors = 50.0f;
|
||||||
const float gMaxDistanceToAttract = 10.0f;
|
const float gMaxDistanceToAttract = 10.0f;
|
||||||
|
|
||||||
|
/* Probably this was inlined */
|
||||||
|
void CCivilianPed::FindNearbyAttractorsSectorList(CPtrList& list, float& minDistance, C2dEffect*& pClosestAttractor, CEntity*& pAttractorEntity)
|
||||||
|
{
|
||||||
|
for (CPtrNode* pNode = list.first; pNode != nil; pNode = pNode->next) {
|
||||||
|
CEntity* pEntity = (CEntity*)pNode->item;
|
||||||
|
//if (pEntity->IsObject() && (CObject*)(pEntity)->IsBroken())
|
||||||
|
//continue;
|
||||||
|
CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(pEntity->GetModelIndex());
|
||||||
|
for (int i = 0; i < pModelInfo->GetNum2dEffects(); i++) {
|
||||||
|
C2dEffect* pEffect = pModelInfo->Get2dEffect(i);
|
||||||
|
if (pEffect->type != EFFECT_PED_ATTRACTOR)
|
||||||
|
continue;
|
||||||
|
if (!IsAttractedTo(pEffect->pedattr.type))
|
||||||
|
continue;
|
||||||
|
CVector pos;
|
||||||
|
CPedAttractorManager::ComputeEffectPos(pEffect, pEntity->GetMatrix(), pos);
|
||||||
|
if ((pos - GetPosition()).MagnitudeSqr() < minDistance) {
|
||||||
|
CPedAttractorManager* pManager = GetPedAttractorManager();
|
||||||
|
if (pManager->HasEmptySlot(pEffect) && pManager->IsApproachable(pEffect, pEntity->GetMatrix(), 0, this)) {
|
||||||
|
pClosestAttractor = pEffect;
|
||||||
|
pAttractorEntity = pEntity;
|
||||||
|
minDistance = (pos - GetPosition()).MagnitudeSqr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CCivilianPed::UseNearbyAttractors()
|
void CCivilianPed::UseNearbyAttractors()
|
||||||
{
|
{
|
||||||
if (CWeather::Rain < 0.2f && !m_bAttractorUnk)
|
if (CWeather::Rain < 0.2f && !m_bAttractorUnk)
|
||||||
|
@ -420,52 +448,8 @@ void CCivilianPed::UseNearbyAttractors()
|
||||||
for (int y = ystart; y <= yend; y++) {
|
for (int y = ystart; y <= yend; y++) {
|
||||||
for (int x = xstart; x <= xend; x++) {
|
for (int x = xstart; x <= xend; x++) {
|
||||||
CSector* s = CWorld::GetSector(x, y);
|
CSector* s = CWorld::GetSector(x, y);
|
||||||
for (CPtrNode* pNode = s->m_lists[ENTITYLIST_BUILDINGS].first; pNode != nil; pNode = pNode->next) {
|
FindNearbyAttractorsSectorList(s->m_lists[ENTITYLIST_BUILDINGS], minDistance, pClosestAttractor, pAttractorEntity);
|
||||||
CEntity* pEntity = (CEntity*)pNode->item;
|
FindNearbyAttractorsSectorList(s->m_lists[ENTITYLIST_OBJECTS], minDistance, pClosestAttractor, pAttractorEntity);
|
||||||
//if (pEntity->IsObject() && (CObject*)(pEntity)->IsBroken())
|
|
||||||
//continue;
|
|
||||||
CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(pEntity->GetModelIndex());
|
|
||||||
for (int i = 0; i < pModelInfo->GetNum2dEffects(); i++) {
|
|
||||||
C2dEffect* pEffect = pModelInfo->Get2dEffect(i);
|
|
||||||
if (pEffect->type != EFFECT_PED_ATTRACTOR)
|
|
||||||
continue;
|
|
||||||
if (!IsAttractedTo(pEffect->pedattr.type))
|
|
||||||
continue;
|
|
||||||
CVector pos;
|
|
||||||
CPedAttractorManager::ComputeEffectPos(pEffect, pEntity->GetMatrix(), pos);
|
|
||||||
if ((pos - GetPosition()).MagnitudeSqr() < minDistance) {
|
|
||||||
CPedAttractorManager* pManager = GetPedAttractorManager();
|
|
||||||
if (pManager->HasEmptySlot(pEffect) && pManager->IsApproachable(pEffect, pEntity->GetMatrix(), 0, this)) {
|
|
||||||
pClosestAttractor = pEffect;
|
|
||||||
pAttractorEntity = pEntity;
|
|
||||||
minDistance = (pos - GetPosition()).MagnitudeSqr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (CPtrNode* pNode = s->m_lists[ENTITYLIST_OBJECTS].first; pNode != nil; pNode = pNode->next) {
|
|
||||||
CEntity* pEntity = (CEntity*)pNode->item;
|
|
||||||
//if (pEntity->IsObject() && (CObject*)(pEntity)->IsBroken())
|
|
||||||
//continue;
|
|
||||||
CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(pEntity->GetModelIndex());
|
|
||||||
for (int i = 0; i < pModelInfo->GetNum2dEffects(); i++) {
|
|
||||||
C2dEffect* pEffect = pModelInfo->Get2dEffect(i);
|
|
||||||
if (pEffect->type != EFFECT_PED_ATTRACTOR)
|
|
||||||
continue;
|
|
||||||
if (!IsAttractedTo(pEffect->pedattr.type))
|
|
||||||
continue;
|
|
||||||
CVector pos;
|
|
||||||
CPedAttractorManager::ComputeEffectPos(pEffect, pEntity->GetMatrix(), pos);
|
|
||||||
if ((pos - GetPosition()).MagnitudeSqr() < minDistance) {
|
|
||||||
CPedAttractorManager* pManager = GetPedAttractorManager();
|
|
||||||
if (pManager->HasEmptySlot(pEffect) && pManager->IsApproachable(pEffect, pEntity->GetMatrix(), 0, this)) {
|
|
||||||
pClosestAttractor = pEffect;
|
|
||||||
pAttractorEntity = pEntity;
|
|
||||||
minDistance = (pos - GetPosition()).MagnitudeSqr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pClosestAttractor)
|
if (pClosestAttractor)
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
void CivilianAI(void);
|
void CivilianAI(void);
|
||||||
void ProcessControl(void);
|
void ProcessControl(void);
|
||||||
void UseNearbyAttractors(void);
|
void UseNearbyAttractors(void);
|
||||||
|
void FindNearbyAttractorsSectorList(CPtrList&, float&, C2dEffect*&, CEntity*&);
|
||||||
bool IsAttractedTo(int8);
|
bool IsAttractedTo(int8);
|
||||||
};
|
};
|
||||||
#ifndef PED_SKIN
|
#ifndef PED_SKIN
|
||||||
|
|
Loading…
Reference in a new issue