本文整理汇总了C++中UnitObj::CanEverMove方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitObj::CanEverMove方法的具体用法?C++ UnitObj::CanEverMove怎么用?C++ UnitObj::CanEverMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitObj
的用法示例。
在下文中一共展示了UnitObj::CanEverMove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
//
// Execute
//
U32 Turn::Execute(const U8 *data, Player &player)
{
const Data *d = (Data *) data;
// Send the move order to all of the selected objects
for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
{
UnitObj *unit = **i;
// Calculate desired front vector
Vector v(d->x - unit->Position().x, 0, d->z - unit->Position().z);
v.Normalize();
// Can the unit move
if (unit->CanEverMove())
{
if (!unit->GetDriver()->IsBoarded())
{
// Convert the given task Id into a move type
Tasks::UnitMove *task = new Tasks::UnitMove(unit);
task->SetDir(v);
IssueTask(d->mod, unit, task, player);
}
}
}
return (sizeof (Data));
}
示例2: StateInit
//
// Initial state
//
void MapDeath::StateInit()
{
// Stop the objects driver
UnitObj *unitObj = Promote::Object<UnitObjType, UnitObj>(subject);
if (unitObj)
{
if (unitObj->GetWeapon())
{
unitObj->GetWeapon()->HaltFire();
}
if (unitObj->CanEverMove())
{
unitObj->GetDriver()->Stop(Movement::Driver::STOP_DYING);
}
}
// Play the death animation
subject->SetAnimation(0xF40D135F); // "Death"
NextState(0x382D3C63); // "Dead"
}
示例3: 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;
}
}
}
示例4: StateInit
//
// StateInit
//
void SquadBoard::StateInit()
{
// Get each of the units in the squad to board transports
SquadObj::UnitList::Iterator u(&subject->GetList());
// We could enhance this to use units which are closest to transports etc.
// Clear the squad's completed flags
for (!u; *u; u++)
{
(*u)->completed = FALSE;
(*u)->task = 0;
}
// Reset squad iterator
!u;
for (TransportObjList::Iterator t(&transports); *t; t++)
{
if ((*t)->Alive())
{
TransportObj *transport = **t;
U32 slots = transport->TransportType()->GetSpaces();
U32 added = 0;
while (slots--)
{
UnitObjPtr *unitPtr = *u;
if (unitPtr)
{
ASSERT(unitPtr->Alive())
UnitObj *unit = *unitPtr;
if (unit->CanEverMove())
{
// Tell the unit to board
unit->FlushTasks(Tasks::UnitBoard::GetConfigBlockingPriority());
Task *task;
// Is this a telepad
if (TaskCtrl::PromoteIdle<Tasks::TransportPad>(transport))
{
unit->PrependTask(task = new Tasks::UnitMove(unit, transport), GetFlags());
}
else
{
unit->PrependTask(task = new Tasks::UnitBoard(unit, transport), GetFlags());
}
(*u)->task = task->GetTaskId();
added++;
}
else
{
// This unit can't move so complete it
(*u)->completed = TRUE;
}
}
else
{
break;
}
// Increment iterator
u++;
}
if (!added)
{
// No units were added
break;
}
}
}
// Complete those units which missed out
for (; *u; u++)
{
(*u)->completed = TRUE;
}
NextState(0x09E5F977); // "Boarding"
}