1

Async cell rescan in a separate thread after pickup, removed the perk

This commit is contained in:
Eddoursul 2022-07-09 00:47:03 +02:00
parent adb77dd4d9
commit 31b9d5642e
9 changed files with 28 additions and 21 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -198,6 +198,7 @@ namespace ArtifactTracker
g_bHomeContainer = false; g_bHomeContainer = false;
g_cellStorage = cellStorage; g_cellStorage = cellStorage;
RE::UI::GetSingleton()->AddEventSink<RE::MenuOpenCloseEvent>(EventListener::GetSingleton()); RE::UI::GetSingleton()->AddEventSink<RE::MenuOpenCloseEvent>(EventListener::GetSingleton());
RE::ScriptEventSourceHolder::GetSingleton()->AddEventSink<RE::TESActivateEvent>(EventListener::GetSingleton());
#ifdef _DEBUG #ifdef _DEBUG
SKSE::log::info("Home mode ON"); SKSE::log::info("Home mode ON");
#endif #endif
@ -206,6 +207,7 @@ namespace ArtifactTracker
g_bHomeContainer = false; g_bHomeContainer = false;
g_cellStorage = nullptr; g_cellStorage = nullptr;
RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(EventListener::GetSingleton()); RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(EventListener::GetSingleton());
RE::ScriptEventSourceHolder::GetSingleton()->RemoveEventSink<RE::TESActivateEvent>(EventListener::GetSingleton());
#ifdef _DEBUG #ifdef _DEBUG
SKSE::log::info("Home mode OFF"); SKSE::log::info("Home mode OFF");
#endif #endif

View File

@ -1,5 +1,6 @@
#include "EventListener.h" #include "EventListener.h"
#include "ArtifactTracker.h" #include "ArtifactTracker.h"
#include "Util.h"
auto EventListener::GetSingleton() -> EventListener* auto EventListener::GetSingleton() -> EventListener*
{ {
@ -86,3 +87,21 @@ auto EventListener::ProcessEvent(
return RE::BSEventNotifyControl::kContinue; return RE::BSEventNotifyControl::kContinue;
} }
auto EventListener::ProcessEvent(
const RE::TESActivateEvent* a_event,
RE::BSTEventSource<RE::TESActivateEvent>* a_eventSource)
-> RE::BSEventNotifyControl
{
if (ArtifactTracker::IsHome() && a_event->actionRef->IsPlayerRef() && a_event->objectActivated) {
const auto ref = a_event->objectActivated.get();
if (ref && ArtifactTracker::IsArtifact(ref->GetBaseObject())) {
std::thread([]() {
std::this_thread::sleep_for(std::chrono::milliseconds(200));
ArtifactTracker::SyncCellStorage();
}).detach();
}
}
return RE::BSEventNotifyControl::kContinue;
}

View File

@ -5,7 +5,8 @@ class EventListener :
public RE::BSTEventSink<RE::TESContainerChangedEvent>, public RE::BSTEventSink<RE::TESContainerChangedEvent>,
public RE::BSTEventSink<RE::TESCellFullyLoadedEvent>, public RE::BSTEventSink<RE::TESCellFullyLoadedEvent>,
public RE::BSTEventSink<RE::BGSActorCellEvent>, public RE::BSTEventSink<RE::BGSActorCellEvent>,
public RE::BSTEventSink<RE::MenuOpenCloseEvent> public RE::BSTEventSink<RE::MenuOpenCloseEvent>,
public RE::BSTEventSink<RE::TESActivateEvent>
{ {
public: public:
~EventListener() = default; ~EventListener() = default;
@ -42,6 +43,11 @@ public:
RE::BSTEventSource<SKSE::ModCallbackEvent>* a_eventSource) RE::BSTEventSource<SKSE::ModCallbackEvent>* a_eventSource)
-> RE::BSEventNotifyControl override; -> RE::BSEventNotifyControl override;
auto ProcessEvent(
const RE::TESActivateEvent* a_event,
RE::BSTEventSource<RE::TESActivateEvent>* a_eventSource)
-> RE::BSEventNotifyControl override;
private: private:
EventListener() = default; EventListener() = default;
}; };

View File

@ -6,8 +6,6 @@ FormList Property ETR_ItemsStored Auto
Keyword Property LocTypePlayerHouse Auto Keyword Property LocTypePlayerHouse Auto
Perk Property ETR_PickupPerk Auto
bool bAtHome = false bool bAtHome = false
ObjectReference bookShelf = None ObjectReference bookShelf = None
int iFollowerIndex = 0 int iFollowerIndex = 0
@ -31,10 +29,6 @@ Event OnPlayerLoadGame()
return return
endif endif
if ! (GetReference() as Actor).HasPerk(ETR_PickupPerk)
(GetReference() as Actor).AddPerk(ETR_PickupPerk)
endif
if skse.GetPluginVersion("Ahzaab's moreHUD Plugin") >= 30800 if skse.GetPluginVersion("Ahzaab's moreHUD Plugin") >= 30800
ahzmorehud.RegisterIconFormList("dbmNew", ETR_ItemsNew) ahzmorehud.RegisterIconFormList("dbmNew", ETR_ItemsNew)
ahzmorehud.RegisterIconFormList("dbmFound", ETR_ItemsFound) ahzmorehud.RegisterIconFormList("dbmFound", ETR_ItemsFound)

View File

@ -1,14 +0,0 @@
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 6
Scriptname PRKF_ETR_PickupPerk_03000808 Extends Perk Hidden
;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akTargetRef, Actor akActor)
;BEGIN CODE
Utility.wait(0.3)
ArtifactTrackerPlayer.SyncCellStorage()
;END CODE
EndFunction
;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment