| 848 | } |
| 849 | |
| 850 | bool WorldCallbacks::placeObject(World* world, |
| 851 | String const& objectType, |
| 852 | Vec2I const& worldPosition, |
| 853 | Maybe<int> const& objectDirection, |
| 854 | Json const& objectParameters) { |
| 855 | auto objectDatabase = Root::singleton().objectDatabase(); |
| 856 | |
| 857 | try { |
| 858 | Direction direction = Direction::Right; |
| 859 | if (objectDirection && *objectDirection < 0) |
| 860 | direction = Direction::Left; |
| 861 | |
| 862 | Json parameters = objectParameters ? objectParameters : JsonObject(); |
| 863 | |
| 864 | auto placedObject = objectDatabase->createForPlacement(world, objectType, worldPosition, direction, parameters); |
| 865 | if (placedObject) { |
| 866 | world->addEntity(placedObject); |
| 867 | return true; |
| 868 | } |
| 869 | } catch (StarException const& exception) { |
| 870 | Logger::warn("Could not create placable object of kind '{}', exception caught: {}", |
| 871 | objectType, |
| 872 | outputException(exception, false)); |
| 873 | } |
| 874 | |
| 875 | return false; |
| 876 | } |
| 877 | |
| 878 | Maybe<EntityId> WorldCallbacks::spawnItem(World* world, |
| 879 | Json const& itemType, |
nothing calls this directly
no test coverage detected