本文整理汇总了C++中AddDeathDependence函数的典型用法代码示例。如果您正苦于以下问题:C++ AddDeathDependence函数的具体用法?C++ AddDeathDependence怎么用?C++ AddDeathDependence使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddDeathDependence函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CProjectile
CRepulseGfx::CRepulseGfx(CUnit* owner,CProjectile* repulsed,float maxDist,float3 color)
: CProjectile(repulsed?repulsed->pos:float3(0,0,0),repulsed?repulsed->speed:float3(0,0,0),owner, false),
repulsed(repulsed),
age(0),
sqMaxDist(maxDist*maxDist+100),
color(color)
{
if (owner)
AddDeathDependence(owner);
if (repulsed)
AddDeathDependence(repulsed);
checkCol=false;
useAirLos=true;
SetRadius(maxDist);
for(int y=0;y<5;++y){
float yp=(y/4.0f-0.5f);
for(int x=0;x<5;++x){
float xp=(x/4.0f-0.5f);
float d=sqrt(xp*xp+yp*yp);
difs[y*5+x]=(1-cos(d*2))*20;
}
}
}
示例2: CProjectile
CWeaponProjectile::CWeaponProjectile(const float3& pos,const float3& speed,CUnit* owner, CUnit* target,const float3 &targetPos, WeaponDef *weaponDef,CWeaponProjectile* interceptTarget) :
CProjectile(pos,speed,owner),
weaponDef(weaponDef),
target(target),
targetPos(targetPos),
startpos(pos),
targeted(false),
interceptTarget(interceptTarget)
{
if(target)
AddDeathDependence(target);
if(interceptTarget){
interceptTarget->targeted=true;
AddDeathDependence(interceptTarget);
}
if(weaponDef->interceptedByShieldType)
interceptHandler.AddShieldInterceptableProjectile(this);
if(!weaponDef->visuals.modelName.empty()){
S3DOModel* model = modelParser->Load3DO(string("objects3d/")+weaponDef->visuals.modelName,1,0);
if(model){
s3domodel=model;
if(s3domodel->rootobject3do)
modelDispList= model->rootobject3do->displist;
else
modelDispList= model->rootobjects3o->displist;
}
}
collisionFlags = weaponDef->collisionFlags;
}
示例3: Wait
CWaitCommandsAI::DeathWait::DeathWait(const Command& cmd)
: Wait(CMD_WAITCODE_DEATHWAIT)
{
GML_RECMUTEX_LOCK(sel); // DeathWait
const CUnitSet& selUnits = selectedUnits.selectedUnits;
if (cmd.params.size() == 1) {
const int unitID = (int)cmd.params[0];
if ((unitID < 0) || (static_cast<size_t>(unitID) >= uh->MaxUnits())) {
return;
}
CUnit* unit = uh->units[unitID];
if (unit == NULL) {
return;
}
if (selUnits.find(unit) != selUnits.end()) {
return;
}
deathUnits.insert(unit);
}
else if (cmd.params.size() == 6) {
const float3 pos0(cmd.params[0], cmd.params[1], cmd.params[2]);
const float3 pos1(cmd.params[3], cmd.params[4], cmd.params[5]);
CUnitSet tmpSet;
SelectAreaUnits(pos0, pos1, tmpSet, false);
CUnitSet::iterator it;
for (it = tmpSet.begin(); it != tmpSet.end(); ++it) {
if (selUnits.find(*it) == selUnits.end()) {
deathUnits.insert(*it);
}
}
if (deathUnits.empty()) {
return;
}
}
else {
return; // unknown param config
}
valid = true;
key = GetNewKey();
waitUnits = selUnits;
Command waitCmd(CMD_WAIT, cmd.options);
waitCmd.params.push_back(code);
waitCmd.params.push_back(GetFloatFromKey(key));
selectedUnits.GiveCommand(waitCmd);
CUnitSet::iterator it;
for (it = waitUnits.begin(); it != waitUnits.end(); ++it) {
AddDeathDependence((CObject*)(*it));
}
for (it = deathUnits.begin(); it != deathUnits.end(); ++it) {
AddDeathDependence((CObject*)(*it));
}
return;
}
示例4: DeleteDeathDependence
void CAirMoveType::CheckForCollision(void)
{
if (!collide) return;
SyncedFloat3& pos = owner->midPos;
SyncedFloat3& forward = owner->frontdir;
float3 midTestPos = pos + forward * 121;
std::vector<CUnit*> others = qf->GetUnitsExact(midTestPos, 115);
float dist = 200;
if (lastColWarning) {
DeleteDeathDependence(lastColWarning);
lastColWarning = 0;
lastColWarningType = 0;
}
for (std::vector<CUnit*>::iterator ui = others.begin(); ui != others.end(); ++ui) {
if (*ui == owner || !(*ui)->unitDef->canfly)
continue;
SyncedFloat3& op = (*ui)->midPos;
float3 dif = op - pos;
float3 forwardDif = forward * (forward.dot(dif));
if (forwardDif.SqLength() < dist * dist) {
float frontLength = forwardDif.Length();
float3 ortoDif = dif - forwardDif;
// note that the radii are multiplied by two since we rely on
// aircraft having half-size hitspheres (see unitloader)
//
// FIXME: with the new collision volumes, is this still true?
//
// yes: for backward compatibility, aircraft that do not define
// their own custom volumes get halved hitspheres by default
float minOrtoDif = ((*ui)->radius + owner->radius) * 2 + frontLength * 0.1f + 10;
if (ortoDif.SqLength() < minOrtoDif * minOrtoDif) {
dist = frontLength;
lastColWarning = (*ui);
}
}
}
if (lastColWarning) {
lastColWarningType = 2;
AddDeathDependence(lastColWarning);
return;
}
for (std::vector<CUnit*>::iterator ui = others.begin(); ui != others.end(); ++ui) {
if (*ui == owner)
continue;
if (((*ui)->midPos - pos).SqLength() < dist * dist) {
lastColWarning = *ui;
}
}
if (lastColWarning) {
lastColWarningType = 1;
AddDeathDependence(lastColWarning);
}
return;
}
示例5: DeleteDeathDependence
void CTAAirMoveType::CheckForCollision(void)
{
if (!collide) return;
SyncedFloat3& pos = owner->midPos;
SyncedFloat3 forward = owner->speed;
forward.Normalize();
float3 midTestPos = pos + forward * 121;
std::vector<CUnit*> others = qf->GetUnitsExact(midTestPos, 115);
float dist = 200;
if (lastColWarning) {
DeleteDeathDependence(lastColWarning);
lastColWarning = 0;
lastColWarningType = 0;
}
for (std::vector<CUnit*>::iterator ui = others.begin(); ui != others.end(); ++ui) {
if (*ui == owner || !(*ui)->unitDef->canfly)
continue;
SyncedFloat3& op = (*ui)->midPos;
float3 dif = op - pos;
float3 forwardDif = forward * (forward.dot(dif));
if (forwardDif.SqLength() < dist * dist) {
float frontLength = forwardDif.Length();
float3 ortoDif = dif - forwardDif;
// note: the radius is multiplied by two since we rely on aircraft
// having small spheres (see unitloader)
float minOrtoDif = ((*ui)->radius + owner->radius) * 2 + frontLength * 0.05f + 5;
if (ortoDif.SqLength() < minOrtoDif * minOrtoDif) {
dist = frontLength;
lastColWarning = (*ui);
}
}
}
if (lastColWarning) {
lastColWarningType = 2;
AddDeathDependence(lastColWarning);
return;
}
for (std::vector<CUnit*>::iterator ui = others.begin(); ui != others.end(); ++ui) {
if (*ui == owner)
continue;
if (((*ui)->midPos - pos).SqLength() < dist * dist) {
lastColWarning = *ui;
}
}
if (lastColWarning) {
lastColWarningType = 1;
AddDeathDependence(lastColWarning);
}
return;
}
示例6: CProjectile
CWeaponProjectile::CWeaponProjectile(const float3& pos, const float3& speed,
CUnit* owner, CUnit* target, const float3 &targetPos,
const WeaponDef* weaponDef, CWeaponProjectile* interceptTarget,
int ttl):
CProjectile(pos, speed, owner, true, true, false),
targeted(false),
weaponDef(weaponDef),
weaponDefName(weaponDef? weaponDef->name: std::string("")),
target(target),
targetPos(targetPos),
cegTag(weaponDef? weaponDef->cegTag: std::string("")),
cegID(-1U),
colorTeam(0),
startpos(pos),
ttl(ttl),
bounces(0),
keepBouncing(true),
interceptTarget(interceptTarget)
{
projectileType = WEAPON_BASE_PROJECTILE;
if (owner) {
colorTeam = owner->team;
}
if (target) {
AddDeathDependence(target, DEPENDENCE_WEAPONTARGET);
}
if (interceptTarget) {
interceptTarget->targeted = true;
AddDeathDependence(interceptTarget, DEPENDENCE_INTERCEPTTARGET);
}
assert(weaponDef != NULL);
alwaysVisible = weaponDef->visuals.alwaysVisible;
ignoreWater = weaponDef->waterweapon;
model = weaponDef->LoadModel();
collisionFlags = weaponDef->collisionFlags;
ph->AddProjectile(this);
ASSERT_SYNCED(id);
if (weaponDef->interceptedByShieldType) {
// this needs a valid projectile id set
assert(id >= 0);
interceptHandler.AddShieldInterceptableProjectile(this);
}
}
示例7: CProjectile
CWeaponProjectile::CWeaponProjectile(const float3& pos, const float3& speed,
CUnit* owner, CUnit* target, const float3 &targetPos,
const WeaponDef* weaponDef, CWeaponProjectile* interceptTarget,
bool synced, int ttl):
CProjectile(pos, speed, owner, synced, true),
weaponDef(weaponDef),
weaponDefName(weaponDef? weaponDef->name: std::string("")),
target(target),
targetPos(targetPos),
startpos(pos),
targeted(false),
interceptTarget(interceptTarget),
colorTeam(0),
bounces(0),
keepBouncing(true),
ttl(ttl),
cegTag(weaponDef? weaponDef->cegTag: std::string(""))
{
if (owner) {
colorTeam = owner->team;
}
if (target) {
AddDeathDependence(target);
}
if (interceptTarget) {
interceptTarget->targeted = true;
AddDeathDependence(interceptTarget);
}
if (weaponDef) {
if(weaponDef->interceptedByShieldType) {
interceptHandler.AddShieldInterceptableProjectile(this);
}
alwaysVisible = weaponDef->visuals.alwaysVisible;
if (!weaponDef->visuals.modelName.empty()) {
S3DOModel* model = modelParser->Load3DModel(string("objects3d/") + weaponDef->visuals.modelName, 1, colorTeam);
if (model) {
s3domodel = model;
if (s3domodel->rootobject3do)
modelDispList = model->rootobject3do->displist;
else
modelDispList = model->rootobjects3o->displist;
}
}
collisionFlags = weaponDef->collisionFlags;
}
}
示例8: targetPos
bool CWeapon::AttackUnit(CUnit *unit,bool userTarget)
{
if((!userTarget && weaponDef->noAutoTarget))
return false;
if(weaponDef->interceptor)
return false;
weaponPos=owner->pos+owner->frontdir*relWeaponPos.z+owner->updir*relWeaponPos.y+owner->rightdir*relWeaponPos.x;
if(weaponPos.y<ground->GetHeight2(weaponPos.x,weaponPos.z))
weaponPos=owner->pos+10; //hope that we are underground because we are a popup weapon and will come above ground later
if(!unit) {
if(targetType!=Target_Unit) //make the unit be more likely to keep the current target if user start to move it
targetType=Target_None;
haveUserTarget=false;
return false;
}
float3 targetPos(helper->GetUnitErrorPos(unit,owner->allyteam));
targetPos+=errorVector*(weaponDef->targetMoveError*30*unit->speed.Length()*(1.0-owner->limExperience));
if(!TryTarget(targetPos,userTarget,unit))
return false;
if(targetUnit) {
DeleteDeathDependence(targetUnit);
targetUnit=0;
}
haveUserTarget=userTarget;
targetType=Target_Unit;
targetUnit=unit;
targetPos=unit->midPos+float3(0,0.3,0)*unit->radius;
AddDeathDependence(targetUnit);
return true;
}
示例9: DetachUnit
void CTransportUnit::AttachUnit(CUnit* unit, int piece)
{
DetachUnit(unit);
if(unit->inTransport)
return;
AddDeathDependence(unit);
unit->inTransport=true;
unit->toBeTransported=false;
if (unit->unitDef->stunnedCargo)
unit->stunned=true; //make sure unit doesnt fire etc in transport
unit->UnBlock();
if(CTAAirMoveType* am=dynamic_cast<CTAAirMoveType*>(moveType))
unit->moveType->useHeading=false;
TransportedUnit tu;
tu.unit=unit;
tu.piece=piece;
tu.size=unit->xsize/2;
tu.mass=unit->mass;
transportCapacityUsed+=tu.size;
transportMassUsed+=tu.mass;
transported.push_back(tu);
unit->CalculateTerrainType();
unit->UpdateTerrainType();
}
示例10: max
void CAirMoveType::SlowUpdate(void)
{
if(aircraftState!=AIRCRAFT_LANDED && owner->unitDef->maxFuel>0)
owner->currentFuel = max (0.f, owner->currentFuel - (16.f/GAME_SPEED));
if(!reservedPad && aircraftState==AIRCRAFT_FLYING && owner->health<owner->maxHealth*repairBelowHealth){
CAirBaseHandler::LandingPad* lp=airBaseHandler->FindAirBase(owner,8000,owner->unitDef->minAirBasePower);
if(lp){
AddDeathDependence(lp);
reservedPad=lp;
padStatus=0;
oldGoalPos=goalPos;
}
}
if(owner->pos!=oldSlowUpdatePos){
oldSlowUpdatePos=owner->pos;
int newmapSquare=ground->GetSquare(owner->pos);
if(newmapSquare!=owner->mapSquare){
owner->mapSquare=newmapSquare;
float oldlh=owner->losHeight;
float h=owner->pos.y-ground->GetApproximateHeight(owner->pos.x,owner->pos.z);
owner->losHeight=h+5;
loshandler->MoveUnit(owner,false);
if(owner->hasRadarCapacity)
radarhandler->MoveUnit(owner);
owner->losHeight=oldlh;
}
qf->MovedUnit(owner);
owner->isUnderWater=owner->pos.y+owner->model->height<0;
}
}
示例11: AddDeathDependence
void CAirMoveType::SlowUpdate(void)
{
if(!reservedPad && aircraftState==AIRCRAFT_FLYING && owner->health<owner->maxHealth*repairBelowHealth){
CAirBaseHandler::LandingPad* lp=airBaseHandler->FindAirBase(owner,8000);
if(lp){
AddDeathDependence(lp);
reservedPad=lp;
padStatus=0;
oldGoalPos=goalPos;
}
}
if(owner->pos!=oldSlowUpdatePos){
oldSlowUpdatePos=owner->pos;
int newmapSquare=ground->GetSquare(owner->pos);
if(newmapSquare!=owner->mapSquare){
owner->mapSquare=newmapSquare;
float oldlh=owner->losHeight;
float h=owner->pos.y-ground->GetApproximateHeight(owner->pos.x,owner->pos.z);
owner->losHeight=h+5;
loshandler->MoveUnit(owner,false);
if(owner->radarRadius || owner->jammerRadius || owner->sonarRadius)
radarhandler->MoveUnit(owner);
owner->losHeight=oldlh;
}
qf->MovedUnit(owner);
owner->isUnderWater=owner->pos.y+owner->model->height<0;
}
}
示例12: CalcBuildPos
void CFactory::StartBuild(const UnitDef* buildeeDef) {
const float3& buildPos = CalcBuildPos();
const bool blocked = groundBlockingObjectMap->GroundBlocked(buildPos, this);
// wait until buildPos is no longer blocked (eg. by a previous buildee)
//
// it might rarely be the case that a unit got stuck inside the factory
// or died right after completion and left some wreckage, but that is up
// to players to fix (we no longer broadcast BuggerOff directives, since
// those are indiscriminate and ineffective)
if (blocked)
return;
CUnit* b = unitLoader->LoadUnit(buildeeDef, buildPos, team, true, buildFacing, this);
if (!unitDef->canBeAssisted) {
b->soloBuilder = this;
b->AddDeathDependence(this, DEPENDENCE_BUILDER);
}
AddDeathDependence(b, DEPENDENCE_BUILD);
script->StartBuilding();
// set curBuildDef to NULL to indicate construction
// has started, otherwise we would keep being called
curBuild = b;
curBuildDef = NULL;
#if (PLAY_SOUNDS == 1)
if (losStatus[gu->myAllyTeam] & LOS_INLOS) {
Channels::General.PlayRandomSample(unitDef->sounds.build, buildPos);
}
#endif
}
示例13: SetRepairTarget
void RepairTask::SetRepairTarget (aiUnit *u)
{
if (target) DeleteDeathDependence (target);
target = u;
if (u) AddDeathDependence (u);
}
示例14: AddDeathDependence
void CSelectedUnits::AddUnit(CUnit* unit)
{
// if unit is being transported by eg. Hulk or Atlas
// then we should not be able to select it
if (unit->transporter != NULL && !unit->transporter->unitDef->isFirePlatform) {
return;
}
if (unit->noSelect) {
return;
}
selectedUnits.insert(unit);
AddDeathDependence(unit);
selectionChanged = true;
possibleCommandsChanged = true;
if (!(unit->group) || unit->group->id != selectedGroup)
selectedGroup = -1;
PUSH_CODE_MODE;
ENTER_MIXED;
unit->commandAI->selected = true;
POP_CODE_MODE;
}
示例15: DetachUnit
void CTransportUnit::AttachUnit(CUnit* unit, int piece)
{
DetachUnit(unit);
if (!CanTransport(unit))
return;
AddDeathDependence(unit);
unit->AddDeathDependence (this);
unit->transporter = this;
unit->toBeTransported=false;
if (!unitDef->isfireplatform) {
unit->stunned=true; //make sure unit doesnt fire etc in transport
selectedUnits.RemoveUnit(unit);
}
unit->UnBlock();
loshandler->FreeInstance(unit->los);
unit->los=0;
if (dynamic_cast<CTAAirMoveType*>(moveType)) {
unit->moveType->useHeading=false;
}
TransportedUnit tu;
tu.unit=unit;
tu.piece=piece;
tu.size=unit->xsize/2;
tu.mass=unit->mass;
transportCapacityUsed+=tu.size;
transportMassUsed+=tu.mass;
transported.push_back(tu);
unit->CalculateTerrainType();
unit->UpdateTerrainType();
luaCallIns.UnitLoaded(unit, this);
}