Пример #1
0
void ADebuff::RefreshDebuff_Implementation(ADebuff* NewDebuff)
{
    if (NewDebuff->Duration > (FinishTime - ElapsedTime)) SetRemainingTime(NewDebuff->Duration);
}
Пример #2
0
bool CollisionSystem::TransmitInfection(std::shared_ptr<Entity> transmitterEntity,
    std::shared_ptr<Entity> receiverEntity)
{
    auto transmitterInfectionComponent = std::static_pointer_cast<InfectionComponent>(Engine::GetInstance().GetSingleComponentOfClass(transmitterEntity, "InfectionComponent"));
    auto receiverInfectionComponent = std::static_pointer_cast<InfectionComponent>(Engine::GetInstance().GetSingleComponentOfClass(receiverEntity, "InfectionComponent"));

    // Only transmit to healthy entities
    if (receiverInfectionComponent->GetInfectionType() != NoInfection)
        return false;

    if (transmitterInfectionComponent->GetTransmissible())
    {
        receiverInfectionComponent->SetInfectionType(
            transmitterInfectionComponent->GetInfectionType());

        // Avoid epidemies by blocking further transmissions
        receiverInfectionComponent->SetTransmissible(false);
        receiverInfectionComponent->SetRemainingTime(
            transmitterInfectionComponent->GetRemainingTime());
        receiverInfectionComponent->SetTemporary(true);

        if (transmitterInfectionComponent->GetInfectionType() == CannotInput)
        {
            if (Engine::GetInstance().HasComponent(receiverEntity, "PlayerComponent"))
                Engine::GetInstance().PlaySoundEffect(CFG_GETP("FROZEN_SOUND_EFFECT"));

            auto spriteComponents = Engine::GetInstance().GetComponentsOfClass(receiverEntity, "SpriteComponent");
            Engine::GetInstance().GetEntityManager()->DeleteComponentsOfClass(receiverEntity, "SpriteComponent");
            Engine::GetInstance().AddComponent(
            std::make_shared<SpriteComponent>(CFG_GETP("CELL_FROZEN_IMAGE"),
                Vector(0, 0), 0, 0, true,
                CFG_GETF("CELL_FROZEN_SCALE")), receiverEntity);
            for (unsigned int i = 1; i < spriteComponents.size(); ++i)
                Engine::GetInstance().AddComponent(spriteComponents[i], receiverEntity);
        }
        else if (transmitterInfectionComponent->GetInfectionType() == StrongImpulses)
        {
            if (Engine::GetInstance().HasComponent(receiverEntity, "PlayerComponent"))
                Engine::GetInstance().PlaySoundEffect(CFG_GETP("IMPULSES_SOUND_EFFECT"));

            auto spriteComponents = Engine::GetInstance().GetComponentsOfClass(receiverEntity, "SpriteComponent");
            Engine::GetInstance().GetEntityManager()->DeleteComponentsOfClass(receiverEntity, "SpriteComponent");
            Engine::GetInstance().AddComponent(
            std::make_shared<SpriteComponent>(CFG_GETP("CELL_ERRACTIC_IMAGE"),
                Vector(0, 0), 0, CFG_GETF("CELL_ERRACTIC_ROTATION_SPEED"),
                true, CFG_GETF("CELL_ERRACTIC_SCALE")), receiverEntity);
            for (unsigned int i = 1; i < spriteComponents.size(); ++i)
                Engine::GetInstance().AddComponent(spriteComponents[i], receiverEntity);
        }
        else if (transmitterInfectionComponent->GetInfectionType() == CannotEat)
        {
            if (Engine::GetInstance().HasComponent(receiverEntity, "PlayerComponent"))
                Engine::GetInstance().PlaySoundEffect(CFG_GETP("IMPULSES_SOUND_EFFECT"));

            auto spriteComponents = Engine::GetInstance().GetComponentsOfClass(receiverEntity, "SpriteComponent");
            Engine::GetInstance().GetEntityManager()->DeleteComponentsOfClass(receiverEntity, "SpriteComponent");
            Engine::GetInstance().AddComponent(
            std::make_shared<SpriteComponent>(CFG_GETP("CELL_CANNOT_EAT_IMAGE"),
                Vector(0, 0), 0, 0, true,
                CFG_GETF("CELL_CANNOT_EAT_SCALE")), receiverEntity);
            for (unsigned int i = 1; i < spriteComponents.size(); ++i)
                Engine::GetInstance().AddComponent(spriteComponents[i], receiverEntity);
        }

        DestroyEntity(transmitterEntity);
        return true;
    }

    return false;
}