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

Method loungeableQuery

source/game/scripting/StarWorldLuaBindings.cpp:1284–1313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1282 }
1283
1284 LuaTable WorldEntityCallbacks::loungeableQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe<LuaTable> options) {
1285 String orientationName;
1286 if (options)
1287 orientationName = options->get<Maybe<String>>("orientation").value();
1288
1289 LoungeOrientation orientation = LoungeOrientation::None;
1290 if (orientationName == "sit")
1291 orientation = LoungeOrientation::Sit;
1292 else if (orientationName == "lay")
1293 orientation = LoungeOrientation::Lay;
1294 else if (orientationName == "stand")
1295 orientation = LoungeOrientation::Stand;
1296 else if (orientationName.empty())
1297 orientation = LoungeOrientation::None;
1298 else
1299 throw StarException(strf("Unsupported loungeableQuery orientation {}", orientationName));
1300
1301 auto filter = [orientation](shared_ptr<LoungeableObject> const& entity) -> bool {
1302 auto loungeable = as<LoungeableEntity>(entity);
1303 if (!loungeable || loungeable->anchorCount() == 0)
1304 return false;
1305
1306 if (orientation == LoungeOrientation::None)
1307 return true;
1308 auto pos = loungeable->loungeAnchor(0);
1309 return pos && pos->orientation == orientation;
1310 };
1311
1312 return LuaBindings::entityQuery<LoungeableObject>(world, engine, pos1, pos2, std::move(options), filter);
1313 }
1314
1315 LuaTable WorldEntityCallbacks::entityLineQuery(World* world, LuaEngine& engine, Vec2F const& point1, Vec2F const& point2, Maybe<LuaTable> options) {
1316 return LuaBindings::entityLineQuery<Entity>(world, engine, point1, point2, std::move(options));

Callers

nothing calls this directly

Calls 6

StarExceptionClass · 0.85
strfFunction · 0.85
valueMethod · 0.45
emptyMethod · 0.45
anchorCountMethod · 0.45
loungeAnchorMethod · 0.45

Tested by

no test coverage detected