| 57 | * @ignore |
| 58 | */ |
| 59 | export function detectObjectType(settings) { |
| 60 | if (settings instanceof TMXLayer) { |
| 61 | return "layer"; |
| 62 | } |
| 63 | // check if a factory is registered for this object's class |
| 64 | if (typeof settings.class === "string" && factories.has(settings.class)) { |
| 65 | return settings.class; |
| 66 | } |
| 67 | // check if a factory is registered for this object's name |
| 68 | if (typeof settings.name === "string" && factories.has(settings.name)) { |
| 69 | return settings.name; |
| 70 | } |
| 71 | if (typeof settings.text === "object") { |
| 72 | return "text"; |
| 73 | } |
| 74 | if (typeof settings.tile === "object") { |
| 75 | return "tile"; |
| 76 | } |
| 77 | return "shape"; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Register a factory function for a given Tiled object type. |