Only predict pickup if affected by movers

This commit is contained in:
Freddie Wang 2021-05-27 15:45:41 +08:00
parent 0d0f22ae8c
commit 769970b30b
3 changed files with 21 additions and 6 deletions

View file

@ -320,12 +320,15 @@ void CItems::OnRender()
} }
for(auto *pPickup = (CPickup *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_PICKUP); pPickup; pPickup = (CPickup *)pPickup->NextEntity()) for(auto *pPickup = (CPickup *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_PICKUP); pPickup; pPickup = (CPickup *)pPickup->NextEntity())
{ {
if(auto *pPrev = (CPickup *)GameClient()->m_PrevPredictedWorld.GetEntity(pPickup->ID(), CGameWorld::ENTTYPE_PICKUP)) if(pPickup->InDDNetTile())
{ {
CNetObj_Pickup Data, Prev; if(auto *pPrev = (CPickup *)GameClient()->m_PrevPredictedWorld.GetEntity(pPickup->ID(), CGameWorld::ENTTYPE_PICKUP))
pPickup->FillInfo(&Data); {
pPrev->FillInfo(&Prev); CNetObj_Pickup Data, Prev;
RenderPickup(&Prev, &Data, true); pPickup->FillInfo(&Data);
pPrev->FillInfo(&Prev);
RenderPickup(&Prev, &Data, true);
}
} }
} }
} }
@ -369,7 +372,11 @@ void CItems::OnRender()
else if(Item.m_Type == NETOBJTYPE_PICKUP) else if(Item.m_Type == NETOBJTYPE_PICKUP)
{ {
if(UsePredicted) if(UsePredicted)
continue; {
auto *pPickup = (CPickup *)GameClient()->m_GameWorld.FindMatch(Item.m_ID, Item.m_Type, pData);
if(pPickup && pPickup->InDDNetTile())
continue;
}
const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID);
if(pPrev) if(pPrev)
RenderPickup((const CNetObj_Pickup *)pPrev, (const CNetObj_Pickup *)pData); RenderPickup((const CNetObj_Pickup *)pPrev, (const CNetObj_Pickup *)pData);

View file

@ -77,8 +77,13 @@ void CPickup::Move()
int index = Collision()->IsMover(m_Pos.x, m_Pos.y, &Flags); int index = Collision()->IsMover(m_Pos.x, m_Pos.y, &Flags);
if(index) if(index)
{ {
m_IsCoreActive = true;
m_Core = Collision()->CpSpeed(index, Flags); m_Core = Collision()->CpSpeed(index, Flags);
} }
else
{
m_IsCoreActive = false;
}
m_Pos += m_Core; m_Pos += m_Core;
} }
} }
@ -91,6 +96,7 @@ CPickup::CPickup(CGameWorld *pGameWorld, int ID, CNetObj_Pickup *pPickup) :
m_Type = pPickup->m_Type; m_Type = pPickup->m_Type;
m_Subtype = pPickup->m_Subtype; m_Subtype = pPickup->m_Subtype;
m_Core = vec2(0.f, 0.f); m_Core = vec2(0.f, 0.f);
m_IsCoreActive = false;
m_ID = ID; m_ID = ID;
m_Layer = LAYER_GAME; m_Layer = LAYER_GAME;
m_Number = 0; m_Number = 0;

View file

@ -15,6 +15,7 @@ public:
CPickup(CGameWorld *pGameWorld, int ID, CNetObj_Pickup *pPickup); CPickup(CGameWorld *pGameWorld, int ID, CNetObj_Pickup *pPickup);
void FillInfo(CNetObj_Pickup *pPickup); void FillInfo(CNetObj_Pickup *pPickup);
bool Match(CPickup *pPickup); bool Match(CPickup *pPickup);
bool InDDNetTile() { return m_IsCoreActive; }
private: private:
int m_Type; int m_Type;
@ -24,6 +25,7 @@ private:
void Move(); void Move();
vec2 m_Core; vec2 m_Core;
bool m_IsCoreActive;
}; };
#endif #endif