本文整理汇总了C++中Object::AddComponant方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::AddComponant方法的具体用法?C++ Object::AddComponant怎么用?C++ Object::AddComponant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::AddComponant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddFuelComponent
bool ObjectManager::AddFuelComponent(int objectNumber, SMapSquare fuelPoint)
{
BaseComponent* newComponent = new FuelPatrolComponent(Objects.at(objectNumber), myMap, fuelPoint);
vector<string> newComponentRequirements = newComponent->GetRequiredComponents();
Object* object = Objects.at(objectNumber);
//check for each requirement on the object.
//if any requirements are missing delete the new component and fail the attachment
for (int i = 0; i < newComponentRequirements.size(); i++)
{
if (!object->CheckForComponant(newComponentRequirements.at(i)))
{
delete newComponent;
return false;
}
}
//check if there is already an override of this type
if (object->CheckForComponant("PatrolAIOverride"))
{
//delete the existing component and replace it
delete object->GetComponentPointer("PatrolAIOverride");
}
object->AddComponant("PatrolAIOverride", newComponent);
return true;
}
示例2: AddComponent
bool ObjectManager::AddComponent(string ComponentType, int objectNumber, string mesh, float X, float Y, float Z)
{
BaseComponent* newComponent;
vector<string> newComponentRequirements;
Object* object = Objects.at(objectNumber);
if (ComponentMap.find(ComponentType) != ComponentMap.end()) // if we have the requested component
{
string name;
//create the new component and get it's requiremernts
newComponent = ComponentMap[ComponentType](object ,myMap);
newComponentRequirements = newComponent->GetRequiredComponents();
//Set override name for components
if (ComponentType == "ChargeAttackComponent")
{
name = "AttackAIOverride";
}
else if (ComponentType == "BlockSearchComponent")
{
name = "SearchAIOverride";
}
else
{
name = ComponentType;
}
//check for each requirement on the object.
//if any requirements are missing delete the new component and fail the attachment
for (int i = 0; i < newComponentRequirements.size(); i++)
{
if (!object->CheckForComponant(newComponentRequirements.at(i)))
{
delete newComponent;
return false;
}
}
//add the component to the object and give a pointer to the object to the component
object->AddComponant(name,newComponent);
return true;
}
else if(ComponentType == "ModelComponent") // exception as this component requires a mesh and co-ordinates
{
//create the model from the mesh
tle::IModel* model = MeshMap[mesh]->CreateModel(X,Y,Z);
//create a new component with this model
newComponent = new ModelComponent(Objects.at(objectNumber), model);
newComponentRequirements = newComponent->GetRequiredComponents();
//check for each requirement on the object.
//if any requirements are missing delete the new component and fail the attachment
for (int i = 0; i < newComponentRequirements.size(); i++)
{
if (!object->CheckForComponant(newComponentRequirements.at(i)))
{
delete newComponent;
return false;
}
}
//add the model to the component
object->AddComponant(ComponentType,newComponent);
return true;
}
else if(ComponentType == "ControlComponent")
{
newComponent = new ControlComponent(Objects.at(objectNumber), myEngine);
newComponentRequirements = newComponent->GetRequiredComponents();
//check for each requirement on the object.
//if any requirements are missing delete the new component and fail the attachment
for (int i = 0; i < newComponentRequirements.size(); i++)
{
if (!object->CheckForComponant(newComponentRequirements.at(i)))
{
delete newComponent;
return false;
}
}
object->AddComponant(ComponentType, newComponent);
}
else if (ComponentType == "InfoPanelComponent")
{
newComponent = new InfoPanelComponent(Objects.at(objectNumber), myEngine);
newComponentRequirements = newComponent->GetRequiredComponents();
//check for each requirement on the object.
//if any requirements are missing delete the new component and fail the attachment
for (int i = 0; i < newComponentRequirements.size(); i++)
{
if (!object->CheckForComponant(newComponentRequirements.at(i)))
{
delete newComponent;
return false;
}
}
//.........这里部分代码省略.........