本文整理汇总了C++中Entity::AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::AddComponent方法的具体用法?C++ Entity::AddComponent怎么用?C++ Entity::AddComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::AddComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialize
virtual void Initialize()
{
for(int i = 1; i <= 10; i++){
Entity* pEntity = Repo::Core()->CreateEntity();
pEntity->AddComponent(new BuildingComponent());
pEntity->AddComponent(new TypeComponent("House"));
pEntity->AddComponent(new LevelComponent(i));
cout << "New entity created of type " << GetType(pEntity) << " and level " << GetLevel(pEntity) << endl;
}
}
示例2: CreateCamera
Entity* CommonFactory::CreateCamera()
{
Entity* camera = new Entity();
TransformComponent* transformComponent = new TransformComponent();
PhysicsComponent* physicsComponent = new PhysicsComponent();
CameraComponent* cameraComponent = new CameraComponent();
cameraComponent->UseCamera();
camera->AddComponent(physicsComponent);
camera->AddComponent(cameraComponent);
camera->AddComponent(transformComponent);
return camera;
}
示例3: GetOwner
void Box2DSystem::__AddCircle(const sf::Vector2f& pos)
{
// Define the dynamic body. We set its position and call the body factory.
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(pos.x, pos.y);
b2Body* body = m_world->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2CircleShape dynamicCircle;
dynamicCircle.m_p.Set(pos.x,pos.y);
dynamicCircle.m_radius = .5;
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicCircle;
// Set the box density to be non-zero, so it will be dynamic.
fixtureDef.density = 1.0f;
// Override the default friction.
fixtureDef.friction = 0.3f;
// Add the shape to the body.
body->CreateFixture(&fixtureDef);
Entity* boxEntity = GetOwner()->CreateEntity();
Box2DComponent* boxComponent = Box2DComponent::Pool.CreateComponent();
boxEntity->AddComponent(boxComponent);
boxComponent->m_body = body;
}
示例4: AddSkybox
Entity* SkyboxSystem::AddSkybox()
{
Entity* result = skyboxEntity;
if(NULL == skyboxEntity)
{
SkyboxRenderObject* skyboxRenderObject = new SkyboxRenderObject();
AABBox3 box = AABBox3(Vector3(-0.5f, -0.5f, -0.5f), Vector3(0.5f, 0.5f, 0.5f));
skyboxRenderObject->Initialize(box); //first time initialization
RenderComponent* renderComponent = new RenderComponent();
renderComponent->SetRenderObject(skyboxRenderObject);
result = new Entity();
result->SetName("Skybox");
result->RemoveComponent(Component::RENDER_COMPONENT);
result->AddComponent(renderComponent);
renderComponent->Release();
GetScene()->AddNode(result);
Matrix4 * worldTransformPointer = ((TransformComponent*)result->GetComponent(Component::TRANSFORM_COMPONENT))->GetWorldTransformPtr();
skyboxRenderObject->SetWorldTransformPtr(worldTransformPointer);
result->GetScene()->renderSystem->MarkForUpdate(skyboxRenderObject);
SafeRelease(skyboxRenderObject);
DVASSERT(skyboxEntity);
result->Release();
}
return result;
}
示例5: ShowEditorLandscape
bool LandscapesController::ShowEditorLandscape(EditorLandscape *displayingLandscape)
{
Landscape *landscape = EditorScene::GetLandscape(scene);
if (!landscape)
{
Logger::Error("[LandscapesController::ShowEditorLandscape] Can be only one landscape");
return false;
}
displayingLandscape->SetNestedLandscape(landscape);
if(!landscapeRenderer)
{
renderedHeightmap = new EditorHeightmap(landscape->GetHeightmap());
landscapeRenderer = new LandscapeRenderer(renderedHeightmap, landscape->GetBoundingBox());
displayingLandscape->SetHeightmap(renderedHeightmap);
}
displayingLandscape->SetRenderer(landscapeRenderer);
//TODO: remove SetWorldTransformPtr
displayingLandscape->SetWorldTransformPtr(landscape->GetWorldTransformPtr());
Entity* lanscapeNode = EditorScene::GetLandscapeNode(scene);
lanscapeNode->RemoveComponent(Component::RENDER_COMPONENT);
RenderComponent* component = new RenderComponent(displayingLandscape);
lanscapeNode->AddComponent(component);
currentLandscape = displayingLandscape;
return true;
}
示例6: Init
void DungeonSystem::Init(GameCommon* owner)
{
System::Init(owner);
Entity* dungeonEntity = GetOwner()->CreateEntity();
DungeonComponent* dungeonComponent = DungeonComponent::Pool.CreateComponent();
dungeonEntity->AddComponent(dungeonComponent);
}
示例7: CreateParticleEffectNode
Entity* ParticlesEditorSceneModelHelper::CreateParticleEffectNode()
{
Entity * newParentNodeParticleEffect = new Entity();
newParentNodeParticleEffect->SetName(ResourceEditor::PARTICLE_EFFECT_NODE_NAME);
newParentNodeParticleEffect->AddComponent(ScopedPtr<ParticleEffectComponent> (new ParticleEffectComponent()));
return newParentNodeParticleEffect;
}
示例8: main
int main(int argc, const char * argv[])
{
EntityManager *Manager = new EntityManager;
Entity *Thingy = Manager->GetNewEntity();
Thingy->AddComponent("Physics", new PhysicsClass());
Thingy->AddComponent("Graphics", new GraphicsClass());
Manager->Update(1.0f);
delete Manager;
Manager = NULL;
system("PAUSE");
return 0;
}
示例9: Init
void TestGame::Init() {
Entity *camera = new Entity( Vector3f( 0, 5, 15 ) );
camera->AddComponent( new FreeLookFreeMoveComponent() );
SetCamera( camera );
Planet *planet = new Planet( 12310, 4, 10.0f, 30 );
Entity *entity = new Entity();
RenderComponent* render = new RenderComponent( planet->CreateMesh() );
render->SetShaderType( ShaderType::SHADER_COLORIZED );
entity->AddComponent( render );
entity->AddComponent( new PlanetColorComponent( planet ) );
AddToScene( entity );
// Entity* cube = new Entity();
// cube->AddComponent( new RenderComponent( "cube.obj", "test.png" ) );
// AddToScene( cube );
}
示例10: CreateParticleEffectNode
Entity* ParticlesEditorSceneModelHelper::CreateParticleEffectNode()
{
Entity * newParentNodeParticleEffect = new Entity();
newParentNodeParticleEffect->SetName("Particle effect");
ParticleEffectComponent * newEffectComponent = new ParticleEffectComponent();
newParentNodeParticleEffect->AddComponent(newEffectComponent);
return newParentNodeParticleEffect;
}
示例11: Entity
Entity * EntityFactory::CreateDrone(double x, double y, double rotation)
{
Entity * entity;
Image * drone = nullptr;
drone = ResourceStore::Instance().GetDroneImage(63, 1);
entity = new Entity(x, y, drone->GetWidth(), drone->GetHeight(), rotation);
ComponentRenderer * renderer = new ComponentRenderer(drone,0, 63, 30);
entity->AddComponent(renderer);
entityStore.Add(entity);
return entity;
}
示例12: CreateSprite
Entity* CommonFactory::CreateSprite(std::string path)
{
Entity* sprite = new Entity();
RenderComponent* renderComponent = new RenderComponent();
sf::Texture* texture = new sf::Texture();
texture->loadFromFile(resourcePath() + path);
texture->setSmooth(true);
renderComponent->sprite = *new Sprite();
renderComponent->sprite.setTexture(*texture);
sprite->AddComponent(renderComponent);
return sprite;
}
示例13: DegCos
Entity * EntityFactory::createMissile(double damage, double x, double y, double rotation, double linearSpeed)
{
double trueX, trueY;
Entity * entity;
Image * missile = nullptr;
missile = ResourceStore::Instance().GetMissileImage();
trueX = x + DegCos(rotation-90) * missile->GetWidth() / 2;
x += x - trueX;
trueY = y - DegSin(rotation-90) * missile->GetHeight() / 2;
y += y - trueY;
entity = new Entity(x, y, missile->GetWidth(), missile->GetHeight(), rotation);
ComponentRenderer * renderer = new ComponentRenderer(missile,1,1,false);
entity->AddComponent(renderer);
ComponentLinearMovement * linearMovement = new ComponentLinearMovement(linearSpeed);
entity->AddComponent(linearMovement);
ComponentSmallExplosion * SmallExplosion = new ComponentSmallExplosion(this);
entity->AddComponent(SmallExplosion);
ComponentCircleCollision * collision = new ComponentCircleCollision(damage,true);
entity->AddComponent(collision);
entityStore.Add(entity);
return entity;
}
示例14: setTunableVariant
void VariantTuner::setTunableVariant(Variant& var, const Variant& step)
{
Entity* rootEntity = GetBaseApp()->GetEntityRoot();
VariantChangerComponent* varChanger = dynamic_cast<VariantChangerComponent*>(rootEntity->GetComponentByName("VariantChanger"));
if (varChanger == NULL)
{
varChanger = new VariantChangerComponent;
rootEntity->AddComponent(varChanger);
}
varChanger->SetChangeableVariant(&var);
varChanger->GetVar("step")->Reset();
varChanger->GetVar("step")->Set(step);
}
示例15: HideEditorLandscape
bool LandscapesController::HideEditorLandscape(EditorLandscape *hiddingLandscape)
{
hiddingLandscape->FlushChanges();
EditorLandscape *parentLandscape = hiddingLandscape->GetParentLandscape();
Landscape *nestedLandscape = hiddingLandscape->GetNestedLandscape();
if(parentLandscape)
{
Heightmap *hmap = SafeRetain(parentLandscape->GetHeightmap());
parentLandscape->SetNestedLandscape(nestedLandscape);
parentLandscape->SetHeightmap(hmap);
SafeRelease(hmap);
currentLandscape = parentLandscape;
}
else
{
EditorLandscape *editorLandscape = dynamic_cast<EditorLandscape *>(nestedLandscape);
if(editorLandscape)
{
editorLandscape->SetParentLandscape(NULL);
}
Entity* lanscapeNode = EditorScene::GetLandscapeNode(scene);
lanscapeNode->RemoveComponent(Component::RENDER_COMPONENT);
lanscapeNode->AddComponent(new RenderComponent(nestedLandscape));
if(NeedToKillRenderer(nestedLandscape))
{
SafeRelease(renderedHeightmap);
SafeRelease(landscapeRenderer);
}
currentLandscape = nestedLandscape;
}
SafeRelease(hiddingLandscape);
return true;
}