本文整理汇总了C++中ManagedReference::asBuildingObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::asBuildingObject方法的具体用法?C++ ManagedReference::asBuildingObject怎么用?C++ ManagedReference::asBuildingObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::asBuildingObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPlanetObjects
void PlanetManagerImplementation::loadPlanetObjects(LuaObject* luaObject) {
if (!luaObject->isValidTable())
return;
for (int i = 1; i <= luaObject->getTableSize(); ++i) {
lua_State* L = luaObject->getLuaState();
lua_rawgeti(L, -1, i);
LuaObject planetObject(L);
String templateFile = planetObject.getStringField("templateFile");
ManagedReference<SceneObject*> obj = ObjectManager::instance()->createObject(templateFile.hashCode(), 0, "");
if (obj != NULL) {
Locker objLocker(obj);
float x = planetObject.getFloatField("x");
float y = planetObject.getFloatField("y");
float z = planetObject.getFloatField("z");
float ox = planetObject.getFloatField("ox");
float oy = planetObject.getFloatField("oy");
float oz = planetObject.getFloatField("oz");
float ow = planetObject.getFloatField("ow");
uint64 parentID = planetObject.getLongField("parent");
if (obj->isBuildingObject()) {
BuildingObject* building = obj->asBuildingObject();
building->createCellObjects();
}
obj->initializePosition(x, z, y);
obj->setDirection(ow, ox, oy, oz);
ManagedReference<SceneObject*> parent = zone->getZoneServer()->getObject(parentID);
if (parent != NULL)
parent->transferObject(obj, -1, true);
else
zone->transferObject(obj, -1, true);
obj->createChildObjects();
}
planetObject.pop();
}
}
示例2: sendBaselinesTo
void CellObjectImplementation::sendBaselinesTo(SceneObject* player) {
BaseMessage* cellMsg3 = new CellObjectMessage3(getObjectID(), cellNumber);
player->sendMessage(cellMsg3);
BaseMessage* cellMsg6 = new CellObjectMessage6(getObjectID());
player->sendMessage(cellMsg6);
bool allowEntry = true;
ManagedReference<SceneObject*> strongParent = getParent().get();
if (player->isCreatureObject() && strongParent != NULL && strongParent->isBuildingObject()) {
CreatureObject* creature = player->asCreatureObject();
allowEntry = strongParent->asBuildingObject()->isAllowedEntry(creature);
}
BaseMessage* perm = new UpdateCellPermissionsMessage(getObjectID(), allowEntry);
player->sendMessage(perm);
}
示例3: canAddObject
int CellObjectImplementation::canAddObject(SceneObject* object, int containmentType, String& errorDescription) {
ManagedReference<SceneObject*> strongParent = getParent().get();
if (strongParent != NULL && strongParent->isBuildingObject()) {
BuildingObject* building = strongParent->asBuildingObject();
int count = 1;
if (object->isVendor())
count = 0;
else if (object->isContainerObject())
count += object->getCountableObjectsRecursive();
if (building->getCurrentNumberOfPlayerItems() + count > building->getMaximumNumberOfPlayerItems()) {
errorDescription = "@container_error_message:container13";
return TransferErrorCode::TOOMANYITEMSINHOUSE;
}
}
return SceneObjectImplementation::canAddObject(object, containmentType, errorDescription);
}
示例4: createChildObjects
void SceneObjectImplementation::createChildObjects() {
if (getZone() == NULL)
return;
ZoneServer* zoneServer = getZone()->getZoneServer();
bool client = isStaticObject();
for (int i = 0; i < templateObject->getChildObjectsSize(); ++i) {
ChildObject* child = templateObject->getChildObject(i);
if (child == NULL)
continue;
ManagedReference<SceneObject*> obj = NULL;
if (client)
obj = zoneServer->createObject(child->getTemplateFile().hashCode(), "clientobjects", getPersistenceLevel());
else
obj = zoneServer->createObject(child->getTemplateFile().hashCode(), getPersistenceLevel());
if (obj == NULL)
continue;
Locker objLocker(obj, asSceneObject());
Vector3 childPosition = child->getPosition();
childObjects.put(obj);
obj->initializePosition(childPosition.getX(), childPosition.getZ(), childPosition.getY());
obj->setDirection(child->getDirection());
if (isBuildingObject() && child->getCellId() >= 0) {
BuildingObject* buildingObject = asBuildingObject();
int totalCells = buildingObject->getTotalCellNumber();
try {
if (totalCells >= child->getCellId()) {
ManagedReference<CellObject*> cellObject = buildingObject->getCell(child->getCellId());
if (cellObject != NULL) {
if (!cellObject->transferObject(obj, child->getContainmentType(), true)) {
obj->destroyObjectFromDatabase(true);
continue;
}
//cellObject->broadcastObject(obj, false);
} else {
error("NULL CELL OBJECT");
obj->destroyObjectFromDatabase(true);
continue;
}
}
} catch (Exception& e) {
error("unreported exception caught in void SceneObjectImplementation::createChildObjects()!");
e.printStackTrace();
}
} else {
//Create the object outdoors in relation to its parent.
Vector3 position;
if (obj->isActiveArea())
position = getWorldPosition();
else
position = getPosition();
float angle = direction.getRadians();
float x = (Math::cos(angle) * childPosition.getX()) + (childPosition.getY() * Math::sin(angle));
float y = (Math::cos(angle) * childPosition.getY()) - (childPosition.getX() * Math::sin(angle));
x += position.getX();
y += position.getY();
float z = position.getZ() + childPosition.getZ();
float degrees = direction.getDegrees();
Quaternion dir = child->getDirection();
obj->initializePosition(x, z, y);
obj->setDirection(dir.rotate(Vector3(0, 1, 0), degrees));
if (obj->isBuildingObject()) {
BuildingObject* building = obj->asBuildingObject();
if (building != NULL) {
building->createCellObjects();
}
}
if (!getZone()->transferObject(obj, -1, false)) {
obj->destroyObjectFromDatabase(true);
continue;
}
}
//childObjects.put(obj);
ContainerPermissions* permissions = obj->getContainerPermissions();
permissions->setOwner(getObjectID());
permissions->setInheritPermissionsFromParent(false);
permissions->setDefaultDenyPermission(ContainerPermissions::MOVECONTAINER);
permissions->setDenyPermission("owner", ContainerPermissions::MOVECONTAINER);
//.........这里部分代码省略.........