当前位置: 首页>>代码示例>>C++>>正文


C++ UnitObj::SetTeam方法代码示例

本文整理汇总了C++中UnitObj::SetTeam方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitObj::SetTeam方法的具体用法?C++ UnitObj::SetTeam怎么用?C++ UnitObj::SetTeam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitObj的用法示例。


在下文中一共展示了UnitObj::SetTeam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Undo

    //
    // Undo
    //
    // Undo operation
    //
    void Objects::Undo()
    {
      // Process each object
      for (NList<Data>::Iterator i(&dataList); *i; i++)
      {
        Data *d = *i;

        switch (op)
        {
          // Delete objects that were created
          case OP_CREATE:
            if (d->object.Alive())
            {
              GameObjCtrl::MarkForDeletion(d->object);
            }
            break;

          // Create objects that were deleted
          case OP_DELETE:
          {
            MapObj *m = MapObjCtrl::ObjectNewOnMap(d->type, d->matrix, 0, d->zipped);

            // Restore zipping
            if (d->zipped)
            {
              m->ToggleFootPrint(TRUE);
            }
  
            // Is this a unit
            UnitObj *u = Promote::Object<UnitObjType, UnitObj>(m);

            // Restore correct team
            if (u && d->team)
            {
              u->SetTeam(d->team);
            }

            // Save the old id
            U32 oldId = d->object.DirectId();

            // Now replace all references to the old object with the new object
            for (NList<Base>::Iterator items(&GetHistoryList()); *items; items++)
            {
              Objects *item = Promote<Objects>(*items);

              if (item)
              {
                for (NList<Data>::Iterator data(&item->dataList); *data; data++)
                {
                  if ((*data)->object.DirectId() == oldId)
                  {
                    (*data)->object = m;
                  }
                }
              }
            }

            break;
          }

          // Move objects back to original location
          case OP_MOVE:
            if (d->object.Alive())
            {
              d->object->SetSimCurrent(d->matrix);

              // Toggle claiming if necessary
              UnitObj *unitObj = Promote::Object<UnitObjType, UnitObj>(d->object);

              if (unitObj && unitObj->CanEverMove())
              {
                unitObj->GetDriver()->RemoveFromMapHook();
                unitObj->GetDriver()->AddToMapHook();
              }
            }
            break;

          // Restore zipped state
          case OP_ZIP:
            if (d->object.Alive())
            {
              d->object->ToggleFootPrint(d->zipped);
            }
            break;
        }
      }
    }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:92,代码来源:studio_history_objects.cpp


注:本文中的UnitObj::SetTeam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。