don't spool up new helper proxies if the goals are unchanged

This commit is contained in:
AzaezelX 2026-02-21 09:29:33 -06:00
parent 2dae0fbbad
commit 57890a4327
2 changed files with 45 additions and 6 deletions

View file

@ -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;
}

View file

@ -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;
}