Initial commit
This commit is contained in:
250
engines/pegasus/items/inventory/airmask.cpp
Normal file
250
engines/pegasus/items/inventory/airmask.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pegasus/gamestate.h"
|
||||
#include "pegasus/pegasus.h"
|
||||
#include "pegasus/ai/ai_area.h"
|
||||
#include "pegasus/items/inventory/airmask.h"
|
||||
#include "pegasus/neighborhood/neighborhood.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
AirMask *g_airMask = nullptr;
|
||||
|
||||
// Based on full == 100, which is scale used by GetAirLeft().
|
||||
static const TimeValue kOxygenLowThreshold = 25;
|
||||
|
||||
void AirMask::airMaskTimerExpired() {
|
||||
if (g_neighborhood)
|
||||
g_neighborhood->checkAirMask();
|
||||
}
|
||||
|
||||
AirMask::AirMask(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
|
||||
InventoryItem(id, neighborhood, room, direction), _toggleSpot(kAirMaskToggleSpotID) {
|
||||
g_airMask = this;
|
||||
_toggleSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 10, kAIMiddleAreaTop + 17, kAIMiddleAreaLeft + 110, kAIMiddleAreaTop + 57));
|
||||
_toggleSpot.setHotspotFlags(kAirMaskSpotFlag);
|
||||
g_allHotspots.push_back(&_toggleSpot);
|
||||
setItemState(kAirMaskEmptyOff);
|
||||
_oxygenTimer.primeFuse(0);
|
||||
_oxygenTimer.setFunctor(new Common::Functor0Mem<void, AirMask>(this, &AirMask::airMaskTimerExpired));
|
||||
}
|
||||
|
||||
AirMask::~AirMask() {
|
||||
g_allHotspots.removeOneHotspot(kAirMaskToggleSpotID);
|
||||
g_airMask = nullptr;
|
||||
}
|
||||
|
||||
void AirMask::writeToStream(Common::WriteStream *stream) {
|
||||
InventoryItem::writeToStream(stream);
|
||||
stream->writeUint32BE(_oxygenTimer.getTimeRemaining());
|
||||
}
|
||||
|
||||
void AirMask::readFromStream(Common::ReadStream *stream) {
|
||||
_oxygenTimer.stopFuse();
|
||||
InventoryItem::readFromStream(stream);
|
||||
_oxygenTimer.primeFuse(stream->readUint32BE());
|
||||
}
|
||||
|
||||
void AirMask::putMaskOn() {
|
||||
AirQuality airQuality;
|
||||
|
||||
if (g_neighborhood)
|
||||
airQuality = g_neighborhood->getAirQuality(GameState.getCurrentRoom());
|
||||
else
|
||||
airQuality = kAirQualityGood;
|
||||
|
||||
uint airLevel = getAirLeft();
|
||||
ItemState newState = getItemState();
|
||||
ItemState oldState = newState;
|
||||
|
||||
if (airLevel == 0) {
|
||||
newState = kAirMaskEmptyFilter;
|
||||
} else if (airLevel <= kOxygenLowThreshold) {
|
||||
if (airQuality == kAirQualityVacuum)
|
||||
newState = kAirMaskLowOn;
|
||||
else
|
||||
newState = kAirMaskLowFilter;
|
||||
} else {
|
||||
if (airQuality == kAirQualityVacuum)
|
||||
newState = kAirMaskFullOn;
|
||||
else
|
||||
newState = kAirMaskFullFilter;
|
||||
}
|
||||
|
||||
if (newState != oldState)
|
||||
setItemState(newState);
|
||||
}
|
||||
|
||||
void AirMask::takeMaskOff() {
|
||||
uint airLevel = getAirLeft();
|
||||
ItemState newState = getItemState();
|
||||
ItemState oldState = newState;
|
||||
|
||||
if (airLevel == 0)
|
||||
newState = kAirMaskEmptyOff;
|
||||
else if (airLevel <= kOxygenLowThreshold)
|
||||
newState = kAirMaskLowOff;
|
||||
else
|
||||
newState = kAirMaskFullOff;
|
||||
|
||||
if (newState != oldState)
|
||||
setItemState(newState);
|
||||
}
|
||||
|
||||
void AirMask::toggleItemState() {
|
||||
if (isAirMaskInUse())
|
||||
takeMaskOff();
|
||||
else
|
||||
putMaskOn();
|
||||
}
|
||||
|
||||
void AirMask::airQualityChanged() {
|
||||
if (isAirMaskInUse())
|
||||
putMaskOn();
|
||||
else
|
||||
takeMaskOff();
|
||||
}
|
||||
|
||||
void AirMask::setItemState(const ItemState newState) {
|
||||
if (newState != getItemState()) {
|
||||
InventoryItem::setItemState(newState);
|
||||
|
||||
switch (newState) {
|
||||
case kAirMaskFullOn:
|
||||
case kAirMaskLowOn:
|
||||
if (!_oxygenTimer.isFuseLit()) {
|
||||
_oxygenTimer.lightFuse();
|
||||
startIdling();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (_oxygenTimer.isFuseLit()) {
|
||||
_oxygenTimer.stopFuse();
|
||||
stopIdling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_neighborhood)
|
||||
g_neighborhood->checkAirMask();
|
||||
|
||||
g_AIArea->checkMiddleArea();
|
||||
}
|
||||
}
|
||||
|
||||
void AirMask::useIdleTime() {
|
||||
if (getAirLeft() == 0)
|
||||
setItemState(kAirMaskEmptyOff);
|
||||
else if (getAirLeft() <= kOxygenLowThreshold)
|
||||
setItemState(kAirMaskLowOn);
|
||||
}
|
||||
|
||||
void AirMask::refillAirMask() {
|
||||
switch (getItemState()) {
|
||||
case kAirMaskEmptyOff:
|
||||
case kAirMaskLowOff:
|
||||
setItemState(kAirMaskFullOff);
|
||||
break;
|
||||
case kAirMaskEmptyFilter:
|
||||
case kAirMaskLowFilter:
|
||||
setItemState(kAirMaskFullFilter);
|
||||
break;
|
||||
case kAirMaskLowOn:
|
||||
setItemState(kAirMaskFullOn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (_oxygenTimer.isFuseLit()) {
|
||||
_oxygenTimer.stopFuse();
|
||||
_oxygenTimer.primeFuse(kOxyMaskFullTime);
|
||||
_oxygenTimer.lightFuse();
|
||||
} else {
|
||||
_oxygenTimer.primeFuse(kOxyMaskFullTime);
|
||||
}
|
||||
}
|
||||
|
||||
// Doesn't return 0 until the timer is actually at 0.
|
||||
uint AirMask::getAirLeft() {
|
||||
return CLIP<int>(((_oxygenTimer.getTimeRemaining() * 100) + kOxyMaskFullTime - 1) / kOxyMaskFullTime, 0, 100);
|
||||
}
|
||||
|
||||
bool AirMask::isAirMaskInUse() {
|
||||
switch (getItemState()) {
|
||||
case kAirMaskEmptyOff:
|
||||
case kAirMaskLowOff:
|
||||
case kAirMaskFullOff:
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AirMask::isAirMaskOn() {
|
||||
switch (getItemState()) {
|
||||
case kAirMaskLowOn:
|
||||
case kAirMaskFullOn:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AirMask::isAirFilterOn() {
|
||||
switch (getItemState()) {
|
||||
case kAirMaskEmptyFilter:
|
||||
case kAirMaskLowFilter:
|
||||
case kAirMaskFullFilter:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AirMask::addedToInventory() {
|
||||
GameState.setMarsMaskOnFiller(false);
|
||||
}
|
||||
|
||||
void AirMask::removedFromInventory() {
|
||||
if (isAirMaskInUse())
|
||||
toggleItemState();
|
||||
}
|
||||
|
||||
void AirMask::activateAirMaskHotspots() {
|
||||
_toggleSpot.setActive();
|
||||
}
|
||||
|
||||
void AirMask::clickInAirMaskHotspot() {
|
||||
toggleItemState();
|
||||
}
|
||||
|
||||
} // End of namespace Pegasus
|
||||
75
engines/pegasus/items/inventory/airmask.h
Normal file
75
engines/pegasus/items/inventory/airmask.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PEGASUS_ITEMS_INVENTORY_AIRMASK_H
|
||||
#define PEGASUS_ITEMS_INVENTORY_AIRMASK_H
|
||||
|
||||
#include "pegasus/hotspot.h"
|
||||
#include "pegasus/timers.h"
|
||||
#include "pegasus/items/inventory/inventoryitem.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
class AirMask : public InventoryItem, private Idler {
|
||||
public:
|
||||
AirMask(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
|
||||
~AirMask() override;
|
||||
|
||||
void writeToStream(Common::WriteStream *) override;
|
||||
void readFromStream(Common::ReadStream *) override;
|
||||
|
||||
void setItemState(const ItemState) override;
|
||||
void putMaskOn();
|
||||
void takeMaskOff();
|
||||
void toggleItemState() override;
|
||||
void airQualityChanged();
|
||||
|
||||
bool isAirMaskInUse();
|
||||
bool isAirMaskOn();
|
||||
bool isAirFilterOn();
|
||||
|
||||
void refillAirMask();
|
||||
|
||||
// Returns a percentage
|
||||
uint getAirLeft();
|
||||
|
||||
void activateAirMaskHotspots();
|
||||
void clickInAirMaskHotspot();
|
||||
|
||||
protected:
|
||||
void airMaskTimerExpired();
|
||||
|
||||
void removedFromInventory() override;
|
||||
void addedToInventory() override;
|
||||
void useIdleTime() override;
|
||||
|
||||
Hotspot _toggleSpot;
|
||||
FuseFunction _oxygenTimer;
|
||||
};
|
||||
|
||||
extern AirMask *g_airMask;
|
||||
|
||||
} // End of namespace Pegasus
|
||||
|
||||
#endif
|
||||
45
engines/pegasus/items/inventory/gascanister.cpp
Normal file
45
engines/pegasus/items/inventory/gascanister.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pegasus/ai/ai_area.h"
|
||||
#include "pegasus/items/inventory/gascanister.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
GasCanister::GasCanister(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
|
||||
InventoryItem(id, neighborhood, room, direction) {
|
||||
}
|
||||
|
||||
void GasCanister::select() {
|
||||
InventoryItem::select();
|
||||
takeSharedArea();
|
||||
}
|
||||
|
||||
void GasCanister::takeSharedArea() {
|
||||
ItemExtraEntry entry;
|
||||
findItemExtra(kGasCanLoop, entry);
|
||||
g_AIArea->loopAIAreaSequence(kInventorySignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
|
||||
}
|
||||
|
||||
} // End of namespace Pegasus
|
||||
43
engines/pegasus/items/inventory/gascanister.h
Normal file
43
engines/pegasus/items/inventory/gascanister.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PEGASUS_ITEMS_INVENTORY_GASCANISTER_H
|
||||
#define PEGASUS_ITEMS_INVENTORY_GASCANISTER_H
|
||||
|
||||
#include "pegasus/items/inventory/inventoryitem.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
class GasCanister : public InventoryItem {
|
||||
public:
|
||||
GasCanister(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
|
||||
~GasCanister() override {}
|
||||
|
||||
void select() override;
|
||||
void takeSharedArea() override;
|
||||
};
|
||||
|
||||
} // End of namespace Pegasus
|
||||
|
||||
#endif
|
||||
107
engines/pegasus/items/inventory/inventoryitem.cpp
Normal file
107
engines/pegasus/items/inventory/inventoryitem.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/stream.h"
|
||||
|
||||
#include "pegasus/pegasus.h"
|
||||
#include "pegasus/ai/ai_area.h"
|
||||
#include "pegasus/items/inventory/inventoryitem.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
InventoryItem::InventoryItem(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
|
||||
Item(id, neighborhood, room, direction) {
|
||||
|
||||
Common::SeekableReadStream *leftInfo = g_vm->_resFork->getResource(MKTAG('L', 'e', 'f', 't'), kItemBaseResID + id);
|
||||
if (leftInfo) {
|
||||
_leftAreaInfo = readItemState(leftInfo);
|
||||
delete leftInfo;
|
||||
} else {
|
||||
_leftAreaInfo.numEntries = 0;
|
||||
_leftAreaInfo.entries = nullptr;
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *inventoryInfo = g_vm->_resFork->getResource(MKTAG('I', 'n', 'v', 'I'), kItemBaseResID + id);
|
||||
if (inventoryInfo) {
|
||||
_inventoryInfo.panelStart = inventoryInfo->readUint32BE();
|
||||
_inventoryInfo.panelStop = inventoryInfo->readUint32BE();
|
||||
delete inventoryInfo;
|
||||
} else {
|
||||
_inventoryInfo.panelStart = _inventoryInfo.panelStop = 0;
|
||||
}
|
||||
|
||||
_itemAnimationTime = 0;
|
||||
}
|
||||
|
||||
InventoryItem::~InventoryItem() {
|
||||
delete[] _leftAreaInfo.entries;
|
||||
}
|
||||
|
||||
ItemType InventoryItem::getItemType() {
|
||||
return kInventoryItemType;
|
||||
}
|
||||
|
||||
TimeValue InventoryItem::getLeftAreaTime() const {
|
||||
if (!_leftAreaInfo.entries)
|
||||
return 0xffffffff;
|
||||
|
||||
TimeValue time;
|
||||
ItemState state;
|
||||
|
||||
findItemStateEntryByState(_leftAreaInfo, _itemState, time);
|
||||
if (time == 0xffffffff)
|
||||
getItemStateEntry(_leftAreaInfo, 0, state, time);
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
void InventoryItem::setAnimationTime(const TimeValue time) {
|
||||
_itemAnimationTime = time;
|
||||
}
|
||||
|
||||
TimeValue InventoryItem::getAnimationTime() const {
|
||||
return _itemAnimationTime;
|
||||
}
|
||||
|
||||
// Must affect images in left area.
|
||||
void InventoryItem::select() {
|
||||
Item::select();
|
||||
|
||||
if (g_AIArea)
|
||||
g_AIArea->setAIAreaToTime(kInventorySignature, kLeftAreaSignature, getLeftAreaTime());
|
||||
}
|
||||
|
||||
void InventoryItem::deselect() {
|
||||
Item::deselect();
|
||||
|
||||
if (g_AIArea)
|
||||
g_AIArea->setAIAreaToTime(kInventorySignature, kLeftAreaSignature, 0xffffffff);
|
||||
}
|
||||
|
||||
void InventoryItem::getPanelTimes(TimeValue &start, TimeValue &stop) const {
|
||||
start = _inventoryInfo.panelStart;
|
||||
stop = _inventoryInfo.panelStop;
|
||||
}
|
||||
|
||||
} // End of namespace Pegasus
|
||||
66
engines/pegasus/items/inventory/inventoryitem.h
Normal file
66
engines/pegasus/items/inventory/inventoryitem.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PEGASUS_ITEMS_INVENTORY_INVENTORYITEM_H
|
||||
#define PEGASUS_ITEMS_INVENTORY_INVENTORYITEM_H
|
||||
|
||||
#include "pegasus/items/item.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
// JMPInventoryInfo contains the resource data used by InventoryItems.
|
||||
|
||||
struct JMPInventoryInfo {
|
||||
TimeValue panelStart;
|
||||
TimeValue panelStop;
|
||||
};
|
||||
|
||||
class InventoryItem : public Item {
|
||||
public:
|
||||
InventoryItem(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
|
||||
~InventoryItem() override;
|
||||
|
||||
ItemType getItemType() override;
|
||||
|
||||
void getPanelTimes(TimeValue &, TimeValue &) const;
|
||||
TimeValue getLeftAreaTime() const;
|
||||
|
||||
void setAnimationTime(const TimeValue);
|
||||
TimeValue getAnimationTime() const;
|
||||
|
||||
virtual void toggleItemState() {}
|
||||
|
||||
// Must affect images in left area.
|
||||
void select() override;
|
||||
void deselect() override;
|
||||
|
||||
protected:
|
||||
JMPInventoryInfo _inventoryInfo;
|
||||
ItemStateInfo _leftAreaInfo;
|
||||
TimeValue _itemAnimationTime;
|
||||
};
|
||||
|
||||
} // End of namespace Pegasus
|
||||
|
||||
#endif
|
||||
58
engines/pegasus/items/inventory/keycard.cpp
Normal file
58
engines/pegasus/items/inventory/keycard.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pegasus/pegasus.h"
|
||||
#include "pegasus/items/inventory/keycard.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
KeyCard::KeyCard(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
|
||||
InventoryItem(id, neighborhood, room, direction) {
|
||||
setItemState(kFlashlightOff);
|
||||
}
|
||||
|
||||
void KeyCard::toggleItemState() {
|
||||
if (getItemState() == kFlashlightOff)
|
||||
setItemState(kFlashlightOn);
|
||||
else
|
||||
setItemState(kFlashlightOff);
|
||||
}
|
||||
|
||||
void KeyCard::setItemState(const ItemState newState) {
|
||||
if (newState != getItemState()) {
|
||||
InventoryItem::setItemState(newState);
|
||||
g_vm->checkFlashlight();
|
||||
}
|
||||
}
|
||||
|
||||
bool KeyCard::isFlashlightOn() {
|
||||
return getItemState() == kFlashlightOn;
|
||||
}
|
||||
|
||||
void KeyCard::removedFromInventory() {
|
||||
if (isFlashlightOn())
|
||||
setItemState(kFlashlightOff);
|
||||
}
|
||||
|
||||
} // End of namespace Pegasus
|
||||
47
engines/pegasus/items/inventory/keycard.h
Normal file
47
engines/pegasus/items/inventory/keycard.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* Additional copyright for this file:
|
||||
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PEGASUS_ITEMS_INVENTORY_KEYCARD_H
|
||||
#define PEGASUS_ITEMS_INVENTORY_KEYCARD_H
|
||||
|
||||
#include "pegasus/items/inventory/inventoryitem.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
class KeyCard : public InventoryItem {
|
||||
public:
|
||||
KeyCard(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
|
||||
~KeyCard() override {}
|
||||
|
||||
void toggleItemState() override;
|
||||
void setItemState(const ItemState) override;
|
||||
bool isFlashlightOn();
|
||||
|
||||
protected:
|
||||
void removedFromInventory() override;
|
||||
};
|
||||
|
||||
} // End of namespace Pegasus
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user