mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-30 12:32:36 +00:00
Rename MWLua::WorldView -> MWLua::ObjectLists
This commit is contained in:
parent
6c4e1f4e8f
commit
87912065fd
@ -59,7 +59,7 @@ add_openmw_dir (mwscript
|
||||
)
|
||||
|
||||
add_openmw_dir (mwlua
|
||||
luamanagerimp object worldview userdataserializer luaevents engineevents objectvariant
|
||||
luamanagerimp object objectlists userdataserializer luaevents engineevents objectvariant
|
||||
context globalscripts localscripts playerscripts luabindings objectbindings cellbindings mwscriptbindings
|
||||
camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings
|
||||
types/types types/door types/item types/actor types/container types/lockable types/weapon types/npc types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing types/levelledlist
|
||||
|
@ -11,7 +11,7 @@ namespace MWLua
|
||||
{
|
||||
class LuaEvents;
|
||||
class LuaManager;
|
||||
class WorldView;
|
||||
class ObjectLists;
|
||||
|
||||
struct Context
|
||||
{
|
||||
@ -19,7 +19,7 @@ namespace MWLua
|
||||
LuaManager* mLuaManager;
|
||||
LuaUtil::LuaState* mLua;
|
||||
LuaUtil::UserdataSerializer* mSerializer;
|
||||
WorldView* mWorldView;
|
||||
ObjectLists* mObjectLists;
|
||||
LuaEvents* mLuaEvents;
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "luaevents.hpp"
|
||||
#include "luamanagerimp.hpp"
|
||||
#include "mwscriptbindings.hpp"
|
||||
#include "worldview.hpp"
|
||||
#include "objectlists.hpp"
|
||||
|
||||
#include "camerabindings.hpp"
|
||||
#include "cellbindings.hpp"
|
||||
@ -235,12 +235,12 @@ namespace MWLua
|
||||
static sol::table initWorldPackage(const Context& context)
|
||||
{
|
||||
sol::table api(context.mLua->sol(), sol::create);
|
||||
WorldView* worldView = context.mWorldView;
|
||||
ObjectLists* objectLists = context.mObjectLists;
|
||||
addTimeBindings(api, context, true);
|
||||
addCellGetters(api, context);
|
||||
api["mwscript"] = initMWScriptBindings(context);
|
||||
api["activeActors"] = GObjectList{ worldView->getActorsInScene() };
|
||||
api["players"] = GObjectList{ worldView->getPlayers() };
|
||||
api["activeActors"] = GObjectList{ objectLists->getActorsInScene() };
|
||||
api["players"] = GObjectList{ objectLists->getPlayers() };
|
||||
api["createObject"] = [](std::string_view recordId, sol::optional<int> count) -> GObject {
|
||||
MWWorld::ManualRef mref(*MWBase::Environment::get().getESMStore(), ESM::RefId::deserializeText(recordId));
|
||||
const MWWorld::Ptr& ptr = mref.getPtr();
|
||||
|
@ -76,7 +76,7 @@ namespace MWLua
|
||||
context.mIsGlobal = true;
|
||||
context.mLuaManager = this;
|
||||
context.mLua = &mLua;
|
||||
context.mWorldView = &mWorldView;
|
||||
context.mObjectLists = &mObjectLists;
|
||||
context.mLuaEvents = &mLuaEvents;
|
||||
context.mSerializer = mGlobalSerializer.get();
|
||||
|
||||
@ -137,7 +137,7 @@ namespace MWLua
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(mPlayer);
|
||||
}
|
||||
|
||||
mWorldView.update();
|
||||
mObjectLists.update();
|
||||
|
||||
std::erase_if(mActiveLocalScripts, [](const LocalScripts* l) {
|
||||
return l->getPtrOrEmpty().isEmpty() || l->getPtrOrEmpty().getRefData().isDeleted();
|
||||
@ -261,7 +261,7 @@ namespace MWLua
|
||||
mLuaEvents.clear();
|
||||
mEngineEvents.clear();
|
||||
mInputEvents.clear();
|
||||
mWorldView.clear();
|
||||
mObjectLists.clear();
|
||||
mGlobalScripts.removeAllScripts();
|
||||
mGlobalScriptsStarted = false;
|
||||
mNewGameStarted = false;
|
||||
@ -283,8 +283,8 @@ namespace MWLua
|
||||
return;
|
||||
if (!mPlayer.isEmpty())
|
||||
throw std::logic_error("Player is initialized twice");
|
||||
mWorldView.objectAddedToScene(ptr);
|
||||
mWorldView.setPlayer(ptr);
|
||||
mObjectLists.objectAddedToScene(ptr);
|
||||
mObjectLists.setPlayer(ptr);
|
||||
mPlayer = ptr;
|
||||
LocalScripts* localScripts = ptr.getRefData().getLuaScripts();
|
||||
if (!localScripts)
|
||||
@ -313,7 +313,7 @@ namespace MWLua
|
||||
|
||||
void LuaManager::objectAddedToScene(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mWorldView.objectAddedToScene(ptr); // assigns generated RefNum if it is not set yet.
|
||||
mObjectLists.objectAddedToScene(ptr); // assigns generated RefNum if it is not set yet.
|
||||
mEngineEvents.addToQueue(EngineEvents::OnActive{ getId(ptr) });
|
||||
|
||||
LocalScripts* localScripts = ptr.getRefData().getLuaScripts();
|
||||
@ -333,7 +333,7 @@ namespace MWLua
|
||||
|
||||
void LuaManager::objectRemovedFromScene(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
mWorldView.objectRemovedFromScene(ptr);
|
||||
mObjectLists.objectRemovedFromScene(ptr);
|
||||
LocalScripts* localScripts = ptr.getRefData().getLuaScripts();
|
||||
if (localScripts)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "localscripts.hpp"
|
||||
#include "luaevents.hpp"
|
||||
#include "object.hpp"
|
||||
#include "worldview.hpp"
|
||||
#include "objectlists.hpp"
|
||||
|
||||
namespace MWLua
|
||||
{
|
||||
@ -157,7 +157,7 @@ namespace MWLua
|
||||
|
||||
GlobalScripts mGlobalScripts{ &mLua };
|
||||
std::set<LocalScripts*> mActiveLocalScripts;
|
||||
WorldView mWorldView;
|
||||
ObjectLists mObjectLists;
|
||||
|
||||
MWWorld::Ptr mPlayer;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "../mwphysics/raycasting.hpp"
|
||||
|
||||
#include "luamanagerimp.hpp"
|
||||
#include "worldview.hpp"
|
||||
#include "objectlists.hpp"
|
||||
|
||||
namespace sol
|
||||
{
|
||||
@ -25,7 +25,7 @@ namespace MWLua
|
||||
sol::table initNearbyPackage(const Context& context)
|
||||
{
|
||||
sol::table api(context.mLua->sol(), sol::create);
|
||||
WorldView* worldView = context.mWorldView;
|
||||
ObjectLists* objectLists = context.mObjectLists;
|
||||
|
||||
sol::usertype<MWPhysics::RayCastingResult> rayResult
|
||||
= context.mLua->sol().new_usertype<MWPhysics::RayCastingResult>("RayCastingResult");
|
||||
@ -131,12 +131,12 @@ namespace MWLua
|
||||
return LObject(refId.getIf<ESM::FormIdRefId>()->getValue());
|
||||
};
|
||||
|
||||
api["activators"] = LObjectList{ worldView->getActivatorsInScene() };
|
||||
api["actors"] = LObjectList{ worldView->getActorsInScene() };
|
||||
api["containers"] = LObjectList{ worldView->getContainersInScene() };
|
||||
api["doors"] = LObjectList{ worldView->getDoorsInScene() };
|
||||
api["items"] = LObjectList{ worldView->getItemsInScene() };
|
||||
api["players"] = LObjectList{ worldView->getPlayers() };
|
||||
api["activators"] = LObjectList{ objectLists->getActivatorsInScene() };
|
||||
api["actors"] = LObjectList{ objectLists->getActorsInScene() };
|
||||
api["containers"] = LObjectList{ objectLists->getContainersInScene() };
|
||||
api["doors"] = LObjectList{ objectLists->getDoorsInScene() };
|
||||
api["items"] = LObjectList{ objectLists->getItemsInScene() };
|
||||
api["players"] = LObjectList{ objectLists->getPlayers() };
|
||||
|
||||
api["NAVIGATOR_FLAGS"]
|
||||
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, DetourNavigator::Flag>({
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "worldview.hpp"
|
||||
#include "objectlists.hpp"
|
||||
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
@ -17,7 +17,7 @@
|
||||
namespace MWLua
|
||||
{
|
||||
|
||||
void WorldView::update()
|
||||
void ObjectLists::update()
|
||||
{
|
||||
mActivatorsInScene.updateList();
|
||||
mActorsInScene.updateList();
|
||||
@ -26,7 +26,7 @@ namespace MWLua
|
||||
mItemsInScene.updateList();
|
||||
}
|
||||
|
||||
void WorldView::clear()
|
||||
void ObjectLists::clear()
|
||||
{
|
||||
mActivatorsInScene.clear();
|
||||
mActorsInScene.clear();
|
||||
@ -35,7 +35,7 @@ namespace MWLua
|
||||
mItemsInScene.clear();
|
||||
}
|
||||
|
||||
WorldView::ObjectGroup* WorldView::chooseGroup(const MWWorld::Ptr& ptr)
|
||||
ObjectLists::ObjectGroup* ObjectLists::chooseGroup(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
// It is important to check `isMarker` first.
|
||||
// For example "prisonmarker" has class "Door" despite that it is only an invisible marker.
|
||||
@ -55,7 +55,7 @@ namespace MWLua
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WorldView::objectAddedToScene(const MWWorld::Ptr& ptr)
|
||||
void ObjectLists::objectAddedToScene(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
MWBase::Environment::get().getWorldModel()->registerPtr(ptr);
|
||||
ObjectGroup* group = chooseGroup(ptr);
|
||||
@ -63,14 +63,14 @@ namespace MWLua
|
||||
addToGroup(*group, ptr);
|
||||
}
|
||||
|
||||
void WorldView::objectRemovedFromScene(const MWWorld::Ptr& ptr)
|
||||
void ObjectLists::objectRemovedFromScene(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
ObjectGroup* group = chooseGroup(ptr);
|
||||
if (group)
|
||||
removeFromGroup(*group, ptr);
|
||||
}
|
||||
|
||||
void WorldView::ObjectGroup::updateList()
|
||||
void ObjectLists::ObjectGroup::updateList()
|
||||
{
|
||||
if (mChanged)
|
||||
{
|
||||
@ -81,20 +81,20 @@ namespace MWLua
|
||||
}
|
||||
}
|
||||
|
||||
void WorldView::ObjectGroup::clear()
|
||||
void ObjectLists::ObjectGroup::clear()
|
||||
{
|
||||
mChanged = false;
|
||||
mList->clear();
|
||||
mSet.clear();
|
||||
}
|
||||
|
||||
void WorldView::addToGroup(ObjectGroup& group, const MWWorld::Ptr& ptr)
|
||||
void ObjectLists::addToGroup(ObjectGroup& group, const MWWorld::Ptr& ptr)
|
||||
{
|
||||
group.mSet.insert(getId(ptr));
|
||||
group.mChanged = true;
|
||||
}
|
||||
|
||||
void WorldView::removeFromGroup(ObjectGroup& group, const MWWorld::Ptr& ptr)
|
||||
void ObjectLists::removeFromGroup(ObjectGroup& group, const MWWorld::Ptr& ptr)
|
||||
{
|
||||
group.mSet.erase(getId(ptr));
|
||||
group.mChanged = true;
|
@ -1,5 +1,5 @@
|
||||
#ifndef MWLUA_WORLDVIEW_H
|
||||
#define MWLUA_WORLDVIEW_H
|
||||
#ifndef MWLUA_OBJECTLISTS_H
|
||||
#define MWLUA_OBJECTLISTS_H
|
||||
|
||||
#include <set>
|
||||
|
||||
@ -8,11 +8,8 @@
|
||||
namespace MWLua
|
||||
{
|
||||
|
||||
// WorldView is a kind of an extension to mwworld. It was created on initial stage of
|
||||
// OpenMW Lua development in order to minimize the risk of merge conflicts.
|
||||
// TODO: Move get*InScene functions to mwworld/scene
|
||||
// TODO: Remove WorldView.
|
||||
class WorldView
|
||||
// ObjectLists is used to track lists of game objects like nearby.items, nearby.actors, etc.
|
||||
class ObjectLists
|
||||
{
|
||||
public:
|
||||
void update(); // Should be called every frame.
|
||||
@ -55,4 +52,4 @@ namespace MWLua
|
||||
|
||||
}
|
||||
|
||||
#endif // MWLUA_WORLDVIEW_H
|
||||
#endif // MWLUA_OBJECTLISTS_H
|
@ -13,7 +13,7 @@
|
||||
//
|
||||
// Subrecords:
|
||||
// LUAF - LuaScriptCfg::mFlags and ESM::RecNameInts list
|
||||
// LUAW - Start of MWLua::WorldView data
|
||||
// LUAW - Simulation time and last generated RefNum
|
||||
// LUAE - Start of MWLua::LocalEvent or MWLua::GlobalEvent (eventName)
|
||||
// LUAS - VFS path to a Lua script
|
||||
// LUAD - Serialized Lua variable
|
||||
|
Loading…
x
Reference in New Issue
Block a user