feat: add texture destory function

This commit is contained in:
2026-01-15 20:49:11 +08:00
parent 4ae99a44a3
commit 562599b8b4
8 changed files with 65 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
GameSession::GameSession()
{
m_board = std::make_unique<Board>(7, 7);
}
@@ -61,6 +62,7 @@ bool GameSession::executeAction(int toRow, int toCol) {
if (m_currentActionType == ActionType::GROW) {
if (Rule::canGrow(m_board.get(), fromRow, fromCol, toRow, toCol, m_currentPlayer)) {
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
m_gamePieceEventCallback(GamePieceEvent::PLACE_PIECE, toRow, toCol);
// 如果执行了操作就擦除
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
return true;
@@ -69,7 +71,9 @@ bool GameSession::executeAction(int toRow, int toCol) {
if (m_currentActionType == ActionType::MOVE) {
if (Rule::canMove(m_board.get(), fromRow, fromCol, toRow, toCol, m_currentPlayer)) {
m_board->removePieceAt(fromRow, fromCol);
m_gamePieceEventCallback(GamePieceEvent::REMOVE_PIECE, fromRow, fromCol);
m_board->removePieceAt(toRow, toCol);
m_gamePieceEventCallback(GamePieceEvent::REMOVE_PIECE, toRow, toCol);
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
@@ -79,8 +83,9 @@ bool GameSession::executeAction(int toRow, int toCol) {
if (m_currentActionType == ActionType::SPORE) {
if (Rule::canSpore(m_board.get(), fromRow, fromCol, toRow, toCol, m_currentPlayer)) {
m_board->removePieceAt(fromRow, fromCol);
m_gamePieceEventCallback(GamePieceEvent::REMOVE_PIECE, fromRow, fromCol);
m_board->placePieceAt(toRow, toCol, m_currentPlayer);
m_gamePieceEventCallback(GamePieceEvent::PLACE_PIECE, toRow, toCol);
markComponentAsUsed(getOldComponentID(fromRow, fromCol));
return true;
}