Blocks.cpp: add character support to

This commit is contained in:
zvon 2021-08-08 21:22:44 +02:00
parent c7309d56a3
commit c183e58f6e

View File

@ -11,6 +11,7 @@
#include "blocks/coineditorblock.hpp"
#include "blocks/coinblock.hpp"
#include "blocks/mushroomblock.hpp"
#include "blocks/goombablock.hpp"
#include "mario.hpp"
#define CAN_BE_DESTROYED_FLAG 0x0000000000000001
@ -36,7 +37,8 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
destroy();
}
if ( !_tool && !_terrain &&
visitor.getVisitorType() == VisitorType::Modifier ) {
(visitor.getVisitorType() == VisitorType::Modifier ||
visitor.getVisitorType() == VisitorType::Character)) {
destroy();
}
#else
@ -305,6 +307,7 @@ const std::vector< uint64_t > possibleMods = {
const std::vector< uint64_t > possibleCharacters = {
MARIO_ID,
GOOMBA_ID,
};
const std::vector< LandType::Value > possibleLands = {
@ -560,6 +563,10 @@ createBlockById( uint64_t id, int x, int y,
result = std::static_pointer_cast< MarioBlock >(
std::make_shared< Mario >( x, y, renderer ) );
break;
case GOOMBA_ID:
result = std::static_pointer_cast< MarioBlock >(
std::make_shared< GoombaBlock >( x, y, renderer ) );
break;
case DESTRUCTIBLE_MODIFIER_ID:
result = std::static_pointer_cast< MarioBlock >(
std::make_shared< DestructibleModifierBlock >( x, y, renderer ) );
@ -647,8 +654,7 @@ enum BlockRole::Value getBlockRole( uint64_t id ) {
if ( id == MARIO_ID )
return BlockRole::MARIO;
if ( id < MARIO_ID )
return BlockRole::MODIFIER;
// TODO modifier/character
return BlockRole::CHARACTER;
return BlockRole::MODIFIER;
}