2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Updates to the Python API

Throw away some stupid stuff and make things slightly easier to use...
This commit is contained in:
2012-05-07 23:17:46 -04:00
parent 3b69a4aee3
commit 5cf540b424
7 changed files with 34 additions and 49 deletions

View File

@ -2868,14 +2868,7 @@ PyObject* cyMisc::GetAIAvatarsByModelName(const char* name)
Py_DECREF(tuple);
}
}
if (PyList_Size(avList) > 0)
return avList;
else
{
Py_DECREF(avList);
PYTHON_RETURN_NONE;
}
return avList;
}
void cyMisc::ForceVaultNodeUpdate(unsigned nodeId)

View File

@ -41,8 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "pyCritterBrain.h"
#include "pyGeometry3.h"
#include "pySceneObject.h"
#include "plAvatar/plAvBrainCritter.h"
#include "pnSceneObject/plSceneObject.h"
pyCritterBrain::pyCritterBrain(): fBrain(nil) {}
@ -66,18 +68,12 @@ void pyCritterBrain::RemoveReceiver(pyKey& oldReceiver)
fBrain->RemoveReceiver(oldReceiver.getKey());
}
void pyCritterBrain::LocallyControlled(bool local)
PyObject* pyCritterBrain::GetSceneObject()
{
if (!fBrain)
return;
fBrain->LocallyControlled(local);
}
bool pyCritterBrain::LocallyControlled() const
{
if (!fBrain)
return false;
return fBrain->LocallyControlled();
if (fBrain)
if (plSceneObject* obj = fBrain->GetTarget())
return pySceneObject::New(obj->GetKey());
PYTHON_RETURN_NONE;
}
void pyCritterBrain::AddBehavior(const std::string& animationName, const std::string& behaviorName, bool loop /* = true */,

View File

@ -83,8 +83,7 @@ public:
void AddReceiver(pyKey& newReceiver);
void RemoveReceiver(pyKey& oldReceiver);
void LocallyControlled(bool local);
bool LocallyControlled() const;
PyObject* GetSceneObject();
void AddBehavior(const std::string& animationName, const std::string& behaviorName, bool loop = true, bool randomStartPos = true,
float fadeInLen = 2.f, float fadeOutLen = 2.f);

View File

@ -139,21 +139,9 @@ PYTHON_METHOD_DEFINITION(ptCritterBrain, removeReceiver, args)
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCritterBrain, setLocallyControlled, args)
PYTHON_METHOD_DEFINITION(ptCritterBrain, getSceneObject, GetSceneObject)
{
char local;
if (!PyArg_ParseTuple(args, "b", &local))
{
PyErr_SetString(PyExc_TypeError, "setLocallyControlled expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->LocallyControlled(local != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCritterBrain, getLocallyControlled)
{
PYTHON_RETURN_BOOL(self->fThis->LocallyControlled());
return self->fThis->GetSceneObject();
}
PYTHON_METHOD_DEFINITION_WKEY(ptCritterBrain, addBehavior, args, keywords)
@ -472,10 +460,7 @@ PYTHON_METHOD_DEFINITION(ptCritterBrain, vectorToPlayer, args)
PYTHON_START_METHODS_TABLE(ptCritterBrain)
PYTHON_METHOD(ptCritterBrain, addReceiver, "Params: key\nTells the brain that the specified key wants AI messages"),
PYTHON_METHOD(ptCritterBrain, removeReceiver, "Params: key\nTells the brain that the specified key no longer wants AI messages"),
PYTHON_METHOD(ptCritterBrain, setLocallyControlled, "Params: local\nTells the brain that we are the ones making all the AI decisions, and to prop location "
"and other information to the server."),
PYTHON_METHOD_NOARGS(ptCritterBrain, getLocallyControlled, "Are we the one making AI decisions? NOTE: Not set automatically, some python script needs to "
"tell the brain this using setLocallyControlled()."),
PYTHON_METHOD(ptCritterBrain, getSceneObject, "Returns the ptSceneObject this brain controls."),
PYTHON_METHOD_WKEY(ptCritterBrain, addBehavior, "Params: animName, behaviorName, loop = 1, randomStartPos = 1, fadeInLen = 2.0, fadeOutLen = 2.0\n"
"Adds a new animation to the brain as a behavior with the specified name and parameters. If multiple animations are assigned to the same behavior, "
"they will be randomly picked from when started."),