Moved delayed bookshelf processing to the DLL
This commit is contained in:
parent
31b9d5642e
commit
39b9e5cc04
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,6 +7,7 @@ namespace ArtifactTracker
|
||||
{
|
||||
bool g_bLoaded;
|
||||
bool g_bHomeContainer;
|
||||
bool g_bBookShelf;
|
||||
RE::TESBoundObject* g_cellContainer;
|
||||
RE::BGSListForm* g_listNew;
|
||||
RE::BGSListForm* g_listStored;
|
||||
@ -175,6 +176,8 @@ namespace ArtifactTracker
|
||||
&& IsInSameCell(refr.get())
|
||||
&& !g_persistentMap.contains(refr.get()->formID);
|
||||
|
||||
g_bBookShelf = g_bHomeContainer && refr->GetBaseObject()->formID == 0xDC9E7;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (g_bHomeContainer) {
|
||||
RE::DebugNotification("Delayed processing enabled");
|
||||
@ -183,7 +186,16 @@ namespace ArtifactTracker
|
||||
|
||||
} else if (g_bHomeContainer) {
|
||||
g_bHomeContainer = false;
|
||||
SyncCellStorage();
|
||||
|
||||
if (g_bBookShelf) {
|
||||
g_bBookShelf = false;
|
||||
std::thread([]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1200));
|
||||
ArtifactTracker::SyncCellStorage();
|
||||
}).detach();
|
||||
} else {
|
||||
SyncCellStorage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace ArtifactTracker
|
||||
{
|
||||
extern bool g_bLoaded;
|
||||
extern bool g_bHomeContainer;
|
||||
extern bool g_bBookShelf;
|
||||
extern RE::TESBoundObject* g_cellContainer;
|
||||
extern RE::BGSListForm* g_listNew;
|
||||
extern RE::BGSListForm* g_listStored;
|
||||
|
@ -93,6 +93,7 @@ auto EventListener::ProcessEvent(
|
||||
RE::BSTEventSource<RE::TESActivateEvent>* a_eventSource)
|
||||
-> RE::BSEventNotifyControl
|
||||
{
|
||||
// This listener is expected to be unregistered outside of home.
|
||||
if (ArtifactTracker::IsHome() && a_event->actionRef->IsPlayerRef() && a_event->objectActivated) {
|
||||
const auto ref = a_event->objectActivated.get();
|
||||
if (ref && ArtifactTracker::IsArtifact(ref->GetBaseObject())) {
|
||||
|
@ -4,10 +4,6 @@ FormList Property ETR_ItemsNew Auto
|
||||
FormList Property ETR_ItemsFound Auto
|
||||
FormList Property ETR_ItemsStored Auto
|
||||
|
||||
Keyword Property LocTypePlayerHouse Auto
|
||||
|
||||
bool bAtHome = false
|
||||
ObjectReference bookShelf = None
|
||||
int iFollowerIndex = 0
|
||||
int iArtifactCount = 0
|
||||
|
||||
@ -59,34 +55,11 @@ Event OnPlayerLoadGame()
|
||||
RescanFoundArtifacts()
|
||||
RescanNewArtifacts()
|
||||
|
||||
Location currentLocation = (GetReference() as ObjectReference).GetCurrentLocation()
|
||||
bAtHome = currentLocation && currentLocation.HasKeyword(LocTypePlayerHouse)
|
||||
|
||||
if bAtHome
|
||||
RegisterForModEvent("AT_HomeInventoryUpdate", "OnHomeInventoryUpdate")
|
||||
RegisterForMenu("ContainerMenu")
|
||||
GotoState("AtHome")
|
||||
else
|
||||
UnregisterForModEvent("AT_HomeInventoryUpdate")
|
||||
UnregisterForMenu("ContainerMenu")
|
||||
GotoState("")
|
||||
endif
|
||||
|
||||
EndEvent
|
||||
|
||||
|
||||
Event OnLocationChange(Location akOldLoc, Location akNewLoc)
|
||||
|
||||
bAtHome = akNewLoc && akNewLoc.HasKeyword(LocTypePlayerHouse)
|
||||
|
||||
if bAtHome
|
||||
RegisterForModEvent("AT_HomeInventoryUpdate", "OnHomeInventoryUpdate")
|
||||
GotoState("AtHome")
|
||||
elseif akOldLoc && akOldLoc.HasKeyword(LocTypePlayerHouse)
|
||||
UnregisterForModEvent("AT_HomeInventoryUpdate")
|
||||
GotoState("")
|
||||
endif
|
||||
|
||||
int iCurrentFollowers = 0;
|
||||
Actor[] aFollowers = GetPlayerFollowers()
|
||||
int i = aFollowers.length
|
||||
@ -111,53 +84,6 @@ Event OnUpdate()
|
||||
EndEvent
|
||||
|
||||
|
||||
event OnHomeInventoryUpdate(string eventName, string strArg, float numArg, Form sender)
|
||||
if bAtHome
|
||||
SyncCellStorage()
|
||||
endif
|
||||
endevent
|
||||
|
||||
|
||||
state AtHome
|
||||
|
||||
event OnBeginState()
|
||||
RegisterForMenu("ContainerMenu")
|
||||
endevent
|
||||
|
||||
event OnEndState()
|
||||
UnregisterForMenu("ContainerMenu")
|
||||
endevent
|
||||
|
||||
event OnMenuOpen(String MenuName)
|
||||
if ! bAtHome
|
||||
GotoState("")
|
||||
return
|
||||
endif
|
||||
ObjectReference currentContainer = GetCurrentContainer()
|
||||
if currentContainer as PlayerBookShelfContainerScript
|
||||
bookShelf = currentContainer
|
||||
endif
|
||||
endevent
|
||||
|
||||
event OnMenuClose(String MenuName)
|
||||
|
||||
if bookShelf
|
||||
ObjectReference ref = bookShelf
|
||||
bookShelf = None
|
||||
Utility.wait(1.0)
|
||||
int iLimit = 10
|
||||
while iLimit > 0 && (ref as PlayerBookShelfContainerScript).GetState() == "PlacingBooks"
|
||||
iLimit -= 1
|
||||
Utility.wait(0.5)
|
||||
endwhile
|
||||
SyncCellStorage()
|
||||
endif
|
||||
|
||||
endevent
|
||||
|
||||
endstate
|
||||
|
||||
|
||||
; NATIVE FUNCTIONS
|
||||
|
||||
bool function Load() native global
|
||||
|
Loading…
Reference in New Issue
Block a user