Пример #1
0
bool TentacleLogicCmp::checkDependency (void){
    bool check = true;
    if (!getEntity()->HAS_CMP(PositionComponent))
        check = false;
	if (!getEntity()->HAS_CMP(PhysicsCmp))
		check = false;
    return check;}
Пример #2
0
bool TriggerCmp::checkDependency (void){
  bool isCheck = true;
  if (!getEntity()->HAS_CMP(PositionComponent))
    isCheck = false;
  if (!getEntity()->HAS_CMP(CollisionCmp))
    isCheck = false;
  return isCheck;}
	vector<shared_ptr<Action> > BulletAnimator::animate()
	{
		vector<shared_ptr<Action> > actions;
		shared_ptr<Model> model = getEntity().getSingleComponent<Model>();

		if (distance > range)
		{
			Simplicity::removeEntity(getEntity().getName());
			return vector<shared_ptr<Action> >();
		}

		unique_ptr<TransformationMatrix<> > transformation = MathFactory::getInstance().createTransformationMatrix();
		unique_ptr<TranslationVector<> > vector = MathFactory::getInstance().createTranslationVector();
		vector->setData(direction->getData());
		vector->scale(speed);
		transformation->translate(*vector);

		distance += speed;

		shared_ptr<TransformNodeAction> moveAction(
			new TransformNodeAction(getEntity(), *model->getNode(), move(transformation)));
		actions.push_back(moveAction);

		return actions;
	}
Пример #4
0
void Battlefield::draw() const
{
    std::vector<int> entityIds(entities_.size());
    iota(std::begin(entityIds), std::end(entityIds), 0);

    // Arrange entities logically by z-order.
    sort(std::begin(entityIds), std::end(entityIds), [&] (int a, int b)
         { return getEntity(a).z < getEntity(b).z; });

    sdlClear(displayArea_);
    SdlSetClipRect(displayArea_, [&] {
        for (auto id : entityIds) {
            const auto &e = getEntity(id);
            if (e.visible) {
                if (e.frame < 0) {
                    sdlBlit(e.img, sPixelFromHex(e.hex) + e.pOffset);
                }
                else {
                    sdlBlitFrame(e.img, e.frame, e.numFrames,
                                 sPixelFromHex(e.hex) + e.pOffset);
                }
            }
        }
    });
}
Пример #5
0
cocos2d::Node* System::getNode()
{
    if (getEntity()!=nullptr) {
        return getEntity()->getNode();
    }
    
    return nullptr;
}
Пример #6
0
bool TileLogicCmp::checkDependency (void) {
  bool check = true;
  if (!getEntity()->HAS_CMP(PositionComponent))
    check = false;
  if (!getEntity()->HAS_CMP(SpriteCmp))
    check = false;
  if (!getEntity()->HAS_CMP(CollisionCmp))
    check = false;    
    return check;}
Пример #7
0
void TileLogicCmp::onDestroyed (OnTileDestroyed* event_){
	if (!event_->_tile)
		return;
  if(event_->_tile == getEntity()){
    auto level = Director::getInstance()->getRunningScene()->getLevel();
    auto pos = getEntity()->GET_CMP(PositionComponent)->getPosition();
    Eigen::Vector2i idx = level->posToTileIndex(pos);
    level->removeCell(idx.x(), idx.y());
		event_->_tile = nullptr;}}
Пример #8
0
void Bullet::CollisionEntity::onCollision(iCollisionEntity &o, const iContactInfo &ci)
{
    o, ci;
    getEntity().bExplode = true;
    const TankContactInfo &tci = *(const TankContactInfo *)&ci;
    if (tci.getNumber() > 0)
    {
        getEntity().explodePos = tci.getData()->m_xContacts[0];
    }
}
Пример #9
0
void RExporter::setLinetypeId(RLinetype::Id ltId) {
    RDocument* doc = NULL;
    if (getEntity()!=NULL) {
        doc = getEntity()->getDocument();
    }
    if (doc == NULL) {
        doc = document;
    }

    currentLinetypePattern =
        RLinetypePatternMap::getPattern(doc->getLinetypeName(ltId));
}
Пример #10
0
void RExporter::setLinetypeId(RLinetype::Id ltId) {
    RDocument* doc = NULL;
    if (getEntity()!=NULL) {
        doc = getEntity()->getDocument();
    }
    if (doc == NULL) {
        doc = document;
    }

    QSharedPointer<RLinetype> lt = doc->queryLinetype(ltId);

    if (!lt.isNull()) {
        currentLinetypePattern = lt->getPattern();
    }
}
Пример #11
0
bool TriggerCmp::init(void){
  _isInit = true;
  auto colCmp = getEntity()->GET_CMP(CollisionCmp);
  auto posCmp = getEntity()->GET_CMP(PositionComponent);
  std::list<ITrigger *>::iterator it;
  for (it = _triggers.begin(); it != _triggers.end(); ++ it){
    (*it)->setIsRemovedFromGame(false);
    (*it)->setIsActive(true);
    (*it)->addTriggerRegionRect(posCmp->getPosition(),
      colCmp->getBoundingBox()._width,
      colCmp->getBoundingBox()._height);
  }
  
  
  return _isInit;}
