Eliminate unnecessary uses of ConsoleMethod

This commit is contained in:
Lukas Joergensen 2018-04-17 22:36:32 +02:00
parent 2bbc716db6
commit 0fff33869c
15 changed files with 155 additions and 190 deletions

View file

@ -1823,12 +1823,11 @@ ConsoleMethod(Entity, addComponents, void, 2, 2, "() - Add all fielded behaviors
object->addComponents();
}*/
ConsoleMethod(Entity, addComponent, bool, 3, 3, "(ComponentInstance bi) - Add a behavior to the object\n"
DefineEngineMethod(Entity, addComponent, bool, (Component* comp),,
"@brief Add a behavior to the object\n"
"@param bi The behavior instance to add"
"@return (bool success) Whether or not the behavior was successfully added")
{
Component *comp = dynamic_cast<Component *>(Sim::findObject(argv[2]));
if (comp != NULL)
{
bool success = object->addComponent(comp);
@ -1848,40 +1847,33 @@ ConsoleMethod(Entity, addComponent, bool, 3, 3, "(ComponentInstance bi) - Add a
return false;
}
ConsoleMethod(Entity, removeComponent, bool, 3, 4, "(ComponentInstance bi, [bool deleteBehavior = true])\n"
DefineEngineMethod(Entity, removeComponent, bool, (Component* comp, bool deleteComponent), (true),
"@param bi The behavior instance to remove\n"
"@param deleteBehavior Whether or not to delete the behavior\n"
"@return (bool success) Whether the behavior was successfully removed")
{
bool deleteComponent = true;
if (argc > 3)
deleteComponent = dAtob(argv[3]);
return object->removeComponent(dynamic_cast<Component *>(Sim::findObject(argv[2])), deleteComponent);
return object->removeComponent(comp, deleteComponent);
}
ConsoleMethod(Entity, clearComponents, void, 2, 2, "() - Clear all behavior instances\n"
DefineEngineMethod(Entity, clearComponents, void, (),, "Clear all behavior instances\n"
"@return No return value")
{
object->clearComponents();
}
ConsoleMethod(Entity, getComponentByIndex, S32, 3, 3, "(int index) - Gets a particular behavior\n"
DefineEngineMethod(Entity, getComponentByIndex, Component*, (S32 index),,
"@brief Gets a particular behavior\n"
"@param index The index of the behavior to get\n"
"@return (ComponentInstance bi) The behavior instance you requested")
{
Component *comp = object->getComponent(dAtoi(argv[2]));
return (comp != NULL) ? comp->getId() : 0;
return object->getComponent(index);
}
DefineEngineMethod(Entity, getComponent, S32, (String componentName), (""),
DefineEngineMethod(Entity, getComponent, Component*, (String componentName), (""),
"Get the number of static fields on the object.\n"
"@return The number of static fields defined on the object.")
{
Component *comp = object->getComponent(componentName);
return (comp != NULL) ? comp->getId() : 0;
return object->getComponent(componentName);
}
/*ConsoleMethod(Entity, getBehaviorByType, S32, 3, 3, "(string BehaviorTemplateName) - gets a behavior\n"
@ -1910,7 +1902,8 @@ DefineEngineMethod(Entity, getComponent, S32, (String componentName), (""),
return object->reOrder(inst, idx);
}*/
ConsoleMethod(Entity, getComponentCount, S32, 2, 2, "() - Get the count of behaviors on an object\n"
DefineEngineMethod(Entity, getComponentCount, S32, (),,
"@brief Get the count of behaviors on an object\n"
"@return (int count) The number of behaviors on an object")
{
return object->getComponentCount();