示例#1
0
Tile* Item::getTile()
{
	Cylinder* cylinder = getTopParent();
	//get root cylinder
	if (cylinder->getParent()) {
		cylinder = cylinder->getParent();
	}
	return dynamic_cast<Tile*>(cylinder);
}
示例#2
0
void Container::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, cylinderlink_t)
{
	Cylinder* topParent = getTopParent();
	if (topParent->getCreature()) {
		topParent->postRemoveNotification(thing, newParent, index, LINK_TOPPARENT);
	} else if (topParent == this) {
		//let the tile class notify surrounding players
		if (topParent->getParent()) {
			topParent->getParent()->postRemoveNotification(thing, newParent, index, LINK_NEAR);
		}
	} else {
		topParent->postRemoveNotification(thing, newParent, index, LINK_PARENT);
	}
}
示例#3
0
Tile* Thing::getTile()
{
	Cylinder* cylinder = getTopParent();
#ifdef __DEBUG_MOVESYS__
	if(!cylinder)
	{
		std::clog << "[Failure - Thing::getTile] NULL tile" << std::endl;
		return &(Tile::nullTile);
	}
#endif

	if(cylinder->getParent())
		cylinder = cylinder->getParent();

	return dynamic_cast<Tile*>(cylinder);
}
示例#4
0
void Container::postRemoveNotification(Creature* actor, Thing* thing, const Cylinder* newParent,
                                       int32_t index, bool isCompleteRemoval, CylinderLink_t/* link = LINK_OWNER*/)
{
    Cylinder* topParent = getTopParent();
    if(!topParent->getCreature())
    {
        if(topParent == this)
        {
            //let the tile class notify surrounding players
            if(topParent->getParent())
                topParent->getParent()->postRemoveNotification(actor, thing, newParent, index, isCompleteRemoval, LINK_NEAR);
        }
        else
            topParent->postRemoveNotification(actor, thing, newParent, index, isCompleteRemoval, LINK_PARENT);
    }
    else
        topParent->postRemoveNotification(actor, thing, newParent, index, isCompleteRemoval, LINK_TOPPARENT);
}
示例#5
0
Cylinder* Item::getTopParent()
{
	Cylinder* aux = getParent();
	Cylinder* prevaux = dynamic_cast<Cylinder*>(this);
	if (!aux) {
		return prevaux;
	}

	while (aux->getParent() != NULL) {
		prevaux = aux;
		aux = aux->getParent();
	}

	if (dynamic_cast<Cylinder*>(prevaux)) {
		return prevaux;
	}
	return aux;
}
示例#6
0
Cylinder* Thing::getTopParent()
{
	//tile
	Cylinder* aux = getParent();
	if(!aux)
		return dynamic_cast<Cylinder*>(this);

	Cylinder* prev = dynamic_cast<Cylinder*>(this);
	while(aux->getParent())
	{
		prev = aux;
		aux = aux->getParent();
	}

	if(dynamic_cast<Cylinder*>(prev))
		return prev;

	return aux;
}
示例#7
0
Player* Item::getHoldingPlayer()
{
	for(Cylinder* p = getParent(); p; p = p->getParent())
	{
		if(p->getCreature())
			return p->getCreature()->getPlayer();
	}

	return NULL;
}
示例#8
0
文件: thing.cpp 项目: cp1337/devland
Cylinder* Thing::getTopParent()
{
	//tile
	if(getParent() == NULL)
		return dynamic_cast<Cylinder*>(this);

	Cylinder* aux = getParent();
	Cylinder* prevaux = dynamic_cast<Cylinder*>(this);

	while(aux->getParent() != NULL){
		prevaux = aux;
		aux = aux->getParent();
	}

	if(dynamic_cast<Cylinder*>(prevaux)){
		return prevaux;
	}

	return aux;
}
示例#9
0
Player* Item::getHoldingPlayer()
{
	Cylinder* p = getParent();
	while(p){
		if(p->getCreature())
			// Must be a player, creatures are not cylinders
			return p->getCreature()->getPlayer();
		p = p->getParent();
	}
	return NULL;
}
示例#10
0
Player* Item::getHoldingPlayer()
{
	Cylinder* p = getParent();

	while (p) {
		if (p->getCreature()) {
			return p->getCreature()->getPlayer();
		}

		p = p->getParent();
	}

	return NULL;
}