|
@@ -18,29 +18,18 @@ Chest::Chest(int typeId, Framework::Vec3<int> pos, int dimensionId)
|
|
|
|
|
|
|
|
void Chest::onDialogClosed(Framework::Text dialogId)
|
|
void Chest::onDialogClosed(Framework::Text dialogId)
|
|
|
{
|
|
{
|
|
|
- if (dialogId.istGleich(getDialogId()))
|
|
|
|
|
- {
|
|
|
|
|
- open = 0;
|
|
|
|
|
- userEntityId = 0;
|
|
|
|
|
- NetworkMessage* msg = new NetworkMessage();
|
|
|
|
|
- msg->animateBlockBone(getDimensionId(),
|
|
|
|
|
- Game::getChunkCenter(getPos().x, getPos().y),
|
|
|
|
|
- Chunk::index(Dimension::chunkCoordinates(getPos())),
|
|
|
|
|
- 1,
|
|
|
|
|
- 1.0,
|
|
|
|
|
- Framework::Vec3<float>(0.5f, 0.f, 0.45f),
|
|
|
|
|
- Framework::Vec3<float>(
|
|
|
|
|
- 0.0f, 0.f, 0.f)); // close the chest over one second
|
|
|
|
|
- broadcastMessage(msg);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-Framework::Text Chest::getDialogId() const
|
|
|
|
|
-{
|
|
|
|
|
- Framework::Text dialogId = "chest_inventory_";
|
|
|
|
|
- dialogId.append() << getDimensionId() << "," << getPos().x << ","
|
|
|
|
|
- << getPos().y << "," << getPos().z;
|
|
|
|
|
- return dialogId;
|
|
|
|
|
|
|
+ open = 0;
|
|
|
|
|
+ userEntityId = 0;
|
|
|
|
|
+ NetworkMessage* msg = new NetworkMessage();
|
|
|
|
|
+ msg->animateBlockBone(getDimensionId(),
|
|
|
|
|
+ Game::getChunkCenter(getPos().x, getPos().y),
|
|
|
|
|
+ Chunk::index(Dimension::chunkCoordinates(getPos())),
|
|
|
|
|
+ 1,
|
|
|
|
|
+ 1.0,
|
|
|
|
|
+ Framework::Vec3<float>(0.5f, 0.f, 0.45f),
|
|
|
|
|
+ Framework::Vec3<float>(
|
|
|
|
|
+ 0.0f, 0.f, 0.f)); // close the chest over one second
|
|
|
|
|
+ broadcastMessage(msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool Chest::onTick(TickQueue* zQueue, int numTicks, bool& blocked)
|
|
bool Chest::onTick(TickQueue* zQueue, int numTicks, bool& blocked)
|
|
@@ -49,7 +38,7 @@ bool Chest::onTick(TickQueue* zQueue, int numTicks, bool& blocked)
|
|
|
{
|
|
{
|
|
|
if (!Game::INSTANCE->zEntity(userEntityId))
|
|
if (!Game::INSTANCE->zEntity(userEntityId))
|
|
|
{
|
|
{
|
|
|
- onDialogClosed(getDialogId());
|
|
|
|
|
|
|
+ onDialogClosed("");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return open;
|
|
return open;
|
|
@@ -65,19 +54,23 @@ bool Chest::interact(Item* zItem, Entity* zActor, bool& itemChanged)
|
|
|
}
|
|
}
|
|
|
if (!open)
|
|
if (!open)
|
|
|
{
|
|
{
|
|
|
- userEntityId = zActor->getId();
|
|
|
|
|
- open = 1;
|
|
|
|
|
result = Block::interact(zItem, zActor, itemChanged);
|
|
result = Block::interact(zItem, zActor, itemChanged);
|
|
|
- NetworkMessage* msg = new NetworkMessage();
|
|
|
|
|
- msg->animateBlockBone(getDimensionId(),
|
|
|
|
|
- Game::getChunkCenter(getPos().x, getPos().y),
|
|
|
|
|
- Chunk::index(Dimension::chunkCoordinates(getPos())),
|
|
|
|
|
- 1,
|
|
|
|
|
- 1.0,
|
|
|
|
|
- Framework::Vec3<float>(0.5f, 0.f, 0.45f),
|
|
|
|
|
- Framework::Vec3<float>(
|
|
|
|
|
- 0.0f, (float)(PI / 2.0), 0.f)); // open the chest over 1 second
|
|
|
|
|
- broadcastMessage(msg);
|
|
|
|
|
|
|
+ if (result)
|
|
|
|
|
+ {
|
|
|
|
|
+ userEntityId = zActor->getId();
|
|
|
|
|
+ open = 1;
|
|
|
|
|
+ NetworkMessage* msg = new NetworkMessage();
|
|
|
|
|
+ msg->animateBlockBone(getDimensionId(),
|
|
|
|
|
+ Game::getChunkCenter(getPos().x, getPos().y),
|
|
|
|
|
+ Chunk::index(Dimension::chunkCoordinates(getPos())),
|
|
|
|
|
+ 1,
|
|
|
|
|
+ 1.0,
|
|
|
|
|
+ Framework::Vec3<float>(0.5f, 0.f, 0.45f),
|
|
|
|
|
+ Framework::Vec3<float>(0.0f,
|
|
|
|
|
+ (float)(PI / 2.0),
|
|
|
|
|
+ 0.f)); // open the chest over 1 second
|
|
|
|
|
+ broadcastMessage(msg);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
unlock();
|
|
unlock();
|
|
|
return result;
|
|
return result;
|