Exemplo n.º 1
0
/** 
 * This method builds a ModificationRequest srv 
 * For stop operator, the path can be retreived from srv
 * */
void Modifier::buildModificationRequest(const Population& pop, bool imminent_collision, ramp_msgs::ModificationRequest& result)
{

  // Push the target paths onto the modification request
  std::vector<int> targets;

  if(!imminent_collision || (move_dist_ > 100 && move_dir_ > 100))
  {
    ////ROS_INFO("Modifier: No IC");
    result.request.op = getOperator();
    targets           = getTargets(result.request.op, pop);
  }
  else
  {
    ////ROS_INFO("Modifier: Calling Move because IC exists");
    result.request.op = "move";
    targets.push_back(pop.calcBestIndex());  
  }


  //////ROS_INFO("targets.size(): %i", (int)targets.size());
  for(unsigned int i=0;i<targets.size();i++) 
  {
    //std::cout<<"\nTarget index: "<<targets.at(i);
    //std::cout<<"\nPath "<<targets.at(i)<<" size: "<<pop.paths_.at(targets.at(i)).size()<<"\n";
    result.request.paths.push_back(
        pop.paths_.at(targets.at(i)).buildPathMsg());
  }

  result.request.move_dir = move_dir_;
  result.request.move_dist = move_dist_;

} // End buildModificationRequest
Exemplo n.º 2
0
bool Slot::disconnect(Slot& target) {
	std::set<Slot*> targets = getTargets();
	if (targets.find(&target) == targets.end())
		return false;
	bool res = true;
	res &= target._removeTarget(this);
	res &= _removeTarget(&target);
	return res;
}
Exemplo n.º 3
0
bool Slot::disconnect() {
	bool res = true;
	std::set<Slot*>::iterator tIter;
	std::set<Slot*> targets = getTargets();
	for (tIter = targets.begin(); tIter != targets.end(); tIter++) {
		res &= (*tIter)->_removeTarget(this);
		res &= _removeTarget(*tIter);
	}
	return res;
}
Exemplo n.º 4
0
vector<int> fixedTargets(vector<int> dst, FireInfo* origin, int owner, int target, int parentTarget)
{
    vector<int> result;
    vector<int> vaild = getAllVaildTargets(origin, owner, target, parentTarget);
    
    for (auto it : dst)
    {
        if (find(vaild.begin(), vaild.end(), it) != vaild.end()) {
            result.push_back(it);
        }
    }
    
    if (result == dst && result.size() > 0) {
        return result;
    }
    
    return getTargets(origin, owner, target, parentTarget);
}
Exemplo n.º 5
0
void StateBuffRm::execute(StateBase *parent)
{
    auto battleInfo = getBattleInfo();
    auto dst = battleInfo->allPets[buff->belongs.owner];

    // to do ...
    BatSeqBuffRm* h = new BatSeqBuffRm;
    h->buffId = buff->bid;
    h->petUid = dst->uid;
    getBattleInfo()->pushSeq(shared_ptr<ISeq>(h));
    
    // 移除附加效果
    shared_ptr<FireBuff> fireInfo(new FireBuff);
    assign(fireInfo.get(), buff, buff->keyBuff, 0);
    fireInfo->parent = nullptr;
    fireInfo->origin = nullptr;
    battleInfo->pushSkill(fireInfo);
    
    for (auto subsk : buff->keyBuff->subs) {
        fireInfo->targets = battleInfo->getTargets(fireInfo->origin, buff->belongs.owner, subsk->target, subsk->parent.lock()->target);
        for (int i=0; i<fireInfo->targets.size(); i++) {
            int dstuid = fireInfo->targets[i];
            if (battleInfo->allPets[dstuid]->isBating) {
                assign(fireInfo.get(), buff, subsk.get(), dstuid);
                createUndoEffect(2, subsk->subEffId)->undoExecute();
            }
        }
    }
    
    battleInfo->popSkill();

    // 移除buff
    for (auto pit=dst->buffs.begin(); pit != dst->buffs.end(); ++pit) {
        if ((*pit)->bid == buff->bid) {
            dst->buffs.erase(pit);
            break;
        }
    }
    
    battleInfo->getTriggerCenter()->removeTrigger(buff->attached_trigger.lock());
    buff->attached_trigger.reset();
    exitState();
}
Exemplo n.º 6
0
   void RoadNavigation::planRoadDetection(const nav_msgs::Path::ConstPtr& lane_traj, const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& pose) {
        nav_msgs::Path target_traj = decideTargetTrajectory(lane_traj);
        geometry_msgs::Pose current_pose = pose->pose.pose;

        std::vector<geometry_msgs::Pose> targets = getTargets(current_pose, target_traj);
        std::vector<std::vector<PathSegment*> > paths = getPaths(current_pose, targets);

        if (paths.size() == 0) {
            ROS_WARN("[local_planner]: No path found");
            return;
        }

//        nav_msgs::Path best_path;
//        for (int i = 0; i < paths.size(); i++) {
//            // TODO: Choose the best path
//            best_path = paths[0];
//        }
//
//        best_path.header.stamp = ros::Time::now();
//        return best_path;
    }
