Beispiel #1
0
void Game::setupSpaces()
{
    //Set up gameplay space
    this->gameplay = new Space("GAMEPLAY", *this->inputHandler);
    this->gameplay->entityManager = EntityManager();

    TransformSystem* gameplayTransformSystem = new TransformSystem();
    StateSystem* gameplayStateSystem = new StateSystem();
    PlayerInputSystem* gameplayPIS = new PlayerInputSystem();
    MovementSystem* gameplayMovementSystem = new MovementSystem(gameplayTransformSystem);
    PickupSystem* gameplayPickupSystem = new PickupSystem(gameplayTransformSystem, gameplayMovementSystem);
    RenderSystem* gameplayRenderSystem = new RenderSystem(this->graphics, gameplayTransformSystem, gameplayStateSystem);
    PlayerControlSystem* gameplayPCS = new PlayerControlSystem(
        this->inputHandler,
        gameplayTransformSystem,
        gameplayMovementSystem,
        gameplayStateSystem,
        gameplayPIS,
        gameplayPickupSystem
    );
    CollisionSystem* gameplayCollisionSystem = new CollisionSystem(gameplayTransformSystem, gameplayMovementSystem, gameplayPCS);


    gameplay->addSystem(gameplayTransformSystem);
    gameplay->addSystem(gameplayStateSystem);
    gameplay->addSystem(gameplayPIS);
    gameplay->addSystem(gameplayPCS);
    gameplay->addSystem(gameplayCollisionSystem);
    gameplay->addSystem(gameplayPickupSystem);
    gameplay->addSystem(gameplayMovementSystem);
    gameplay->renderSystem = gameplayRenderSystem;

    this->gameplay->entityFactory = EntityFactory(
                                        &this->gameplay->entityManager,
                                        this->inputHandler,
                                        gameplayCollisionSystem,
                                        gameplayMovementSystem,
                                        gameplayPCS,
                                        gameplayPIS,
                                        gameplayRenderSystem,
                                        gameplayStateSystem,
                                        gameplayTransformSystem
                                    );

    gameplayPCS->entityFactory = &this->gameplay->entityFactory;
    gameplayPickupSystem->collisionSystem = gameplayCollisionSystem;
    //Set up menu
    /*
    this->mainmenu = new Space("MAINMENU", *this->inputHandler);
    this->mainmenu->entityManager = EntityManager();
    this->mainmenu->entityFactory = EntityFactory(
        &this->mainmenu->entityManager,
        this->inputHandler
    );

    TransformSystem menuTransformSystem = new TransformSystem();

    mainmenu->addSystem(menuTransformSystem);
    mainmenu->renderSystem = new RenderSystem(this->graphics, *menuTransformSystem);*/
}
bool CModelViewerApp::PreRunApp()
{
	m_pState = new CHLMVState();
	m_pSettings = new CHLMVSettings( GetFileSystem() );

	//TODO: fix on Linux - Solokiller
	SetToolIcon( wxICON( HLMV_ICON ) );

	SetEntityList( &g_EntityList );

	if( !EntityManager().OnMapBegin() )
	{
		FatalError( "Failed to start map\n" );
		return false;
	}

	//Must be called before we create the main window, since it accesses the window.
	UseMessagesWindow( true );

	if( !GetSettings()->Initialize( HLMV_SETTINGS_FILE ) )
	{
		return false;
	}

	m_pMainWindow = new hlmv::CMainWindow( this );

	m_pMainWindow->Show( true );

	if( !m_szModel.IsEmpty() )
		LoadModel( m_szModel );

	return true;
}
Beispiel #3
0
int main() {
    ResourceManager resourceManager = ResourceManager();
    resourceManager.addResourceDirectory("res/");
    sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "ECS Test");
    EntityManager entityManager = EntityManager(&window, 100);
    for (int i = 1; i < 10000; ++i) {
        int temp = entityManager.createEntity(sf::Vector2f(WINDOW_X * float(rand()) / RAND_MAX, WINDOW_Y * float(rand()) / RAND_MAX));
        entityManager.attachComponent(temp, RenderComponent(resourceManager.getTexture("player.png")));
        entityManager.attachComponent(temp, PhysicsComponent(sf::Vector2f(100 * (float(rand()) / RAND_MAX - 0.5), 100 * (float(rand()) / RAND_MAX - 0.5))));
    }
    // Remove some entities.
    for (int i = 1; i < 3; ++i) {
        entityManager.destroyEntity(i);
    }
    // Remove some components.
    for (int i = 3; i < 10; ++i) {
        entityManager.detachComponent(i, RENDER);
    }
    sf::Clock clock;
    while (window.isOpen()) {
        // Handle events.
        sf::Event event;
        while (window.pollEvent(event)) {
          if(event.type == sf::Event::Closed) {
              window.close();
          }
        }
        float frametime = clock.restart().asSeconds();
        std::cout << (1 / frametime) << std::endl;
        window.clear(sf::Color::White);
        entityManager.update(frametime);
        window.display();
    }
}
Beispiel #4
0
ptr<ScriptRepo> Core::CreateScriptRepo(ptr<ClientRepo> clientRepo, ptr<RemoteRepo> remoteRepo)
{
	return NEW(ScriptRepo(
		clientRepo,
		remoteRepo,
		NEW(EntityManager(clientRepo, entitySchemeManager))));
}
Beispiel #5
0
Kylin::Scene::Scene( const SceneHag& kSceneHag )
    : m_kSceneHag(kSceneHag)
    , m_pSceneLoader(NULL)
{
    m_pEntityManager = KNEW EntityManager();
    m_pEventManager  = KNEW EventManager(m_pEntityManager);

}
void CModelViewerApp::RunFrame()
{
	EntityManager().RunFrame();

	if( m_pFullscreenWindow )
		m_pFullscreenWindow->RunFrame();
	else if( m_pMainWindow )
		m_pMainWindow->RunFrame();
}
void CModelViewerApp::ShutdownApp()
{
	if( auto pSettings = GetSettings() )
	{
		pSettings->Shutdown( HLMV_SETTINGS_FILE );
	}

	if( m_pFullscreenWindow )
	{
		m_pFullscreenWindow = nullptr;
	}

	if( m_pMainWindow )
	{
		m_pMainWindow = nullptr;
	}

	if( EntityManager().IsMapRunning() )
	{
		EntityManager().OnMapEnd();
	}

	EntityManager().Shutdown();

	if( m_pSettings )
	{
		delete m_pSettings;
		m_pSettings = nullptr;
	}

	if( m_pState )
	{
		delete m_pState;
		m_pState = nullptr;
	}

	CBaseWXToolApp::ShutdownApp();
}