Example #1
0
void CategoryAccount::set(const CategoryAccount *account) {
	Account::set(account);
	setParentCategory(account->parentCategory());
	mbudgets = account->mbudgets;
	subCategories = account->subCategories;
}
Example #2
0
void CategoryAccount::setMergeBudgets(const CategoryAccount *account) {
	Account::set(account);
	setParentCategory(account->parentCategory());
	mergeBudgets(account, false);
	subCategories = account->subCategories;
}
Example #3
0
void BlockBehaviourGround::resolve(const sf::Vector3f& manifold, CollisionWorld::Body* other)
{
    switch (other->getType())
    {
    case CollisionWorld::Body::Type::Block:
        if ((/*Util::Vector::lengthSquared(getVelocity()) > 0.2f
            &&*/ manifold.x != 0.f)) //prevents shifting vertically
        {
            move(sf::Vector2f(manifold.x, manifold.y) * manifold.z);
            setVelocity({});

            /*Event e;
            e.type = Event::Block;
            e.block.action = Event::BlockEvent::HitGround;
            {
                auto pos = getBody()->getCentre();
                e.block.positionX = pos.x;
                e.block.positionY = pos.y;
            }
            raiseEvent(e);*/
        }
        break;
    case CollisionWorld::Body::Type::Solid:
        move(sf::Vector2f(manifold.x, manifold.y) * manifold.z);
        if (manifold.x != 0) //only stop when hitting walls
            setVelocity({}); //so boxes still slide hitting floor

        //Event e;
        //e.type = Event::Block;
        //e.block.action = Event::BlockEvent::HitGround;
        //{
        //    auto pos = getBody()->getCentre();
        //    e.block.positionX = pos.x;
        //    e.block.positionY = pos.y;
        //}
        //raiseEvent(e);

        break;
    case CollisionWorld::Body::Type::Player:
        other->applyForce(getVelocity());

        //fall if player pushed block out from underneath
        if (getFootSenseCount() <= 1u
            && (manifold.y * manifold.z) < 0.f)
        {
            setBehaviour<BlockBehaviourAir>();
            setParentCategory(Category::Block);

            //stop drag
            Event e;
            e.type = Event::Block;
            e.block.action = Event::BlockEvent::DragEnd;
            auto pos = getBody()->getCentre();
            e.block.positionX = pos.x;
            e.block.positionY = pos.y;
            raiseEvent(e);
        }
        break;
    case CollisionWorld::Body::FreeForm:
    {
        /*sf::Vector2f normal(manifold.x, manifold.y);
        move(normal * manifold.z);
        setVelocity(Util::Vector::reflect(getVelocity() * getFriction(), normal));*/
    }
    break;
    default: break;
    }
}