| 55 | } |
| 56 | |
| 57 | IEntityNodePtr createNodeForEntity(const IEntityClassPtr& eclass) |
| 58 | { |
| 59 | // Null entityclass check |
| 60 | if (!eclass) |
| 61 | { |
| 62 | throw std::runtime_error( |
| 63 | _("createNodeForEntity(): cannot create entity for NULL entityclass.") |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | // Otherwise create the correct entity subclass based on the entity class parameters. |
| 68 | switch (eclass->getClassType()) |
| 69 | { |
| 70 | case IEntityClass::Type::Light: |
| 71 | return LightNode::Create(eclass); |
| 72 | |
| 73 | case IEntityClass::Type::StaticGeometry: |
| 74 | return StaticGeometryNode::Create(eclass); // Variable size entity |
| 75 | |
| 76 | case IEntityClass::Type::EntityClassModel: |
| 77 | return EclassModelNode::Create(eclass); // Fixed size, has model path |
| 78 | |
| 79 | case IEntityClass::Type::Speaker: |
| 80 | return SpeakerNode::create(eclass); |
| 81 | |
| 82 | case IEntityClass::Type::Generic: |
| 83 | return GenericEntityNode::Create(eclass); // Fixed size, no model path |
| 84 | |
| 85 | default: |
| 86 | throw std::invalid_argument("Entity class type " + |
| 87 | string::to_string(static_cast<int>(eclass->getClassType())) + " is not supported"); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | IEntityNodePtr Doom3EntityModule::createEntity(const IEntityClassPtr& eclass) |
| 92 | { |
no test coverage detected