aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/items/item.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-09-24 14:10:54 -0400
committerMatthew Hoops2011-09-24 14:10:54 -0400
commit59f7e1deeaa15c87adbe073105ea512d1972cde0 (patch)
tree7f39d7d8beba4df409ea18f681ce3029e308195e /engines/pegasus/items/item.cpp
parente5a2dec9c803f75f7aa0f695235e0c08a6d5e7eb (diff)
downloadscummvm-rg350-59f7e1deeaa15c87adbe073105ea512d1972cde0.tar.gz
scummvm-rg350-59f7e1deeaa15c87adbe073105ea512d1972cde0.tar.bz2
scummvm-rg350-59f7e1deeaa15c87adbe073105ea512d1972cde0.zip
PEGASUS: Import AI code and relevant items
Diffstat (limited to 'engines/pegasus/items/item.cpp')
-rwxr-xr-xengines/pegasus/items/item.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index e4f1b712d7..aba9741940 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -30,8 +30,11 @@
#include "pegasus/elements.h"
#include "pegasus/pegasus.h"
#include "pegasus/surface.h"
+#include "pegasus/ai/ai_area.h"
#include "pegasus/items/item.h"
#include "pegasus/items/itemlist.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/inventory/inventoryitem.h"
namespace Pegasus {
@@ -128,30 +131,20 @@ Item::~Item() {
delete[] _itemExtras.entries;
}
-Common::Error Item::writeToStream(Common::WriteStream *stream) {
+void Item::writeToStream(Common::WriteStream *stream) {
stream->writeUint16BE(_itemNeighborhood);
stream->writeUint16BE(_itemRoom);
stream->writeByte(_itemDirection);
stream->writeUint16BE(_itemOwnerID);
stream->writeUint16BE(_itemState);
-
- if (stream->err())
- return Common::kWritingFailed;
-
- return Common::kNoError;
}
-Common::Error Item::readFromStream(Common::ReadStream *stream) {
+void Item::readFromStream(Common::ReadStream *stream) {
_itemNeighborhood = stream->readUint16BE();
_itemRoom = stream->readUint16BE();
_itemDirection = stream->readByte();
_itemOwnerID = stream->readUint16BE();
_itemState = stream->readUint16BE();
-
- if (stream->err())
- return Common::kReadingFailed;
-
- return Common::kNoError;
}
tActorID Item::getItemOwner() const {
@@ -181,7 +174,11 @@ tItemState Item::getItemState() const {
void Item::setItemState(const tItemState state) {
if (state != _itemState) {
_itemState = state;
- // TODO: Selection
+
+ if (getItemType() == kInventoryItemType && ((PegasusEngine *)g_engine)->getCurrentInventoryItem() == (InventoryItem *)this)
+ select();
+ else if (getItemType() == kBiochipItemType && ((PegasusEngine *)g_engine)->getCurrentBiochip() == (BiochipItem *)this)
+ select();
}
}
@@ -224,14 +221,24 @@ TimeValue Item::getSharedAreaTime() const {
void Item::select() {
_isSelected = true;
- // TODO: AI
+ if (g_AIArea) {
+ if (getItemType() == kInventoryItemType)
+ g_AIArea->setAIAreaToTime(kInventorySignature, kMiddleAreaSignature, getSharedAreaTime());
+ else
+ g_AIArea->setAIAreaToTime(kBiochipSignature, kMiddleAreaSignature, getSharedAreaTime());
+ }
}
void Item::deselect() {
_isActive = false;
_isSelected = false;
- // TODO: AI
+ if (g_AIArea) {
+ if (getItemType() == kInventoryItemType)
+ g_AIArea->setAIAreaToTime(kInventorySignature, kMiddleAreaSignature, 0xffffffff);
+ else
+ g_AIArea->setAIAreaToTime(kBiochipSignature, kMiddleAreaSignature, 0xffffffff);
+ }
}
void Item::getItemStateEntry(ItemStateInfo info, uint32 index, tItemState &state, TimeValue &time) {
@@ -286,4 +293,13 @@ Sprite *Item::getDragSprite(const tDisplayElementID id) const {
return result;
}
+TimeValue Item::getInfoLeftTime() const {
+ return _itemInfo.infoLeftTime;
+}
+
+void Item::getInfoRightTimes(TimeValue &start, TimeValue &stop) const {
+ start = _itemInfo.infoRightStart;
+ stop = _itemInfo.infoRightStop;
+}
+
} // End of namespace Pegasus