예제 #1
0
std::vector<FunctionCallerID> EntityHP::actionsOnMe()
{
  std::vector<FunctionCallerID> list;
  FunctionCaller att = &makeAttack; 
  FunctionCallerID functionID(att, "Attack");
  list.push_back(functionID);
  return list;
}
예제 #2
0
파일: Unit.cpp 프로젝트: kevinkraft/RTS_3
std::vector<FunctionCallerID> Unit::actionsByMyself()
{
  std::vector<FunctionCallerID> list = EntityAction::actionsByMyself();
  FunctionCaller move = &makeMovement; 
  FunctionCallerID functionID(move, "Move");
  list.push_back(functionID);
  return list;
}
예제 #3
0
/**
 * @brief This file implements an interface to add a Factor to an opengm model in MatLab.
 *
 * This routine accepts a function id and a subset of variables and connects them to a new factor of the model.
 *
 * @param[in] nlhs number of output arguments expected from MatLab.
 * (needs to be 0).
 * @param[out] plhs pointer to the mxArrays containing the results.
 * @param[in] nrhs number of input arguments provided from MatLab.
 * (needs to be 3)
 * @param[in] prhs pointer to the mxArrays containing the input data provided by
 * matlab. prhs[0] needs to contain the handle for the model.
 * prhs[1] needs to contain the function id. prhs[2] needs to contain a matrix where every column represents a subset of variables.
 */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  //check if data is in correct format
  if(nrhs != 3) {
     mexErrMsgTxt("Wrong number of input variables specified (three needed)\n");
  }
  if(nlhs != 0) {
     mexErrMsgTxt("Wrong number of output variables specified (zero needed)\n");
  }

  // get model out of handle
  typedef opengm::interface::MatlabModelType::GmType GmType;
  GmType& gm = opengm::interface::handle<GmType>::getObject(prhs[0]);

  // get function id
  GmType::FunctionIdentifier::FunctionIndexType functionIndex;
  GmType::FunctionIdentifier::FunctionTypeIndexType functionType;

  if((mxIsUint8(prhs[1]) || mxIsUint16(prhs[1]) || mxIsUint32(prhs[1]) || mxIsUint64(prhs[1])) && (mxGetM(prhs[1]) == 1) && (mxGetN(prhs[1]) == 2)) {
     if(mxIsUint8(prhs[1])) {
        const uint8_T* data = static_cast<const uint8_T*>(mxGetData(prhs[1]));
        functionIndex = static_cast<GmType::FunctionIdentifier::FunctionIndexType>(data[0]);
        functionType = static_cast<GmType::FunctionIdentifier::FunctionTypeIndexType>(data[1]);
     } else if(mxIsUint16(prhs[1])) {
        const uint16_T* data = static_cast<const uint16_T*>(mxGetData(prhs[1]));
        functionIndex = static_cast<GmType::FunctionIdentifier::FunctionIndexType>(data[0]);
        functionType = static_cast<GmType::FunctionIdentifier::FunctionTypeIndexType>(data[1]);
     } else if(mxIsUint32(prhs[1])) {
        const uint32_T* data = static_cast<const uint32_T*>(mxGetData(prhs[1]));
        functionIndex = static_cast<GmType::FunctionIdentifier::FunctionIndexType>(data[0]);
        functionType = static_cast<GmType::FunctionIdentifier::FunctionTypeIndexType>(data[1]);
     } else if(mxIsUint64(prhs[1])) {
        const uint64_T* data = static_cast<const uint64_T*>(mxGetData(prhs[1]));
        functionIndex = static_cast<GmType::FunctionIdentifier::FunctionIndexType>(data[0]);
        functionType = static_cast<GmType::FunctionIdentifier::FunctionTypeIndexType>(data[1]);
     }
  } else {
     mexErrMsgTxt("Unsupported dataformat for function id!");
  }
  GmType::FunctionIdentifier functionID(functionIndex, functionType);

  // get subset of variables and add factor
  if(mxIsNumeric(prhs[2])) {
     if(mxGetNumberOfDimensions(prhs[2]) != 2) {
        mexErrMsgTxt("variables has to be a matrix where every column represents a subset of variables!");
     }
     size_t numFactors = mxGetN(prhs[2]);
     size_t numVariablesPerFactor = mxGetM(prhs[2]);
     typedef opengm::interface::helper::getDataFromMXArray<addFactorsFunctor> factorAdder;
     addFactorsFunctor functor(functionID, gm, numFactors, numVariablesPerFactor);
     factorAdder()(functor, prhs[2]);
  } else {
     mexErrMsgTxt("Unsupported dataformat for subset of variables!");
  }
}
예제 #4
0
std::vector<FunctionCallerID> Resource::actionsOnMe()
{
  //NEED TO ADD THE COLLECT ACTION IN HERE
  /*std::vector<FunctionCallerID> list;
  FunctionCaller coll = &makeAttack; 
  FunctionCallerID functionID(att, "Attack");
  list.push_back(functionID);
  return list;*/
  std::vector<FunctionCallerID> list = Entity::actionsOnMe();
  FunctionCaller ia = &makeInfoAction;
  FunctionCallerID functionID(ia, " Info ");
  list.push_back(functionID);  
  return list;
}
예제 #5
0
bool ShowFunction::saveXML(QXmlStreamWriter *doc) const
{
    Q_ASSERT(doc != NULL);

    /* Main tag */
    doc->writeStartElement(KXMLShowFunction);

    /* Attributes */
    doc->writeAttribute(KXMLShowFunctionID, QString::number(functionID()));
    doc->writeAttribute(KXMLShowFunctionStartTime, QString::number(startTime()));
    doc->writeAttribute(KXMLShowFunctionDuration, QString::number(duration()));
    if (color().isValid())
        doc->writeAttribute(KXMLShowFunctionColor, color().name());
    if (isLocked())
        doc->writeAttribute(KXMLShowFunctionLocked, QString::number(m_locked));

    doc->writeEndElement();

    return true;
}