2023-08-06 14:21:43 +00:00
|
|
|
#ifndef MWLUA_OBJECTLISTS_H
|
|
|
|
#define MWLUA_OBJECTLISTS_H
|
2020-12-18 22:21:10 +00:00
|
|
|
|
2022-05-16 15:04:41 +00:00
|
|
|
#include <set>
|
|
|
|
|
2023-08-06 12:46:15 +00:00
|
|
|
#include "object.hpp"
|
2021-01-29 01:38:09 +00:00
|
|
|
|
2020-12-18 22:21:10 +00:00
|
|
|
namespace MWLua
|
|
|
|
{
|
|
|
|
|
2023-08-06 14:21:43 +00:00
|
|
|
// ObjectLists is used to track lists of game objects like nearby.items, nearby.actors, etc.
|
|
|
|
class ObjectLists
|
2020-12-18 22:21:10 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
void update(); // Should be called every frame.
|
|
|
|
void clear(); // Should be called every time before starting or loading a new game.
|
|
|
|
|
2021-01-29 00:54:54 +00:00
|
|
|
ObjectIdList getActivatorsInScene() const { return mActivatorsInScene.mList; }
|
2020-12-18 22:21:10 +00:00
|
|
|
ObjectIdList getActorsInScene() const { return mActorsInScene.mList; }
|
2021-01-29 00:54:54 +00:00
|
|
|
ObjectIdList getContainersInScene() const { return mContainersInScene.mList; }
|
|
|
|
ObjectIdList getDoorsInScene() const { return mDoorsInScene.mList; }
|
2020-12-18 22:21:10 +00:00
|
|
|
ObjectIdList getItemsInScene() const { return mItemsInScene.mList; }
|
2023-06-17 17:56:25 +00:00
|
|
|
ObjectIdList getPlayers() const { return mPlayers; }
|
2020-12-18 22:21:10 +00:00
|
|
|
|
|
|
|
void objectAddedToScene(const MWWorld::Ptr& ptr);
|
|
|
|
void objectRemovedFromScene(const MWWorld::Ptr& ptr);
|
|
|
|
|
2023-06-17 17:56:25 +00:00
|
|
|
void setPlayer(const MWWorld::Ptr& player) { *mPlayers = { getId(player) }; }
|
|
|
|
|
2020-12-18 22:21:10 +00:00
|
|
|
private:
|
|
|
|
struct ObjectGroup
|
|
|
|
{
|
|
|
|
void updateList();
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
bool mChanged = false;
|
|
|
|
ObjectIdList mList = std::make_shared<std::vector<ObjectId>>();
|
|
|
|
std::set<ObjectId> mSet;
|
|
|
|
};
|
|
|
|
|
2021-01-29 00:54:54 +00:00
|
|
|
ObjectGroup* chooseGroup(const MWWorld::Ptr& ptr);
|
2020-12-18 22:21:10 +00:00
|
|
|
void addToGroup(ObjectGroup& group, const MWWorld::Ptr& ptr);
|
|
|
|
void removeFromGroup(ObjectGroup& group, const MWWorld::Ptr& ptr);
|
|
|
|
|
2021-01-29 00:54:54 +00:00
|
|
|
ObjectGroup mActivatorsInScene;
|
2020-12-18 22:21:10 +00:00
|
|
|
ObjectGroup mActorsInScene;
|
2021-01-29 00:54:54 +00:00
|
|
|
ObjectGroup mContainersInScene;
|
|
|
|
ObjectGroup mDoorsInScene;
|
2020-12-18 22:21:10 +00:00
|
|
|
ObjectGroup mItemsInScene;
|
2023-06-17 17:56:25 +00:00
|
|
|
ObjectIdList mPlayers = std::make_shared<std::vector<ObjectId>>();
|
2020-12-18 22:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-08-06 14:21:43 +00:00
|
|
|
#endif // MWLUA_OBJECTLISTS_H
|