MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / spawnProjectile

Method spawnProjectile

source/game/scripting/StarWorldLuaBindings.cpp:1009–1030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 11

singletonClass · 0.85
projectileDatabaseMethod · 0.80
createProjectileMethod · 0.80
setInitialPositionMethod · 0.80
setInitialDirectionMethod · 0.80
setSourceEntityMethod · 0.80
entityIdMethod · 0.80
outputExceptionFunction · 0.50
valueMethod · 0.45
addEntityMethod · 0.45
inWorldMethod · 0.45

Tested by

no test coverage detected