本文整理汇总了C++中Container::CanAddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Container::CanAddItem方法的具体用法?C++ Container::CanAddItem怎么用?C++ Container::CanAddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container::CanAddItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DraggingItem
bool GameMapGump::DraggingItem(Item* item, int mx, int my)
{
// determine target location and set dragging_x/y/z
int dox, doy;
GUIApp::get_instance()->getDraggingOffset(dox, doy);
dragging_shape = item->getShape();
dragging_frame = item->getFrame();
dragging_flags = item->getFlags();
display_dragging = true;
// determine if item can be dropped here
ObjId trace = TraceCoordinates(mx, my, dragging_pos, dox, doy, item);
if (!trace)
return false;
MainActor* avatar = getMainActor();
if (trace == 1) { // dropping on self
ObjId bp = avatar->getEquip(7); // !! constant
Container* backpack = getContainer(bp);
return backpack->CanAddItem(item, true);
}
bool throwing = false;
if (!avatar->canReach(item, 128, // CONSTANT!
dragging_pos[0], dragging_pos[1], dragging_pos[2]))
{
// can't reach, so see if we can throw
int throwrange = item->getThrowRange();
if (throwrange && avatar->canReach(item, throwrange, dragging_pos[0],
dragging_pos[1], dragging_pos[2]))
{
int speed = 64 - item->getTotalWeight() + avatar->getStr();
if (speed < 1) speed = 1;
sint32 ax,ay,az;
avatar->getLocation(ax,ay,az);
MissileTracker t(item, ax, ay, az,
dragging_pos[0], dragging_pos[1], dragging_pos[2],
speed, 4);
if (t.isPathClear())
throwing = true;
else
return false;
} else {
return false;
}
}
if (!item->canExistAt(dragging_pos[0], dragging_pos[1], dragging_pos[2]))
return false;
if (throwing)
GUIApp::get_instance()->setMouseCursor(GUIApp::MOUSE_TARGET);
return true;
}