MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / registerInterface

Method registerInterface

plugins/script/interfaces/EntityInterface.cpp:138–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136};
137
138void EntityInterface::registerInterface(py::module& scope, py::dict& globals)
139{
140 // Add the EntityNode interface
141 py::class_<ScriptEntityNode, ScriptSceneNode> entityNode(scope, "EntityNode");
142 entityNode.def(py::init<const scene::INodePtr&>());
143 entityNode.def("getKeyValue", &ScriptEntityNode::getKeyValue);
144 entityNode.def("setKeyValue", &ScriptEntityNode::setKeyValue);
145 entityNode.def("forEachKeyValue", &ScriptEntityNode::forEachKeyValue);
146 entityNode.def("isInherited", &ScriptEntityNode::isInherited);
147 entityNode.def("getEntityClass", &ScriptEntityNode::getEntityClass);
148 entityNode.def("isModel", &ScriptEntityNode::isModel);
149 entityNode.def("isOfType", &ScriptEntityNode::isOfType);
150 entityNode.def("getKeyValuePairs", &ScriptEntityNode::getKeyValuePairs);
151
152 // Declare the KeyValuePairs vector
153 py::bind_vector<Entity::KeyValuePairs>(scope, "EntityKeyValuePairs");
154
155 // Expose the Entity::Visitor interface
156 py::class_<EntityVisitor, EntityVisitorWrapper> visitor(scope, "EntityVisitor");
157 visitor.def(py::init<>());
158 visitor.def("visit", &EntityVisitor::visit);
159
160 // Add the EntityCreator module declaration to the given python namespace
161 py::class_<EntityInterface> entityCreator(scope, "EntityCreator");
162
163 // Add both overloads to createEntity
164 entityCreator.def("createEntity", static_cast<ScriptSceneNode(EntityInterface::*)(const std::string&)>(&EntityInterface::createEntity));
165 entityCreator.def("createEntity", static_cast<ScriptSceneNode(EntityInterface::*)(const ScriptEntityClass&)>(&EntityInterface::createEntity));
166
167 // Now point the Python variable "GlobalEntityCreator" to this instance
168 globals["GlobalEntityCreator"] = this;
169}
170
171} // namespace script

Callers

nothing calls this directly

Calls 1

ScriptSceneNodeClass · 0.85

Tested by

no test coverage detected