diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-01-21 19:16:23 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-01-21 19:16:23 +1100 |
commit | 46deaa1f1a3f770e55553c2392567eba467d08af (patch) | |
tree | a40c68efa901f54655c34a247991c977d2d8fd6a | |
parent | 034b6cb93f0b39aefceee69c81b911fe1bac3d27 (diff) |
add world.loungingEntities, world.loungableAnchorCount and anchor index arg to loungeableOccupied
-rw-r--r-- | source/game/scripting/StarWorldLuaBindings.cpp | 23 | ||||
-rw-r--r-- | source/game/scripting/StarWorldLuaBindings.hpp | 4 |
2 files changed, 22 insertions, 5 deletions
diff --git a/source/game/scripting/StarWorldLuaBindings.cpp b/source/game/scripting/StarWorldLuaBindings.cpp index 624660f..f5d9172 100644 --- a/source/game/scripting/StarWorldLuaBindings.cpp +++ b/source/game/scripting/StarWorldLuaBindings.cpp @@ -530,7 +530,9 @@ namespace LuaBindings { callbacks.registerCallbackWithSignature<Maybe<LuaValue>, EntityId, String, LuaVariadic<LuaValue>>("callScriptedEntity", bind(WorldEntityCallbacks::callScriptedEntity, world, _1, _2, _3)); callbacks.registerCallbackWithSignature<RpcPromise<Vec2F>, String>("findUniqueEntity", bind(WorldEntityCallbacks::findUniqueEntity, world, _1)); callbacks.registerCallbackWithSignature<RpcPromise<Json>, LuaEngine&, LuaValue, String, LuaVariadic<Json>>("sendEntityMessage", bind(WorldEntityCallbacks::sendEntityMessage, world, _1, _2, _3, _4)); - callbacks.registerCallbackWithSignature<Maybe<bool>, EntityId>("loungeableOccupied", bind(WorldEntityCallbacks::loungeableOccupied, world, _1)); + callbacks.registerCallbackWithSignature<Maybe<List<EntityId>>, EntityId, Maybe<size_t>>("loungingEntities", bind(WorldEntityCallbacks::loungingEntities, world, _1, _2)); + callbacks.registerCallbackWithSignature<Maybe<bool>, EntityId, Maybe<size_t>>("loungeableOccupied", bind(WorldEntityCallbacks::loungeableOccupied, world, _1, _2)); + callbacks.registerCallbackWithSignature<Maybe<size_t>, EntityId>("loungeableAnchorCount", bind(WorldEntityCallbacks::loungeableAnchorCount, world, _1)); callbacks.registerCallbackWithSignature<bool, EntityId, Maybe<bool>>("isMonster", bind(WorldEntityCallbacks::isMonster, world, _1, _2)); callbacks.registerCallbackWithSignature<Maybe<String>, EntityId>("monsterType", bind(WorldEntityCallbacks::monsterType, world, _1)); callbacks.registerCallbackWithSignature<Maybe<String>, EntityId>("npcType", bind(WorldEntityCallbacks::npcType, world, _1)); @@ -1770,10 +1772,23 @@ namespace LuaBindings { return world->sendEntityMessage(engine.luaTo<EntityId>(entityId), message, JsonArray::from(std::move(args))); } - Maybe<bool> WorldEntityCallbacks::loungeableOccupied(World* world, EntityId entityId) { + Maybe<List<EntityId>> WorldEntityCallbacks::loungingEntities(World* world, EntityId entityId, Maybe<size_t> anchorIndex) { + if (auto entity = world->get<LoungeableEntity>(entityId)) + return entity->entitiesLoungingIn(anchorIndex.value()).values(); + return {}; + } + + Maybe<bool> WorldEntityCallbacks::loungeableOccupied(World* world, EntityId entityId, Maybe<size_t> anchorIndex) { auto entity = world->get<LoungeableEntity>(entityId); - if (entity && entity->anchorCount() > 0) - return !entity->entitiesLoungingIn(0).empty(); + size_t anchor = anchorIndex.value(); + if (entity && entity->anchorCount() > anchor) + return !entity->entitiesLoungingIn(anchor).empty(); + return {}; + } + + Maybe<size_t> WorldEntityCallbacks::loungeableAnchorCount(World* world, EntityId entityId) { + if (auto entity = world->get<LoungeableEntity>(entityId)) + return entity->anchorCount(); return {}; } diff --git a/source/game/scripting/StarWorldLuaBindings.hpp b/source/game/scripting/StarWorldLuaBindings.hpp index e3329bf..3cb8c72 100644 --- a/source/game/scripting/StarWorldLuaBindings.hpp +++ b/source/game/scripting/StarWorldLuaBindings.hpp @@ -154,7 +154,9 @@ namespace LuaBindings { Maybe<LuaValue> callScriptedEntity(World* world, EntityId entityId, String const& function, LuaVariadic<LuaValue> const& args); RpcPromise<Vec2F> findUniqueEntity(World* world, String const& uniqueId); RpcPromise<Json> sendEntityMessage(World* world, LuaEngine& engine, LuaValue entityId, String const& message, LuaVariadic<Json> args); - Maybe<bool> loungeableOccupied(World* world, EntityId entityId); + Maybe<List<EntityId>> loungingEntities(World* world, EntityId entityId, Maybe<size_t> anchorIndex); + Maybe<bool> loungeableOccupied(World* world, EntityId entityId, Maybe<size_t> anchorIndex); + Maybe<size_t> loungeableAnchorCount(World* world, EntityId entityId); bool isMonster(World* world, EntityId entityId, Maybe<bool> const& aggressive); Maybe<String> monsterType(World* world, EntityId entityId); Maybe<String> npcType(World* world, EntityId entityId); |