mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 14:43:47 +00:00
put AIPlayer support back, and it as the default class to spawn
This commit is contained in:
parent
185acd23e0
commit
32d95d3b8b
5 changed files with 56 additions and 23 deletions
|
|
@ -227,15 +227,23 @@ void GuiNavEditorCtrl::spawnPlayer(const Point3F &pos)
|
|||
missionCleanup->addObject(obj);
|
||||
}
|
||||
mPlayer = obj;
|
||||
ShapeBase* sbo = dynamic_cast<ShapeBase*>(obj);
|
||||
if (sbo->getAIController())
|
||||
AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(obj);
|
||||
if (asAIPlayer) //try direct
|
||||
{
|
||||
if (sbo->getAIController()->mControllerData)
|
||||
Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
|
||||
Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con::executef(this, "onPlayerSelected");
|
||||
ShapeBase* sbo = dynamic_cast<ShapeBase*>(obj);
|
||||
if (sbo->getAIController())
|
||||
{
|
||||
if (sbo->getAIController()->mControllerData)
|
||||
Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con::executef(this, "onPlayerSelected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -398,25 +406,41 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
if(ri.object)
|
||||
{
|
||||
mPlayer = ri.object;
|
||||
ShapeBase* sbo = dynamic_cast<ShapeBase*>(ri.object);
|
||||
if (sbo->getAIController())
|
||||
AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
|
||||
if (asAIPlayer) //try direct
|
||||
{
|
||||
if (sbo->getAIController()->mControllerData)
|
||||
Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
|
||||
Con::executef(this, "onPlayerSelected", Con::getIntArg(asAIPlayer->mLinkTypes.getFlags()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con::executef(this, "onPlayerSelected");
|
||||
ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
|
||||
if (sbo->getAIController())
|
||||
{
|
||||
if (sbo->getAIController()->mControllerData)
|
||||
Con::executef(this, "onPlayerSelected", Con::getIntArg(sbo->getAIController()->mControllerData->mLinkTypes.getFlags()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con::executef(this, "onPlayerSelected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!mPlayer.isNull() && gServerContainer.castRay(startPnt, endPnt, StaticObjectType, &ri))
|
||||
{
|
||||
ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
|
||||
if (sbo->getAIController())
|
||||
AIPlayer* asAIPlayer = dynamic_cast<AIPlayer*>(mPlayer.getPointer());
|
||||
if (asAIPlayer) //try direct
|
||||
{
|
||||
if (sbo->getAIController()->mControllerData)
|
||||
sbo->getAIController()->getNav()->setPathDestination(ri.point,true);
|
||||
asAIPlayer->setPathDestination(ri.point);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShapeBase* sbo = dynamic_cast<ShapeBase*>(mPlayer.getPointer());
|
||||
if (sbo->getAIController())
|
||||
{
|
||||
if (sbo->getAIController()->mControllerData)
|
||||
sbo->getAIController()->getNav()->setPathDestination(ri.point, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,10 +172,10 @@ datablock LightAnimData( SpinLightAnim )
|
|||
|
||||
datablock AIPlayerControllerData( aiPlayerControl )
|
||||
{
|
||||
|
||||
moveTolerance = 0.25; followTolerance = 1.0; mAttackRadius = 2;
|
||||
};
|
||||
|
||||
datablock AIWheeledVehicleControllerData( aiCarControl )
|
||||
{
|
||||
|
||||
};
|
||||
moveTolerance = 1.0; followTolerance = 2.0; mAttackRadius = 5.0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
|
|||
VertSizing = "bottom";
|
||||
Extent = "90 18";
|
||||
text = "Stop";
|
||||
command = "NavEditorGui.getPlayer().stop();";
|
||||
command = "NavEditorGui.stop();";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function NavEditorPlugin::onWorldEditorStartup(%this)
|
|||
|
||||
// Add ourselves to the Editor Settings window.
|
||||
exec("./NavEditorSettingsTab.gui");
|
||||
//ESettingsWindow.addTabPage(ENavEditorSettingsPage);
|
||||
ESettingsWindow.addTabPage(ENavEditorSettingsPage);
|
||||
ENavEditorSettingsPage.init();
|
||||
|
||||
// Add items to World Editor Creator
|
||||
|
|
@ -241,7 +241,7 @@ function NavEditorPlugin::initSettings(%this)
|
|||
{
|
||||
EditorSettings.beginGroup("NavEditor", true);
|
||||
|
||||
EditorSettings.setDefaultValue("SpawnClass", "Player");
|
||||
EditorSettings.setDefaultValue("SpawnClass", "AIPlayer");
|
||||
EditorSettings.setDefaultValue("SpawnDatablock", "DefaultPlayerData");
|
||||
|
||||
EditorSettings.endGroup();
|
||||
|
|
|
|||
|
|
@ -459,13 +459,13 @@ function NavEditorGui::onLinkSelected(%this, %flags)
|
|||
|
||||
function NavEditorGui::onPlayerSelected(%this, %flags)
|
||||
{
|
||||
if (!isObject(%this.getPlayer().aiController))
|
||||
if (!isObject(%this.getPlayer().aiController) && (!(%this.getPlayer().isMemberOfClass("AIPlayer"))))
|
||||
{
|
||||
%this.getPlayer().aiController = new AIController(){ ControllerData = aiPlayerControl; };
|
||||
%this.getPlayer().setAIController(%this.getPlayer().aiController);
|
||||
NavMeshIgnore(%this.getPlayer(), true);
|
||||
%this.getPlayer().setDamageState("Enabled");
|
||||
}
|
||||
NavMeshIgnore(%this.getPlayer(), true);
|
||||
%this.getPlayer().setDamageState("Enabled");
|
||||
|
||||
updateLinkData(NavEditorOptionsWindow-->TestProperties, %flags);
|
||||
}
|
||||
|
|
@ -559,6 +559,15 @@ function NavEditorGui::followObject(%this)
|
|||
}
|
||||
}
|
||||
|
||||
function NavEditorGui::stop(%this)
|
||||
{
|
||||
if (isObject(%this.getPlayer().aiController))
|
||||
%this.getPlayer().aiController.stop();
|
||||
else
|
||||
{
|
||||
NavEditorGui.getPlayer().stop();
|
||||
}
|
||||
}
|
||||
function NavInspector::inspect(%this, %obj)
|
||||
{
|
||||
%name = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue