Skip to content

Commit

Permalink
feat: TESHarvestEvent implementation, minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
FlenarnTemp committed Oct 3, 2024
1 parent 208bde6 commit 90663c5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
39 changes: 39 additions & 0 deletions Plugin/src/Events/TESHavestEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

namespace RE
{
namespace Cascadia
{
class TESHarvestEventWatcher :
public BSTEventSink<TESHarvestEvent::ItemHarvested>
{
virtual BSEventNotifyControl ProcessEvent(const TESHarvestEvent::ItemHarvested& a_event, BSTEventSource<TESHarvestEvent::ItemHarvested>*) override
{
if (a_event.harvestedBy == PlayerCharacter::GetSingleton())
{
DEBUG("Harvest event sent by player, harvested REFR: {}, harvest object: {}", a_event.referenceHarvested->GetFormEditorID(), a_event.itemHarvested->GetFormEditorID());
const char* itemHarvested = a_event.itemHarvested->GetFormEditorID();

if (strcmp(itemHarvested, "CAS_LL_WoodPile_Random") == 0)
{
SendHUDMessage::ShowHUDMessage("Firewood Added.", nullptr, true, true);
}
else
{
return BSEventNotifyControl::kContinue;
}

}

return BSEventNotifyControl::kContinue;
}
};

void RegisterTESHarvestEventSink()
{
TESHarvestEventWatcher* tesHarvestEvent = new TESHarvestEventWatcher();
TESHarvestEvent::ItemHarvested::GetEventSource()->RegisterSink(tesHarvestEvent);
INFO("Registered 'TESHarvestEvent::ItemHarvested' sink.");
}
}
}
14 changes: 6 additions & 8 deletions Plugin/src/Menus/PipboyMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ namespace RE
{
if (_stricmp(currentSWFPath.GetString(), "Interface/PipboyMenu.swf") == 0)
{
Scaleform::GFx::Value loader;
Scaleform::GFx::Value urlRequest;
Scaleform::GFx::Value rootValue;
a_view->asMovieRoot->GetVariable(&rootValue, "root");
Scaleform::GFx::Value loader, urlRequest, root;
a_view->asMovieRoot->GetVariable(&root, "root");
a_view->asMovieRoot->CreateObject(&loader, "flash.display.Loader");
Scaleform::GFx::Value newSWFName = "CASPipboy.swf";
a_view->asMovieRoot->CreateObject(&urlRequest, "flash.net.URLRequest", &newSWFName, 1);
rootValue.SetMember("casPipboy_loader", &loader);
Scaleform::GFx::Value pipboy = "CASPipboy.swf";
a_view->asMovieRoot->CreateObject(&urlRequest, "flash.net.URLRequest", &pipboy, 1);
root.SetMember("casPipboy_loader", &loader);
Scaleform::GFx::Value casPipboy;
a_view->asMovieRoot->CreateObject(&casPipboy);
rootValue.SetMember("casPipboy", &casPipboy);
root.SetMember("casPipboy", &casPipboy);
RegisterFunction<PipboyReady>(&casPipboy, a_view->asMovieRoot, "ready");
RegisterFunction<PipboyHideWorkshopTab>(&casPipboy, a_view->asMovieRoot, "IsWorkshopTabHidden");
a_view->asMovieRoot->Invoke("root.casPipboy_loader.load", nullptr, &urlRequest, 1);
Expand Down
4 changes: 3 additions & 1 deletion Plugin/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Events/InputEvent.h"
#include "Events/MenuOpenCloseEvent.h"
#include "Events/TESInitScriptEvent.h"
#include "Events/TESHavestEvent.h"
#include "Events/TESHitEvent.h"
#include "Menus/ExamineConfirmMenu.h"
#include "Menus/PipboyMenu.h"
Expand Down Expand Up @@ -48,8 +49,9 @@ namespace
RE::Cascadia::DefineItemDegradationFormsFromGame();
RE::Cascadia::InputEventReceiverOverride::Install();
RE::Cascadia::BSAnimationGraphEventWatcher::Install();
RE::Cascadia::RegisterTESHitEventSink();
RE::Cascadia::RegisterTESInitScriptEventSink();
RE::Cascadia::RegisterTESHarvestEventSink();
RE::Cascadia::RegisterTESHitEventSink();
break;

case F4SE::MessagingInterface::kGameLoaded:
Expand Down

0 comments on commit 90663c5

Please sign in to comment.