2016-06-18 22:34:15 +00:00
|
|
|
#include "objectman.h"
|
2016-06-18 22:48:28 +00:00
|
|
|
#include "dungeonman.h"
|
2016-06-18 22:34:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2016-06-19 09:51:45 +00:00
|
|
|
int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
|
|
|
|
0, /* First icon index in graphic #42 */
|
|
|
|
32, /* First icon index in graphic #43 */
|
|
|
|
64, /* First icon index in graphic #44 */
|
|
|
|
96, /* First icon index in graphic #45 */
|
|
|
|
128, /* First icon index in graphic #46 */
|
|
|
|
160, /* First icon index in graphic #47 */
|
|
|
|
192}; /* First icon index in graphic #48 */
|
|
|
|
|
2016-06-18 23:28:28 +00:00
|
|
|
ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {}
|
2016-06-18 22:34:15 +00:00
|
|
|
|
2016-06-18 22:48:28 +00:00
|
|
|
IconIndice ObjectMan::getObjectType(Thing thing) {
|
|
|
|
if (thing == Thing::_thingNone)
|
|
|
|
return kIconIndiceNone;
|
|
|
|
|
|
|
|
int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
|
|
|
|
if (objectInfoIndex != -1) {
|
|
|
|
objectInfoIndex = gObjectInfo[objectInfoIndex]._type;
|
|
|
|
}
|
|
|
|
return (IconIndice)objectInfoIndex;
|
|
|
|
}
|
|
|
|
|
2016-06-18 22:51:12 +00:00
|
|
|
byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
|
|
|
|
|
2016-06-18 23:28:28 +00:00
|
|
|
int16 ObjectMan::getIconIndex(Thing thing) {
|
|
|
|
IconIndice iconIndex = getObjectType(thing);
|
|
|
|
|
|
|
|
if ((iconIndex != kIconIndiceNone) &&
|
|
|
|
((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
|
|
|
|
((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
|
|
|
|
(iconIndex == kIconIndicePotionEmptyFlask)
|
|
|
|
) {
|
|
|
|
uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
|
|
|
|
switch (iconIndex) {
|
|
|
|
case kIconIndiceJunkCompassNorth:
|
|
|
|
iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir);
|
|
|
|
break;
|
|
|
|
case kIconIndiceWeaponTorchUnlit: {
|
|
|
|
Weapon weapon(rawType);
|
|
|
|
if (weapon.isLit()) {
|
|
|
|
iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kIconIndiceScrollOpen:
|
|
|
|
if (Scroll(rawType).getClosed()) {
|
|
|
|
iconIndex = (IconIndice)(iconIndex + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kIconIndiceJunkWater:
|
|
|
|
case kIconIndiceJunkIllumuletUnequipped:
|
|
|
|
case kIconIndiceJunkJewelSymalUnequipped:
|
|
|
|
if (Junk(rawType).getChargeCount()) {
|
|
|
|
iconIndex = (IconIndice)(iconIndex + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kIconIndiceWeaponBoltBladeStormEmpty:
|
|
|
|
case kIconIndiceWeaponFlamittEmpty:
|
|
|
|
case kIconIndiceWeaponStormringEmpty:
|
|
|
|
case kIconIndiceWeaponFuryRaBladeEmpty:
|
|
|
|
case kIconIndiceWeaponEyeOfTimeEmpty:
|
|
|
|
case kIconIndiceWeaponStaffOfClawsEmpty:
|
|
|
|
if (Weapon(rawType).getChargeCount()) {
|
|
|
|
iconIndex = (IconIndice)(iconIndex + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iconIndex;
|
|
|
|
}
|
2016-06-18 22:51:12 +00:00
|
|
|
|
2016-06-18 22:34:15 +00:00
|
|
|
}
|