Jelajahi Sumber

placed blocks are now interactable

Kolja Strohm 3 tahun lalu
induk
melakukan
7cc4a6ead4
3 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 3 1
      FactoryCraft/Block.cpp
  2. 1 0
      FactoryCraft/Block.h
  3. 2 0
      FactoryCraft/BlockType.cpp

+ 3 - 1
FactoryCraft/Block.cpp

@@ -258,7 +258,7 @@ bool BasicBlockItem::canBeStackedWith( Item* zItem ) const
             maxHP == item->maxHP &&
             hardness == item->hardness &&
             toolId == item->toolId &&
-            speedModifier == item->speedModifier;
+            speedModifier == item->speedModifier && interactable == item->interactable;
     }
     return 0;
 }
@@ -281,6 +281,7 @@ void BasicBlockItemType::loadSuperItem( Item* zItem, Framework::StreamReader* zR
     zReader->lese( (char*)&item->hardness, 4 );
     zReader->lese( (char*)&item->toolId, 4 );
     zReader->lese( (char*)&item->speedModifier, 4 );
+    zReader->lese( (char*)&item->interactable, 1 );
 }
 
 void BasicBlockItemType::saveSuperItem( const Item* zItem, Framework::StreamWriter* zWriter ) const
@@ -296,6 +297,7 @@ void BasicBlockItemType::saveSuperItem( const Item* zItem, Framework::StreamWrit
     zWriter->schreibe( (char*)&item->hardness, 4 );
     zWriter->schreibe( (char*)&item->toolId, 4 );
     zWriter->schreibe( (char*)&item->speedModifier, 4 );
+    zWriter->schreibe( (char*)&item->interactable, 1 );
 }
 
 void BasicBlockItemType::initializeItem( BasicBlockItem* zItem, bool transparent, bool passable, float hp, float maxHP, float hardness, int toolId, float speedModifier ) const

+ 1 - 0
FactoryCraft/Block.h

@@ -105,6 +105,7 @@ protected:
     float hardness;
     int toolId;
     float speedModifier;
+    bool interactable;
 
 public:
     BasicBlockItem( const ItemType* zType, const BlockType* zPlacedBlockType, const char* name );

+ 2 - 0
FactoryCraft/BlockType.cpp

@@ -63,6 +63,7 @@ void BlockType::createSuperBlock( Block* zBlock, Item* zItem ) const
     zBlock->hardness = item->hardness;
     zBlock->speedModifier = item->speedModifier;
     zBlock->zTool = item->toolId >= 0 ? StaticRegistry<ItemType>::INSTANCE.zElement( item->toolId ) : 0;
+    zBlock->interactable = item->interactable;
 }
 
 void BlockType::createSuperItem( Block* zBlock, Item* zItem ) const
@@ -79,6 +80,7 @@ void BlockType::createSuperItem( Block* zBlock, Item* zItem ) const
     item->hardness = zBlock->hardness;
     item->speedModifier = zBlock->speedModifier;
     item->toolId = zBlock->zTool ? zBlock->zTool->getId() : -1;
+    item->interactable = zBlock->interactable;
 }
 
 Block* BlockType::loadBlock( Framework::Vec3<int> position, Framework::StreamReader* zReader ) const