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

Method SetTile

src/game/editor/mapitems/layer_game.cpp:29–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void CLayerGame::SetTile(int x, int y, CTile Tile)
30{
31 if(Tile.m_Index == TILE_THROUGH_CUT && Editor()->m_SelectEntitiesImage == "DDNet")
32 {
33 if(!Map()->m_pFrontLayer)
34 {
35 std::shared_ptr<CLayer> pLayerFront = std::make_shared<CLayerFront>(Map(), m_Width, m_Height);
36 Map()->MakeFrontLayer(pLayerFront);
37 Map()->m_pGameGroup->AddLayer(pLayerFront);
38 int GameGroupIndex = std::find(Map()->m_vpGroups.begin(), Map()->m_vpGroups.end(), Map()->m_pGameGroup) - Map()->m_vpGroups.begin();
39 int LayerIndex = Map()->m_vpGroups[GameGroupIndex]->m_vpLayers.size() - 1;
40 Map()->m_EditorHistory.RecordAction(std::make_shared<CEditorActionAddLayer>(Map(), GameGroupIndex, LayerIndex));
41 }
42 CLayerTiles::SetTile(x, y, CTile{TILE_NOHOOK});
43 Map()->m_pFrontLayer->CLayerTiles::SetTile(x, y, CTile{TILE_THROUGH_CUT}); // NOLINT(bugprone-parent-virtual-call)
44 }
45 else
46 {
47 if(Editor()->m_SelectEntitiesImage == "DDNet" && Map()->m_pFrontLayer && Map()->m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT)
48 {
49 Map()->m_pFrontLayer->CLayerTiles::SetTile(x, y, CTile{TILE_AIR}); // NOLINT(bugprone-parent-virtual-call)
50 }
51 if(Editor()->IsAllowPlaceUnusedTiles() || IsValidGameTile(Tile.m_Index))
52 {
53 CLayerTiles::SetTile(x, y, Tile);
54 }
55 else
56 {
57 CLayerTiles::SetTile(x, y, CTile{TILE_AIR});
58 ShowPreventUnusedTilesWarning();
59 }
60 }
61}
62
63bool CLayerGame::IsEmpty() const
64{

Callers 1

PlaceBorderTilesMethod · 0.45

Calls 9

MapFunction · 0.85
IsValidGameTileFunction · 0.85
MakeFrontLayerMethod · 0.80
AddLayerMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
RecordActionMethod · 0.80
GetTileMethod · 0.45

Tested by

no test coverage detected