| 1007 | } |
| 1008 | |
| 1009 | Maybe<EntityId> WorldCallbacks::spawnProjectile(World* world, |
| 1010 | String const& projectileType, |
| 1011 | Vec2F const& spawnPosition, |
| 1012 | Maybe<EntityId> const& sourceEntityId, |
| 1013 | Maybe<Vec2F> const& projectileDirection, |
| 1014 | bool trackSourceEntity, |
| 1015 | Json const& projectileParameters) { |
| 1016 | |
| 1017 | try { |
| 1018 | auto projectileDatabase = Root::singleton().projectileDatabase(); |
| 1019 | auto projectile = projectileDatabase->createProjectile(projectileType, projectileParameters ? projectileParameters : JsonObject()); |
| 1020 | projectile->setInitialPosition(spawnPosition); |
| 1021 | projectile->setInitialDirection(projectileDirection.value()); |
| 1022 | projectile->setSourceEntity(sourceEntityId.value(NullEntityId), trackSourceEntity); |
| 1023 | world->addEntity(projectile); |
| 1024 | return projectile->inWorld() ? projectile->entityId() : Maybe<EntityId>(); |
| 1025 | } catch (StarException const& exception) { |
| 1026 | Logger::warn( |
| 1027 | "Could not spawn Projectile of type '{}', exception caught: {}", projectileType, outputException(exception, false)); |
| 1028 | return {}; |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | Maybe<EntityId> WorldCallbacks::spawnVehicle( |
| 1033 | World* world, String const& vehicleName, Vec2F const& pos, Json const& extraConfig) { |
nothing calls this directly
no test coverage detected