mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 04:50:31 +00:00
Merge pull request #1671 from Azaezel/alpha41/forgetMeNot
don't spool up new helper proxies if the goals are unchanged
This commit is contained in:
commit
26638a95c5
3 changed files with 63 additions and 8 deletions
|
|
@ -194,7 +194,9 @@ DefineEngineMethod(AIController, getAimObject, S32, (), ,
|
|||
|
||||
"@see setAimObject()\n")
|
||||
{
|
||||
SceneObject* obj = dynamic_cast<GameBase*>(object->getAim()->mObj.getPointer());
|
||||
SceneObject* obj = NULL;
|
||||
if (object->getAim())
|
||||
obj = dynamic_cast<GameBase*>(object->getAim()->mObj.getPointer());
|
||||
return obj ? obj->getId() : -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,12 @@ bool AIController::setControllerDataProperty(void* obj, const char* index, const
|
|||
|
||||
void AIController::setGoal(AIInfo* targ)
|
||||
{
|
||||
if (mGoal) { delete(mGoal); mGoal = NULL; }
|
||||
if (mGoal)
|
||||
{
|
||||
if (mGoal->mObj.isValid() && targ->mObj.isValid() && mGoal->mObj == targ->mObj)
|
||||
return;
|
||||
delete(mGoal); mGoal = NULL;
|
||||
}
|
||||
|
||||
if (targ->mObj.isValid())
|
||||
{
|
||||
|
|
@ -86,26 +91,58 @@ void AIController::setGoal(AIInfo* targ)
|
|||
|
||||
void AIController::setGoal(Point3F loc, F32 rad)
|
||||
{
|
||||
if (mGoal) delete(mGoal);
|
||||
if (mGoal)
|
||||
{
|
||||
if (mGoal->mPosSet && mGoal->getPosition() == loc)
|
||||
{
|
||||
mGoal->mRadius = rad;
|
||||
return;
|
||||
}
|
||||
delete(mGoal);
|
||||
}
|
||||
mGoal = new AIGoal(this, loc, rad);
|
||||
}
|
||||
|
||||
void AIController::setGoal(SimObjectPtr<SceneObject> objIn, F32 rad)
|
||||
{
|
||||
if (mGoal) delete(mGoal);
|
||||
if (mGoal)
|
||||
{
|
||||
if (mGoal->mObj.isValid() && objIn.isValid() && mGoal->mObj == objIn)
|
||||
{
|
||||
mGoal->mRadius = rad;
|
||||
return;
|
||||
}
|
||||
delete(mGoal);
|
||||
}
|
||||
mGoal = new AIGoal(this, objIn, rad);
|
||||
}
|
||||
|
||||
void AIController::setAim(Point3F loc, F32 rad, Point3F offset)
|
||||
{
|
||||
if (mAimTarget) delete(mAimTarget);
|
||||
if (mAimTarget)
|
||||
{
|
||||
if (mAimTarget->mPosSet && mAimTarget->getPosition() == loc)
|
||||
{
|
||||
mAimTarget->mAimOffset = offset;
|
||||
return;
|
||||
}
|
||||
delete(mAimTarget);
|
||||
}
|
||||
mAimTarget = new AIAimTarget(this, loc, rad);
|
||||
mAimTarget->mAimOffset = offset;
|
||||
}
|
||||
|
||||
void AIController::setAim(SimObjectPtr<SceneObject> objIn, F32 rad, Point3F offset)
|
||||
{
|
||||
if (mAimTarget) delete(mAimTarget);
|
||||
if (mAimTarget)
|
||||
{
|
||||
if (mAimTarget->mObj.isValid() && objIn.isValid() && mAimTarget->mObj == objIn)
|
||||
{
|
||||
mAimTarget->mAimOffset = offset;
|
||||
return;
|
||||
}
|
||||
delete(mAimTarget);
|
||||
}
|
||||
mAimTarget = new AIAimTarget(this, objIn, rad);
|
||||
mAimTarget->mAimOffset = offset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,8 +70,24 @@ public:
|
|||
private:
|
||||
AICover* mCover;
|
||||
public:
|
||||
void setCover(Point3F loc, F32 rad = 0.0f) { delete(mCover); mCover = new AICover(this, loc, rad); }
|
||||
void setCover(SimObjectPtr<SceneObject> objIn, F32 rad = 0.0f) { delete(mCover); mCover = new AICover(this, objIn, rad); }
|
||||
void setCover(Point3F loc, F32 rad = 0.0f)
|
||||
{
|
||||
if (mCover && mCover->mPosSet && mCover->getPosition() == loc)
|
||||
{
|
||||
mCover->mRadius == rad;
|
||||
return;
|
||||
}
|
||||
delete(mCover); mCover = new AICover(this, loc, rad);
|
||||
}
|
||||
void setCover(SimObjectPtr<SceneObject> objIn, F32 rad = 0.0f)
|
||||
{
|
||||
if (mCover && mCover->mObj == objIn)
|
||||
{
|
||||
mCover->mRadius == rad;
|
||||
return;
|
||||
}
|
||||
delete(mCover); mCover = new AICover(this, objIn, rad);
|
||||
}
|
||||
AICover* getCover() { return mCover; }
|
||||
bool findCover(const Point3F& from, F32 radius);
|
||||
void clearCover();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue