mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
hook up Vehicle's getAIMove(Move*);
list aiControllerData's in the datablock. though the command is still required to set the controler and look up the relevant db for game specific logic
This commit is contained in:
parent
2d0bcbcf8d
commit
712404c9b4
|
|
@ -31,6 +31,7 @@ IMPLEMENT_CONOBJECT(AIController);
|
|||
//-----------------------------------------------------------------------------
|
||||
void AIController::throwCallback(const char* name)
|
||||
{
|
||||
Con::warnf("throwCallback: %s", name);
|
||||
Con::executef(mControllerData, name, getIdString()); //controller data callbacks
|
||||
|
||||
GameBase* gbo = dynamic_cast<GameBase*>(getAIInfo()->mObj.getPointer());
|
||||
|
|
@ -676,7 +677,6 @@ F32 AIWheeledVehicleControllerData::getSteeringAngle(AIController* obj, Point3F
|
|||
maxSteeringAngle = vd->maxSteeringAngle;
|
||||
|
||||
Point2F steering = wvo->getSteering();
|
||||
|
||||
if (finalYaw < 5 && steering.x != 0.0f)
|
||||
steerState = Straight;
|
||||
else if (finalYaw < 5)
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ PlayerData::PlayerData()
|
|||
|
||||
physicsPlayerType = StringTable->EmptyString();
|
||||
mControlMap = StringTable->EmptyString();
|
||||
|
||||
mAIControllData = NULL;
|
||||
dMemset( actionList, 0, sizeof(actionList) );
|
||||
}
|
||||
|
||||
|
|
@ -740,8 +740,10 @@ void PlayerData::initPersistFields()
|
|||
endGroup( "Camera" );
|
||||
|
||||
addGroup( "Movement" );
|
||||
addField("controlMap", TypeString, Offset(mControlMap, PlayerData),
|
||||
addField("controlMap", TypeString, Offset(mControlMap, PlayerData),
|
||||
"@brief movemap used by these types of objects.\n\n");
|
||||
addField("aiControllerData", TYPEID< AIControllerData >(), Offset(mAIControllData, PlayerData),
|
||||
"@brief ai controller used by these types of objects.\n\n");
|
||||
|
||||
addFieldV( "maxStepHeight", TypeRangedF32, Offset(maxStepHeight, PlayerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Maximum height the player can step up.\n\n"
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ VehicleData::VehicleData()
|
|||
collDamageThresholdVel = 20;
|
||||
collDamageMultiplier = 0.05f;
|
||||
enablePhysicsRep = true;
|
||||
mAIControllData = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -320,6 +321,13 @@ void VehicleData::initPersistFields()
|
|||
"velocity).\n\nCurrently unused." );
|
||||
endGroup("Collision");
|
||||
|
||||
addGroup("Movement");
|
||||
addField("controlMap", TypeString, Offset(mControlMap, VehicleData),
|
||||
"@brief movemap used by these types of objects.\n\n");
|
||||
addField("aiControllerData", TYPEID< AIControllerData >(), Offset(mAIControllData, VehicleData),
|
||||
"@brief ai controller used by these types of objects.\n\n");
|
||||
endGroup("Collision");
|
||||
|
||||
addGroup("Steering");
|
||||
addFieldV( "jetForce", TypeRangedF32, Offset(jetForce, VehicleData), &CommonValidators::PositiveFloat,
|
||||
"@brief Additional force applied to the vehicle when it is jetting.\n\n"
|
||||
|
|
@ -501,6 +509,12 @@ void Vehicle::processTick(const Move* move)
|
|||
if ( isMounted() )
|
||||
return;
|
||||
|
||||
// If we're not being controlled by a client, let the
|
||||
// AI sub-module get a chance at producing a move.
|
||||
Move aiMove;
|
||||
if (!move && isServerObject() && getAIMove(&aiMove))
|
||||
move = &aiMove;
|
||||
|
||||
// Warp to catch up to server
|
||||
if (mDelta.warpCount < mDelta.warpTicks)
|
||||
{
|
||||
|
|
@ -1233,6 +1247,17 @@ bool Vehicle::setAIController(SimObjectId controller)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Vehicle::getAIMove(Move* move)
|
||||
{
|
||||
if (mAIController)
|
||||
{
|
||||
mAIController->getAIMove(move); //actual result
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DefineEngineMethod(Vehicle, setAIController, bool, (S32 controller), , "")
|
||||
{
|
||||
return object->setAIController(controller);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ struct VehicleData : public RigidShapeData
|
|||
F32 numDmgEmitterAreas;
|
||||
|
||||
bool enablePhysicsRep;
|
||||
StringTableEntry mControlMap;
|
||||
AIControllerData* mAIControllData;
|
||||
|
||||
//
|
||||
VehicleData();
|
||||
|
|
@ -152,6 +154,8 @@ public:
|
|||
F32 getThrottle() { return mThrottle;};
|
||||
bool setAIController(SimObjectId controller);
|
||||
AIController* getAIController() { return mAIController; };
|
||||
virtual bool getAIMove(Move*);
|
||||
|
||||
/// Interpolates between move ticks @see processTick
|
||||
/// @param dt Change in time between the last call and this call to the function
|
||||
void advanceTime(F32 dt) override;
|
||||
|
|
|
|||
Loading…
Reference in a new issue