MCPcopy Create free account
hub / github.com/ddnet/ddnet / RenderGameEntities

Method RenderGameEntities

src/game/editor/editor.cpp:6778–6927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6776}
6777
6778void CEditor::RenderGameEntities(const std::shared_ptr<CLayerTiles> &pTiles)
6779{
6780 const CGameClient *pGameClient = (CGameClient *)Kernel()->RequestInterface<IGameClient>();
6781 const float TileSize = 32.f;
6782
6783 for(int y = 0; y < pTiles->m_Height; y++)
6784 {
6785 for(int x = 0; x < pTiles->m_Width; x++)
6786 {
6787 const unsigned char Index = pTiles->m_pTiles[y * pTiles->m_Width + x].m_Index - ENTITY_OFFSET;
6788 if(!((Index >= ENTITY_FLAGSTAND_RED && Index <= ENTITY_WEAPON_LASER) ||
6789 (Index >= ENTITY_ARMOR_SHOTGUN && Index <= ENTITY_ARMOR_LASER)))
6790 continue;
6791
6792 const bool DDNetOrCustomEntities = std::find_if(std::begin(gs_apModEntitiesNames), std::end(gs_apModEntitiesNames),
6793 [&](const char *pEntitiesName) { return str_comp_nocase(m_SelectEntitiesImage.c_str(), pEntitiesName) == 0 &&
6794 str_comp_nocase(pEntitiesName, "ddnet") != 0; }) == std::end(gs_apModEntitiesNames);
6795
6796 vec2 Pos(x * TileSize, y * TileSize);
6797 vec2 Scale;
6798 int VisualSize;
6799
6800 if(Index == ENTITY_FLAGSTAND_RED)
6801 {
6802 Graphics()->TextureSet(pGameClient->m_GameSkin.m_SpriteFlagRed);
6803 Scale = vec2(42, 84);
6804 VisualSize = 1;
6805 Pos.y -= (Scale.y / 2.f) * 0.75f;
6806 }
6807 else if(Index == ENTITY_FLAGSTAND_BLUE)
6808 {
6809 Graphics()->TextureSet(pGameClient->m_GameSkin.m_SpriteFlagBlue);
6810 Scale = vec2(42, 84);
6811 VisualSize = 1;
6812 Pos.y -= (Scale.y / 2.f) * 0.75f;
6813 }
6814 else if(Index == ENTITY_ARMOR_1)
6815 {
6816 Graphics()->TextureSet(pGameClient->m_GameSkin.m_SpritePickupArmor);
6817 Graphics()->GetSpriteScale(SPRITE_PICKUP_HEALTH, Scale.x, Scale.y);
6818 VisualSize = 64;
6819 }
6820 else if(Index == ENTITY_HEALTH_1)
6821 {
6822 Graphics()->TextureSet(pGameClient->m_GameSkin.m_SpritePickupHealth);
6823 Graphics()->GetSpriteScale(SPRITE_PICKUP_HEALTH, Scale.x, Scale.y);
6824 VisualSize = 64;
6825 }
6826 else if(Index == ENTITY_WEAPON_SHOTGUN)
6827 {
6828 Graphics()->TextureSet(pGameClient->m_GameSkin.m_aSpritePickupWeapons[WEAPON_SHOTGUN]);
6829 Graphics()->GetSpriteScale(SPRITE_PICKUP_SHOTGUN, Scale.x, Scale.y);
6830 VisualSize = g_pData->m_Weapons.m_aId[WEAPON_SHOTGUN].m_VisualSize;
6831 }
6832 else if(Index == ENTITY_WEAPON_GRENADE)
6833 {
6834 Graphics()->TextureSet(pGameClient->m_GameSkin.m_aSpritePickupWeapons[WEAPON_GRENADE]);
6835 Graphics()->GetSpriteScale(SPRITE_PICKUP_GRENADE, Scale.x, Scale.y);

Callers 1

RenderMethod · 0.80

Calls 11

str_comp_nocaseFunction · 0.85
GraphicsFunction · 0.85
directionFunction · 0.85
TextureSetMethod · 0.80
GetSpriteScaleMethod · 0.80
QuadsBeginMethod · 0.80
QuadsSetRotationMethod · 0.80
GlobalTimeMethod · 0.80
QuadsDrawTLMethod · 0.80
QuadsEndMethod · 0.80
ClientFunction · 0.70

Tested by

no test coverage detected