Пример #12
0
void entidad(){
	char entity[30];
	char cad[110]={"E-Alumno_F[s-(boleta),c-(nombreCompleto:s-(nombre),s-(apPat),s-(apMat)),k-(boleta)].\n"};
	getEntity(cad,entity);
	printf("\n|entity=%s|",entity);
	printf("\n|cad=%s|",cad);
}
Пример #13
0
bool Scene::enterScene(ServiceID avatarID, const std::string & token, SessionID sID)
{
    EntityPtr entity = getUserEntity(avatarID);
    if (!entity)
    {
        return false;
    }
    if (entity->_token != token)
    {
        return false;
    }
    entity->_clientSessionID = sID;
    if (!getEntity(entity->_info.eid))
    {
        addEntity(entity);
    }
    FillSceneNotice notice;
    EntityFullInfo info;
    for (auto kv : _entitys)
    {
        kv.second->pickProto(info);
        notice.entitys.push_back(info);
    }
    notice.serverTime = getFloatNowTime();
    notice.sceneStartTime = _startTime;
    notice.sceneEndTime = _endTime;
    sendToClient(avatarID, notice);
    return true;
}
Пример #14
0
const std::pair<bool, std::string> Item::drop(const std::vector<std::string>& arguments, Entity* item) {
	//drop X in/into/... Y
	//drop X Y
	unsigned int size = arguments.size();
	if (size > 2) {
		//get the name
		std::string into((size > 3) ? arguments[3] : arguments[2]);

		if (Utilities::compareTo(this->name, into)) {
			//its me
			return storeItem(item);
		} else {
			//it's not me, get the item into store if opened
			if (opened) {
				Entity* itemInto = getEntity(into);
				if (itemInto != nullptr) {
					return itemInto->drop(arguments, item);
				}
			}
			//I ask because if is not opened, don't know why I'm asking this item so probably is a mistake due to a misunderstanding and not because the item is closed
			std::pair<bool, std::string> result;
			result.first = false;
			result.second = "Drop where?";
			return result;
		}

	} else if (!opened) {
		std::pair<bool, std::string> result;
		result.first = false;
		result.second = "Can't drop here, is closed";
		return result;
	} else {
		return storeItem(item);
	}
}
Пример #15
0
void RGraphicsSceneQt::exportRectangle(const RVector& p1,
        const RVector& p2) {
    if (getEntity() == NULL && !exportToPreview) {
        qWarning("RGraphicsSceneQt::exportRectangle: entity is NULL");
        return;
    }

    RPainterPath p;
    p.setZLevel(0);
    p.setPen(currentPen);
    p.setBrush(currentBrush);
    RVector v = RVector::getMinimum(p1, p2);
    p.addRect(v.x, v.y, fabs(p2.x - p1.x), fabs(p2.y - p1.y));

    if (!exportToPreview) {
        if (draftMode) {
            addPath(getBlockRefOrEntity()->getId(), p, true);
        }
        else {
            addPath(getBlockRefOrEntity()->getId(), p, false);
        }
    } else {
        addToPreview(p);
    }
}
Пример #16
0
void RGraphicsSceneQt::exportPainterPaths(const QList<RPainterPath>& paths) {
    if (getEntity() == NULL && !exportToPreview) {
        qWarning("RGraphicsSceneQt::exportPainterPaths: entity is NULL");
        return;
    }

    RPainterPath path;
    for (int i=0; i<paths.size(); i++) {
        path = paths.at(i);
        path.setZLevel(0);

        path.setBrush(getBrush(path));
        if (path.getInheritPen()) {
            path.setPen(currentPainterPath.getPen());
        }
        else {
            path.setPen(getPen(path));
        }

        if (!exportToPreview) {
            // export into current path (used for complex linetypes):
            if (currentPainterPath.isValid()) {
                currentPainterPath.addPath(path);
            }
            else {
                addPath(getBlockRefOrEntity()->getId(), path, draftMode);
            }
        }
        else {
            addToPreview(path);
        }
    }
}
Пример #17
0
void RGraphicsSceneQt::exportTriangle(const RTriangle& triangle) {
    if (getEntity() == NULL && !exportToPreview) {
        qWarning("RGraphicsSceneQt::exportTriangle: entity is NULL");
        return;
    }

    // add new painter path with current entity ID:
    RPainterPath p;
    p.setZLevel(0);
    if (draftMode || screenBasedLinetypes) {
        QPen draftPen = currentPen;
        draftPen.setWidth(0);
        p.setPen(draftPen);
    }
    else {
        p.setPen(currentPen);
    }
    p.setBrush(currentBrush);
    p.moveTo(triangle.corner[0]);
    p.lineTo(triangle.corner[1]);
    p.lineTo(triangle.corner[2]);
    p.lineTo(triangle.corner[0]);

    if (!exportToPreview) {
        addPath(getBlockRefOrEntity()->getId(), p, draftMode);
    } else {
        addToPreview(p);
    }
}
Пример #18
0
bool Scene::removeEntity(EntityID eid)
{
    auto entity = getEntity(eid);
    if (!entity)
    {
        LOGE("");
        return false;
    }
    if(_move->isValidAgent(entity->_control.agentNo))
    {
        _move->delAgent(entity->_control.agentNo);
        entity->_control.agentNo = RVO::RVO_ERROR;
    }
    if (entity->_state.etype == ENTITY_PLAYER)
    {
        _players.erase(entity->_state.avatarID);
        SceneMgr::getRef().sendToWorld(SceneServerGroupStateFeedback(getSceneID(), entity->_state.groupID, SCENE_NONE));
    }
    _entitys.erase(eid);

    RemoveEntityNotice notice;
    notice.eids.push_back(eid);
    broadcast(notice);
    onRemoveEntity(entity);
    return true;
}
Пример #19
0
        void CollisionDestroyPositioner::affect(float ms)
        {
            Entity *entity = getEntity();
            CollisionDetector *collisionDetector =
                    entity->getLevel()->getCollisionDetector();

            /* Convert vectors to ellipse space. */
            Vector2D position = entity->getPosition();
            Vector2D velocity = entity->getVelocity() * ms;

            /* Used later. */
            float time;
            Vector2D collision;

            if(collisionDetector->getClosestCollision(
                    entity->getRadius(), position, velocity,
                    &time, &collision)) {
                entity->setGarbage();
                entity->setPosition(collision);
            } else {
                entity->setPosition(position + velocity);
            }

            velocity = entity->getVelocity() + getGravity() * ms;
            entity->setVelocity(velocity);
        }
