void CollisionSystem::IncorporateEntity(std::shared_ptr<Entity> eaterEntity,
    std::shared_ptr<Entity> eatableEntity)
{
    LOG_D("[CollisionSystem] Entity " << eaterEntity->GetId()
        << " is incorporating entity " << eatableEntity->GetId());

    auto spriteComponent = std::static_pointer_cast<SpriteComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(
            eatableEntity, "SpriteComponent"));
    auto complexityComponent = std::static_pointer_cast<ComplexityComponent>(
        Engine::GetInstance().GetSingleComponentOfClass(eaterEntity, "ComplexityComponent"));

    auto maxComplexity = complexityComponent->GetMaxComplexity();
    auto complexity = complexityComponent->GetComplexity();

    if (complexity < maxComplexity)
    {
        complexity += 1;

        Vector position;
        position.SetPolar(50, 2*M_PI*complexity/maxComplexity);
        
        complexityComponent->SetComplexity(complexity);
        spriteComponent->SetPosition(position);
        Engine::GetInstance().AddComponent(spriteComponent, eaterEntity);

        DestroyEntity(eatableEntity);
    }
}
Beispiel #2
0
//---------------------------------------------------------------------------
//Returns if the test was successful
bool TestRavindran::Execute()
{
  std::clog << "Starting TestRavindranLinux for '"
    << this->GetNewick() << "'\n";

  if (GetComplexity() > 1000000) return false;

  //Write parameters to file
  {
    std::ofstream file("theta.txt");
    file << GetTheta();
  }
  {
    //Older version expects a /n at end
    std::ofstream file("phylogeny.txt");
    file << GetNewick() << "\n\n";
  }

  #ifdef WIN32
  const std::string exe_filename = "../Exes/phy_prob_12.exe";
  const std::string full_command = "../Exes/phy_prob_12.exe";
  #else
  const std::string exe_filename = "../Exes/phy_prob_linux";
  const std::string full_command = "./../Exes/phy_prob_linux";
  #endif

  return Test::Execute(
    exe_filename,
    full_command,
    "expected_probability.txt");
}