本文整理汇总了C++中UnitObj::GetTeam方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitObj::GetTeam方法的具体用法?C++ UnitObj::GetTeam怎么用?C++ UnitObj::GetTeam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitObj
的用法示例。
在下文中一共展示了UnitObj::GetTeam方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AssignConstructors
//
// Assign constructors to this base
//
void Base::AssignConstructors(const char *tagName)
{
processTokens = TRUE;
// Was a tag specified ?
if (tagName)
{
// Resolve the tag
TagObj *tag = TagObj::FindTag(tagName);
if (tag)
{
// Iterate the units in the tag
for (MapObjList::Iterator i(&tag->list); *i; i++)
{
// Is it alive
if (!(*i)->Alive())
{
continue;
}
// Is this a unit ?
UnitObj *unit = Promote::Object<UnitObjType, UnitObj>(**i);
if (!unit)
{
continue;
}
// Is it on our team ?
if (unit->GetTeam() != GetObject().GetTeam())
{
continue;
}
// Is it a constructor ?
if (!unit->HasProperty(0xDCDE71CD)) // "Ability::Construction"
{
continue;
}
// LOG_AI(("Assigning constructor [%d] '%s' to base '%s'", unit->Id(), unit->UnitType()->GetName(), GetName()))
// Add this constructor to the list of idle constructors
constructorsIdle.Append(unit);
}
}
else
{
ERR_CONFIG(("Could not find tag '%s' when assign constructors to base '%s'", tagName, GetName()))
}
}
else
{
// Iterate all of the units on this team
for (NList<UnitObj>::Iterator u(&GetObject().GetTeam()->GetUnitObjects()); *u; u++)
示例2: object
//
// Data constructor
//
Objects::Data::Data(MapObj *o) : object(o)
{
type = object->MapType();
matrix = object->WorldMatrix();
zipped = object->GetFootInstance() ? TRUE : FALSE;
UnitObj *unit = Promote::Object<UnitObjType, UnitObj>(object);
if (unit)
{
team = unit->GetTeam();
}
}
示例3: Execute
//
// Execute
//
U32 SelfDestruct::Execute(const U8 *, Player &player)
{
// Tell each object to SelfDestruct
for (UnitObjList::Iterator i(&player.GetSelectedList()); *i; i++)
{
// Get the unit
UnitObj *unit = **i;
// Ensure it can self destruct
if (unit->HasProperty(0x54D4152A) && !unit->UnderConstruction()) // "Ability::SelfDestruct"
{
unit->SelfDestruct(TRUE, unit->GetTeam());
}
}
return (sizeof (Data));
}
示例4: StateRecycle
//
// Recycle
//
// Check timer and refund resources once recycled
//
void UnitRecycle::StateRecycle()
{
// Apply progress
progressTotal -= progressMax;
// Has recycling finished
if (progressTotal <= 0.0F)
{
// Refund the resources
if (subject->GetTeam() && refund > 0)
{
// Calculate the total refund
U32 totalRefund = U32(subject->UnitType()->GetRecyclePercentage() * refund);
// Add to the team
subject->GetTeam()->AddResourceStore(totalRefund);
// Report the resource type
subject->GetTeam()->ReportResource(totalRefund, "resource.recycled");
// Generate a message
if (Team::GetDisplayTeam() == subject->GetTeam())
{
CON_MSG((TRANSLATE(("#game.messages.recyclerefund", 2, subject->GetUpgradedUnit().GetDesc(), totalRefund))));
}
}
// Trigger finish FX
subject->StartGenericFX(0x2062BAAD, NULL, TRUE); // "Recycle::Finish"
// Did this building consume its constructor
if
(
subject->UnitType()->GetConstructorType() &&
!subject->UnitType()->GetConstructorType()->GetIsFacility() &&
subject->UnitType()->GetConstructorConsume()
)
{
// Ensure the constructors resources are initialized
subject->UnitType()->GetConstructorType()->InitializeResources();
// Create a fresh new constructor
UnitObj *unit = subject->UnitType()->GetConstructorType()->SpawnClosest
(
subject->Position(), subject->GetTeam()
);
// If this team is controlled by AI then assign the
// constructor to the primary base (if there is one)
if (unit && unit->GetTeam() && unit->GetTeam()->IsAI())
{
Strategic::Object *object = unit->GetTeam()->GetStrategicObject();
if (object)
{
Strategic::Base *base = object->GetBaseManager().GetPrimaryBase();
if (base)
{
base->AddUnit(unit);
base->AddConstructor(unit);
}
}
}
}
// Remove the object
subject->MarkForDeletion();
// Remove boarded object
if (subject->UnitType()->CanBoard() && subject->GetBoardManager()->InUse())
{
subject->GetBoardManager()->GetUnitObj()->SelfDestruct();
}
// Recycle completed
Quit();
}
}
示例5: Poll
//
// Poll
//
// Attempt to trigger this trap
//
Bool TrapObj::Poll()
{
// Did we find a valid target
Bool valid = FALSE;
// Has recharging finished
if (recharge.Test())
{
UnitObj *target;
// Find an enemy within the configured range
UnitObjIter::Tactical i
(
NULL, UnitObjIter::FilterData(GetTeam(), Relation::ENEMY, Position(), TrapType()->GetDistance())
);
// Step through each possible target
while ((target = i.Next()) != NULL)
{
// Can this trap trigger on this target
if (TrapType()->Test(target))
{
// Does this trap self destruct
if (TrapType()->GetSelfDestruct())
{
SelfDestruct(TRUE, GetTeam());
valid = TRUE;
}
// Does this trap attach a parasite
if (TrapType()->GetParasite() && TrapType()->GetParasite()->Infect(target, GetTeam()))
{
valid = TRUE;
}
// Should we fire a weapon
if (TrapType()->GetWeaponSpeed() > 0.0F)
{
if (GetWeapon())
{
Vector pos = Origin();
pos.y += 20.0f;
GetWeapon()->SetTarget(Target(pos));
valid = TRUE;
}
else
{
LOG_WARN(("Trap %s configured to fire a weapon, but has none!", TypeName()));
}
}
if (valid)
{
// Signal team radio that we were triggered
if (GetTeam())
{
// "Trap::Triggered"
GetTeam()->GetRadio().Trigger(0xA0FF29A5, Radio::Event(this));
}
// Signal the target that it has been trapped
if (target->GetTeam())
{
// "Trap::Triggered::Target"
target->GetTeam()->GetRadio().Trigger(0x3070E869, Radio::Event(target));
}
// Start charge time
recharge.Start(TrapType()->GetChargeTime());
}
// Only affect one target for now
break;
}
}
}
return (valid);
}