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