Exemplo n.º 7
0
void
load(CFBundleRef bundle, Boolean bundleVerbose)
{
	CFArrayRef	targets;	/* The array of dictionaries representing targets
					 * with a "kick me" sign posted on their backs.*/

	if (bundleVerbose) {
		_verbose = TRUE;
	}

	SCLog(_verbose, LOG_DEBUG, CFSTR("load() called"));
	SCLog(_verbose, LOG_DEBUG, CFSTR("  bundle ID = %@"), CFBundleGetIdentifier(bundle));

	/* get the bundle's URL */
	myBundleURL = CFBundleCopyBundleURL(bundle);
	if (!myBundleURL) {
		return;
	}

	/* get the targets */
	targets = getTargets(bundle);
	if (!targets) {
		/* if nothing to do */
		CFRelease(myBundleURL);
		return;
	}

	/* start a kicker for each target */
	CFArrayApplyFunction(targets,
			     CFRangeMake(0, CFArrayGetCount(targets)),
			     startKicker,
			     NULL);
	CFRelease(targets);

	return;
}
Exemplo n.º 8
0
int patchEntities(double versionFile, char *mapName)
{
	char patchFile[MAX_PATH_LENGTH], *line, *savePtr, itemName[MAX_VALUE_LENGTH];
	char key[MAX_VALUE_LENGTH], value[MAX_VALUE_LENGTH];
	int skipping = FALSE, x, y, read, found, saveMap;
	unsigned char *buffer;
	Entity *e;
	EntityList *el, *entities;
	Target *t;

	savePtr = NULL;

	snprintf(patchFile, sizeof(patchFile), "data/patch/%0.2f.dat", versionFile);

	saveMap = TRUE;

	if (existsInPak(patchFile) == TRUE)
	{
		buffer = loadFileFromPak(patchFile);

		line = strtok_r((char *)buffer, "\n", &savePtr);

		while (line != NULL)
		{
			if (line[strlen(line) - 1] == '\n')
			{
				line[strlen(line) - 1] = '\0';
			}

			if (line[strlen(line) - 1] == '\r')
			{
				line[strlen(line) - 1] = '\0';
			}

			sscanf(line, "%s", itemName);

			if (strcmpignorecase(itemName, "MAP_NAME") == 0)
			{
				sscanf(line, "%*s %s\n", itemName);

				skipping = strcmpignorecase(itemName, mapName) == 0 ? FALSE : TRUE;
			}

			else if (strcmpignorecase(itemName, "MODIFY_OBJECTIVE") == 0 && skipping == FALSE)
			{
				sscanf(line, "%*s \"%[^\"]\" \"%[^\"]\"", key, value);

				modifyObjective(key, value);
			}

			else if (strcmpignorecase(itemName, "REMOVE_OBJECTIVE") == 0 && skipping == FALSE)
			{
				sscanf(line, "%*s \"%[^\"]\"", key);

				removeObjective(key);
			}

			else if (strcmpignorecase(itemName, "REMOVE_TRIGGER") == 0 && skipping == FALSE)
			{
				sscanf(line, "%*s \"%[^\"]\"", key);

				removeGlobalTrigger(key);

				removeTrigger(key);
			}

			else if (strcmpignorecase(line, "ADD_ENTITY") == 0 && skipping == FALSE)
			{
				loadResources(savePtr);
			}

			else if (strcmpignorecase(itemName, "REMOVE_ENTITY") == 0 && skipping == FALSE)
			{
				read = sscanf(line, "%*s %s %d %d", itemName, &x, &y);

				found = FALSE;

				e = getEntityByObjectiveName(itemName);

				if (e != NULL)
				{
					e->inUse = FALSE;

					found = TRUE;
				}

				if (found == FALSE)
				{
					t = getTargetByName(itemName);

					if (t != NULL)
					{
						t->active = FALSE;

						found = TRUE;
					}
				}

				if (found == FALSE && read == 3)
				{
					e = getEntityByStartXY(x, y);

					if (e != NULL)
					{
						e->inUse = FALSE;

						found = TRUE;
					}
				}
			}

			else if (strcmpignorecase(itemName, "UPDATE_ENTITY") == 0 && skipping == FALSE)
			{
				read = sscanf(line, "%*s %s %s %s", itemName, key, value);

				if (strcmpignorecase(itemName, "PLAYER") == 0)
				{
					e = &player;
				}

				else
				{
					e = getEntityByObjectiveName(itemName);
				}

				if (e != NULL)
				{
					if (strcmpignorecase(value, "NULL") == 0)
					{
						STRNCPY(value, "", sizeof(value));
					}

					setProperty(e, key, value);
				}
			}

			else if (strcmpignorecase(itemName, "UPDATE_ENTITY_BY_START") == 0 && skipping == FALSE)
			{
				read = sscanf(line, "%*s %d %d %s %[^\n]s", &x, &y, key, value);

				e = getEntityByStartXY(x, y);

				if (e != NULL)
				{
					setProperty(e, key, value);
				}
			}

			else if (strcmpignorecase(itemName, "UPDATE_ENTITY_BY_XY") == 0 && skipping == FALSE)
			{
				read = sscanf(line, "%*s %d %d %s %[^\n]s", &x, &y, key, value);

				e = getEntityByXY(x, y);

				if (e != NULL)
				{
					setProperty(e, key, value);
				}
			}

			else if (strcmpignorecase(itemName, "TRANSLATE_ENTITIES") == 0 && skipping == FALSE)
			{
				read = sscanf(line, "%*s %d %d", &x, &y);

				entities = getEntities();

				player.x -= x;
				player.y -= y;

				for (el=entities->next;el!=NULL;el=el->next)
				{
					e = el->entity;

					e->x -= x;
					e->y -= y;

					if (e->startX - x > 0)
					{
						e->startX -= x;
					}

					if (e->startY - y > 0)
					{
						e->startY -= y;
					}

					if (e->endX - x > 0)
					{
						e->endX -= x;
					}

					if (e->endY - y > 0)
					{
						e->endY -= y;
					}
				}

				t = getTargets();

				for (x=0;x<MAX_TARGETS;x++)
				{
					if (t[x].active == TRUE)
					{
						if (t[x].x - x > 0)
						{
							t[x].x -= x;
						}

						if (t[x].y - y > 0)
						{
							t[x].y -= y;
						}
					}
				}
			}

			else if (strcmpignorecase(itemName, "RENAME_MAP") == 0 && skipping == FALSE)
			{
				saveMap = FALSE;
			}

			line = strtok_r(NULL, "\n", &savePtr);
		}

		free(buffer);
	}

	return saveMap;
}
Exemplo n.º 9
0
GIDSet BlueConfig::parseTarget(const std::string& target) const
{
    return brion::Target::parse(getTargets(), target);
}
Exemplo n.º 10
0
bool Slot::connected(Slot& target) const {
	std::set<Slot *> targets = getTargets();
	return (targets.find(&target) != targets.end());
}
Exemplo n.º 11
0
bool Slot::connected() const {
	return (getTargets().size() > 0);
}
Exemplo n.º 12
0
void StateBuffTrigger::execute(StateBase* parent)
{
    auto battle = getBattleInfo();

    if (this->stage != 1) {
        BatSeqBuffTrigger* tg = new BatSeqBuffTrigger;
        tg->buffId = buff->bid;
        tg->petUid = buff->belongs.owner;
        battle->pushSeq(shared_ptr<ISeq>(tg));
    }

    shared_ptr<FireBuff> fireInfo(new FireBuff);
    assign(fireInfo.get(), buff, buff->keyBuff, 0);
    fireInfo->parent = nullptr;
    fireInfo->origin = battle->topSkill() != nullptr ? battle->topSkill().get() : nullptr;
    battle->pushSkill(fireInfo);

    for (auto subsk : buff->keyBuff->subs) {
        fireInfo->targets = battle->getTargets(fireInfo->origin, buff->belongs.owner, subsk->target, subsk->parent.lock()->target);
        for (int i=0; i<fireInfo->targets.size(); i++) {
            if (this->stage == subsk->triggerStage) {
                int dstuid = fireInfo->targets[i];
                if (getBattleInfo()->allPets[dstuid]->isBating) {
                    assign(fireInfo.get(), buff, subsk.get(), dstuid);
                    createEffect(2, subsk->subEffId)->execute();
                }
            }
        }

        battle->checkDead(fireInfo->targets);
    }

    // 以次计算触发的每个效果
    vector<Buff*> triggerSubBuff;
    for (auto sub : buff->keyBuff->subs)
    {
        if (stage == sub->triggerStage) {
            for (auto arg : sub->triggerParams) {
                if (createTriggerCondi(buff->belongs.owner, sub->triggerCondi, arg)->isTrigger(stage, fireInfo->origin)) {
                    triggerSubBuff.push_back(sub.get());
                    break;
                }
            }
        }
    }

    //
    for (auto& it : triggerSubBuff)
    {
        assign(fireInfo.get(), buff, it, 0);
        fireInfo->targets = battle->getTargets(fireInfo->origin, buff->belongs.owner, it->target, it->parent.lock()->target);
        for (int i=0; i<fireInfo->targets.size(); i++) {
            int dstuid = fireInfo->targets[i];
            if (getBattleInfo()->allPets[dstuid]->isBating) {
                assign(fireInfo.get(), buff, it, dstuid);
                createEffect(2, it->subEffId)->execute();
            }
        }
    }

    battle->popSkill();

    exitState();

}