Пример #20
0
QVariant CompanyModel::data(const QModelIndex &index, int role) const
{
    int column = index.column();
    int row = index.row();
    if (row < 0) {
        return QVariant();
    }
    Company *company = static_cast<Company *>(getEntity(row));

    if ((column == 0) && ((role == Qt::DisplayRole) || role == (Qt::EditRole))) {
        return company->fields["company_name"];
    }

    if (role == Qt::DisplayRole && column == 1) {
        return company->getTypeName();
    }

    if (role == Qt::DisplayRole && column == 2) {
        return company->fields["company_address"];
    }

    if (role == Qt::DisplayRole && column == 3) {
        return company->fields["company_tel"];
    }

    if (role == Qt::DisplayRole && column == 4) {
        return company->fields["company_account"];
    }

    if (role == typeRole) {
        return company->fields["company_type"];
    }

    return EntityModel::data(index, role);
}
Пример #21
0
Entity *TechTree::createEntity(std::string name) {
    const Entity *ref = getEntity(name);
    if (ref == NULL)
        return NULL;

    return new Entity(*ref);
}
Пример #22
0
        OBCTurret(Entity& mE, OBCPhys& mCPhys, OBCDraw& mCDraw,
            OBCKillable& mCKillable, Dir8 mDir, const OBWpnType& mWpn,
            float mShootDelay, float mPJDelay, int mShootCount) noexcept
            : OBCActor{mE, mCPhys, mCDraw},
              cKillable(mCKillable),
              direction{mDir},
              wpn{game, OBGroup::GFriendlyKillable, mWpn},
              shootDelay{mShootDelay},
              pjDelay{mPJDelay},
              shootCount{mShootCount}
        {
            cDraw.setRotation(getDegFromDir8(direction));

            getEntity().addGroups(OBGroup::GEnemy, OBGroup::GEnemyKillable);
            body.setResolve(false);
            body.addGroups(OBGroup::GSolidGround, OBGroup::GSolidAir,
                OBGroup::GEnemy, OBGroup::GKillable, OBGroup::GEnemyKillable);

            tckShoot.restart(shootDelay);
            repeat(tlShoot,
                [this]
                {
                    shoot();
                },
                shootCount, pjDelay);

            cKillable.onDeath += [this]
            {
                game.createEShard(5, cPhys.getPosI());
            };
        }
