本文整理汇总了C++中Plot::CreateGameObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Plot::CreateGameObject方法的具体用法?C++ Plot::CreateGameObject怎么用?C++ Plot::CreateGameObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plot
的用法示例。
在下文中一共展示了Plot::CreateGameObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CancelBuildingConstruction
void Garrison::CancelBuildingConstruction(uint32 garrPlotInstanceId)
{
WorldPackets::Garrison::GarrisonBuildingRemoved buildingRemoved;
buildingRemoved.GarrTypeID = GARRISON_TYPE_GARRISON;
buildingRemoved.Result = CheckBuildingRemoval(garrPlotInstanceId);
if (buildingRemoved.Result == GARRISON_SUCCESS)
{
Plot* plot = GetPlot(garrPlotInstanceId);
buildingRemoved.GarrPlotInstanceID = garrPlotInstanceId;
buildingRemoved.GarrBuildingID = plot->BuildingInfo.PacketInfo->GarrBuildingID;
Map* map = FindMap();
if (map)
plot->DeleteGameObject(map);
plot->ClearBuildingInfo(_owner);
_owner->SendDirectMessage(buildingRemoved.Write());
GarrBuildingEntry const* constructing = sGarrBuildingStore.AssertEntry(buildingRemoved.GarrBuildingID);
// Refund construction/upgrade cost
_owner->ModifyCurrency(constructing->CostCurrencyID, constructing->CostCurrencyAmount, false, true);
_owner->ModifyMoney(constructing->CostMoney * GOLD, false);
if (constructing->Level > 1)
{
// Restore previous level building
uint32 restored = sGarrisonMgr.GetPreviousLevelBuildingId(constructing->Type, constructing->Level);
ASSERT(restored);
WorldPackets::Garrison::GarrisonPlaceBuildingResult placeBuildingResult;
placeBuildingResult.GarrTypeID = GARRISON_TYPE_GARRISON;
placeBuildingResult.Result = GARRISON_SUCCESS;
placeBuildingResult.BuildingInfo.GarrPlotInstanceID = garrPlotInstanceId;
placeBuildingResult.BuildingInfo.GarrBuildingID = restored;
placeBuildingResult.BuildingInfo.TimeBuilt = time(nullptr);
placeBuildingResult.BuildingInfo.Active = true;
plot->SetBuildingInfo(placeBuildingResult.BuildingInfo, _owner);
_owner->SendDirectMessage(placeBuildingResult.Write());
}
if (map)
if (GameObject* go = plot->CreateGameObject(map, GetFaction()))
map->AddToMap(go);
}
else
_owner->SendDirectMessage(buildingRemoved.Write());
}
示例2: PlaceBuilding
void Garrison::PlaceBuilding(uint32 garrPlotInstanceId, uint32 garrBuildingId)
{
WorldPackets::Garrison::GarrisonPlaceBuildingResult placeBuildingResult;
placeBuildingResult.GarrTypeID = GARRISON_TYPE_GARRISON;
placeBuildingResult.Result = CheckBuildingPlacement(garrPlotInstanceId, garrBuildingId);
if (placeBuildingResult.Result == GARRISON_SUCCESS)
{
placeBuildingResult.BuildingInfo.GarrPlotInstanceID = garrPlotInstanceId;
placeBuildingResult.BuildingInfo.GarrBuildingID = garrBuildingId;
placeBuildingResult.BuildingInfo.TimeBuilt = time(nullptr);
Plot* plot = GetPlot(garrPlotInstanceId);
uint32 oldBuildingId = 0;
Map* map = FindMap();
GarrBuildingEntry const* building = sGarrBuildingStore.AssertEntry(garrBuildingId);
if (map)
plot->DeleteGameObject(map);
if (plot->BuildingInfo.PacketInfo)
{
oldBuildingId = plot->BuildingInfo.PacketInfo->GarrBuildingID;
if (sGarrBuildingStore.AssertEntry(oldBuildingId)->Type != building->Type)
plot->ClearBuildingInfo(_owner);
}
plot->SetBuildingInfo(placeBuildingResult.BuildingInfo, _owner);
if (map)
if (GameObject* go = plot->CreateGameObject(map, GetFaction()))
map->AddToMap(go);
_owner->ModifyCurrency(building->CostCurrencyID, -building->CostCurrencyAmount, false, true);
_owner->ModifyMoney(-building->CostMoney * GOLD, false);
if (oldBuildingId)
{
WorldPackets::Garrison::GarrisonBuildingRemoved buildingRemoved;
buildingRemoved.GarrTypeID = GARRISON_TYPE_GARRISON;
buildingRemoved.Result = GARRISON_SUCCESS;
buildingRemoved.GarrPlotInstanceID = garrPlotInstanceId;
buildingRemoved.GarrBuildingID = oldBuildingId;
_owner->SendDirectMessage(buildingRemoved.Write());
}
_owner->UpdateCriteria(CRITERIA_TYPE_PLACE_GARRISON_BUILDING, garrBuildingId);
}
_owner->SendDirectMessage(placeBuildingResult.Write());
}