Пример #23
0
void Gizmo::updatePositionScale()
{
	const TransformPtr& transObject = nodeObject->getTransform();

	if( !transObject )
		return;

	const BoundingBox& boxObject = transObject->getWorldBoundingVolume();
	Vector3 centerObject = boxObject.getCenter();

	// Get the editor camera and its transform.
	CameraPtr camera = weakCamera;
	const EntityPtr& nodeCamera = camera->getEntity();
	const TransformPtr& transCamera = nodeCamera->getTransform();

	// Get the distance between the two points.
	const Vector3& posGizmo = boxObject.getCenter();
	const Vector3& posCamera = transCamera->getPosition();
	float distance = posCamera.distance(posGizmo);

	// Get the gizmo node and its transform.
	const EntityPtr& nodeGizmo = getEntity();
	const TransformPtr& transGizmo = nodeGizmo->getTransform();

	// Scale the gizmo relative to the distance.
	float scaleFactor = distance / 3.0f;
	transGizmo->setScale( scaleFactor );

	// Update the gizmo position to match the object.
	transGizmo->setPosition( centerObject );
}
Пример #24
0
void RGraphicsSceneQt::startEntity(bool topLevelEntity) {
    if (getEntity() == NULL) {
        return;
    }

    RGraphicsScene::startEntity(topLevelEntity);

    if (!exportToPreview) {
        if (topLevelEntity) {
            // top level entity (i.e. not entity in block ref): remove previous graphical representations:
            painterPaths.remove(getEntity()->getId());
            images.remove(getEntity()->getId());
            texts.remove(getEntity()->getId());
        }
    }
}
Пример #25
0
void Scene::onPlayerInstruction(ServiceID avatarID, ReadStream & rs)
{
    if (avatarID == InvalidAvatarID)
    {
        return;
    }
    if (rs.getProtoID() == MoveReq::getProtoID())
    {
        MoveReq req;
        rs >> req;
        LOGD("MoveReq avatarID[" << avatarID << "] req=" << req);
        auto entity = getEntity(req.eid);
        if (!entity || entity->_state.avatarID != avatarID || entity->_state.etype != ENTITY_PLAYER
            || (req.action != MOVE_ACTION_IDLE && req.action == MOVE_ACTION_FOLLOW && req.action == MOVE_ACTION_PATH)
            || entity->_state.state != ENTITY_STATE_ACTIVE
                    )
        {
            sendToClient(avatarID, MoveResp(EC_ERROR, req.eid, req.action));
            return;
        }
        if (!_move->doMove(req.eid, (MOVE_ACTION)req.action, entity->getSpeed(), req.follow, req.waypoints))
        {
            sendToClient(avatarID, MoveResp(EC_ERROR, req.eid, req.action));
            return;
        }
        if (entity->_skillSys.combating)
        {
            entity->_skillSys.combating = false;
        }

    }
Пример #26
0
void View::appear(const std::string& eid, float stamp)
{
    Entity* ent = getEntity(eid);
    if (!ent) {
        getEntityFromServer(eid);
        return; // everything else will be done once the SIGHT arrives
    }

    if (ent->m_recentlyCreated)
    {
        EntityCreated.emit(ent);
        ent->m_recentlyCreated = false;
    }
    
    if (ent->isVisible()) return;
    
    if ((stamp == 0) || (stamp > ent->getStamp())) {
        if (isPending(eid)) {
            m_pending[eid] = SACTION_APPEAR;
        } else {
            // local data is out of data, re-look
            getEntityFromServer(eid);
        }
    } else
        ent->setVisible(true);

}
bool EntityManager_RegisterProperty(EntityManager *entityManager, const char *entityName, const char *propertyName, void *itemData) {
  void *entity = NULL;

  if (entityManager == NULL || propertyName == NULL || entityName == NULL || itemData == NULL) {
    if (Entity_TestMode == false) {
      snprintf(errStr, sizeof(errStr), "Internal error in EntityManager_RegisterProperty: entityManager, property "
                                       "name '%s' entityName and data must not be NULL\n",
               propertyName);
      Utils_Abort(errStr);
    } else
      return false;
  }
  if (getEntity(entityManager, entityName, &entity) == false) {
    snprintf(errStr, sizeof(errStr), "EntityManager_RegisterProperty: entity '%s' is not in entityManager", entityName);
    return false;
  }
  debug_print("Add property '%s'\n", propertyName);
  if (EntityManager_IsEntityInUsersList(entityManager, entityName) == true)
    return ItemsList_AddItem(((userData *)entity)->PropertiesData, propertyName, itemData);
  else if (EntityManager_IsEntityInGroupsList(entityManager, entityName) == true)
    return ItemsList_AddItem(((groupData *)entity)->PropertiesData, propertyName, itemData);
  else if (EntityManager_IsEntityInResourcesList(entityManager, entityName) == true)
    return ItemsList_AddItem(((resourceData *)entity)->PropertiesData, propertyName, itemData);
  return false;
}
Пример #28
0
			inline void init()
			{
				body.addGroups(OBGroup::GProjectile);
				body.addGroupsToCheck(OBGroup::GSolidGround, OBGroup::GSolidAir);
				body.addGroupsNoResolve(OBGroup::GFriendly, OBGroup::GEnemy, OBGroup::GProjectile);
				body.setResolve(false);
				body.onDetection += [this](const DetectionInfo& mDI)
				{
					if(fallInPit && mDI.body.hasGroup(OBGroup::GPit)) getEntity().destroy();

					if(killDestructible && mDI.body.hasGroup(OBGroup::GEnvDestructible))
					{
						getComponentFromBody<OBCHealth>(mDI.body).damage(100000);
						destroy();
					}

					if(mDI.body.hasGroup(targetGroup) && getComponentFromBody<OBCHealth>(mDI.body).damage(dmg * dmgMult) && pierceOrganic-- == 0)
					{
						destroy();
					}
					else if(!mDI.body.hasGroup(OBGroup::GOrganic) && mDI.body.hasGroup(OBGroup::GSolidAir))
					{
						if(bounce) return;
						game.createPDebris(6, cPhys.getPosPx());
						assets.playSound("Sounds/bulletHitWall.wav");
						destroy();
					}
				};
				body.setRestitutionX(1.f);
				body.setRestitutionY(1.f);

				refreshMult();
			}
Пример #29
0
/**
 * The default implementation calls the \ref REntity::exportEntity() function
 * of the entity.
 * This method may use the \c currentEntity stack to access the
 * entity that is currently being exported.
 * Exporters can choose to reimplement this function to export an entity
 * in a target platform specific manner (e.g. to optimize things for
 * a specific platform).
 */
void RExporter::exportCurrentEntity(bool preview) {
    REntity* entity = getEntity();
    if (entity==NULL) {
        return;
    }

    // if this exporter exports a visual
    // representation of the drawing (scene, view, print)...
    if (isVisualExporter()) {
        // ... only export entities on visible layers:
        if (currentLayer!=NULL && currentLayer->isFrozen()) {
            return;
        }

        // ... only export entities in visible blocks:
        RBlockReferenceEntity* blockRef = dynamic_cast<RBlockReferenceEntity*>(entity);
        if (blockRef!=NULL) {
            RBlock::Id blockId = blockRef->getReferencedBlockId();
            if (blockId!=RBlock::INVALID_ID) {
                QSharedPointer<RBlock> block = document->queryBlockDirect(blockId);
                if (!block.isNull() && block->isFrozen()) {
                    return;
                }
            }
        }
    }

    setEntityAttributes();
    entity->exportEntity(*this, preview);
}
Пример #30
0
void BulletComponent::update(float delta)
{
    EnemyComponent *enemy = target->getComponent<EnemyComponent>();

    if(enemy != nullptr) {
        destination = target->getPosition();
    }
    QVector3D dir = -(this->getEntity()->getPosition() - destination);
    if(dir.length() < 10) {
        if(enemy != nullptr) {
            enemy->takeDamage(damage);
            QVector3D v = getEntity()->getPosition();
            v.setX(v.x() / 768);
            v.setY(v.y() / 624);
            v.setZ(0);

            FMODManager::getInstance()->setCurrentEvent("event:/hit");
            FMODManager::getInstance()->setEventInstancePosition(v);
            FMODManager::getInstance()->setEventInstanceVolume(0.4);
            FMODManager::getInstance()->setParameterValue("pitch", 0.3 + (qrand() % 200) * 0.001);
            FMODManager::getInstance()->startEventInstance();
        }

        this->getEntity()->release();
    } else {
        dir.normalize();
        this->getEntity()->setPosition(this->getEntity()->getPosition() + dir * speed * delta);
    }
}