-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
606 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public native class EntityBuilderEvent extends CallbackSystemEvent { | ||
public native func GetEntityBuilder() -> ref<EntityBuilderWrapper> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
public native class EntityBuilderWrapper { | ||
public native func HasEntity() -> Bool | ||
public native func HasAppearance() -> Bool | ||
public native func HasCustomAppearances() -> Bool | ||
public native func GetRecordID() -> TweakDBID | ||
public native func GetTemplatePath() -> ResRef | ||
public native func GetAppearanceName() -> CName | ||
public native func GetEntityID() -> EntityID | ||
public native func GetEntityType() -> CName | ||
public native func GetEntityParams() -> ref<entEntityParametersStorage> | ||
public native func GetTemplate() -> ref<EntityBuilderTemplateWrapper> | ||
public native func GetAppearance() -> ref<EntityBuilderAppearanceWrapper> | ||
public native func GetCustomAppearances() -> array<ref<EntityBuilderAppearanceWrapper>> | ||
} | ||
|
||
public native class EntityBuilderTemplateWrapper { | ||
public native func GetResource() -> ref<entEntityTemplate> | ||
public native func GetAppearanceName() -> CName | ||
public native func GetEntity() -> ref<Entity> | ||
public native func GetComponents() -> array<ref<IComponent>> | ||
public native func AddComponent(component: ref<IComponent>) | ||
} | ||
|
||
public native class EntityBuilderAppearanceWrapper { | ||
public native func GetResource() -> ref<appearanceAppearanceResource> | ||
public native func GetDefinition() -> ref<appearanceAppearanceDefinition> | ||
public native func GetComponents() -> array<ref<IComponent>> | ||
public native func AddComponent(component: ref<IComponent>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
#include "App/Callback/CallbackSystem.hpp" | ||
#include "App/Callback/CallbackSystemController.hpp" | ||
#include "App/Callback/Events/EntityBuilderEvent.hpp" | ||
#include "Core/Hooking/HookingAgent.hpp" | ||
#include "Red/EntityBuilder.hpp" | ||
|
||
namespace App | ||
{ | ||
class EntityExtractHook | ||
: public CallbackSystemController | ||
, public Core::HookingAgent | ||
{ | ||
public: | ||
constexpr static auto EventName = Red::CName("Entity/Extract"); | ||
|
||
Core::Map<Red::CName, Red::CName> GetEvents() override | ||
{ | ||
return {{EventName, Red::GetTypeName<EntityBuilderEvent>()}}; | ||
} | ||
|
||
protected: | ||
bool OnActivateHook() override | ||
{ | ||
return IsHooked<Raw::EntityBuilder::ExtractComponentsJob>() | ||
|| HookBefore<Raw::EntityBuilder::ExtractComponentsJob>(&OnExtractComponentsJob); | ||
} | ||
|
||
bool OnDeactivateHook() override | ||
{ | ||
return !IsHooked<Raw::EntityBuilder::ExtractComponentsJob>() | ||
|| Unhook<Raw::EntityBuilder::ExtractComponentsJob>(); | ||
} | ||
|
||
inline static void OnExtractComponentsJob(Red::EntityBuilderJobParams* aParams, void*) | ||
{ | ||
if (!aParams->entityBuilderWeak.Expired()) | ||
{ | ||
CallbackSystem::Get()->DispatchNativeEvent<EntityBuilderEvent>(EventName, aParams->entityBuilderWeak); | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "App/Callback/CallbackSystemEvent.hpp" | ||
#include "App/Entity/EntityBuilderWrapper.hpp" | ||
|
||
namespace App | ||
{ | ||
struct EntityBuilderEvent : CallbackSystemEvent | ||
{ | ||
EntityBuilderEvent() = default; | ||
|
||
EntityBuilderEvent(Red::CName aName, const Red::WeakPtr<Red::EntityBuilder>& aEntityBuilder) | ||
: CallbackSystemEvent(aName) | ||
, entityBuilder(Red::MakeHandle<EntityBuilderWrapper>(aEntityBuilder)) | ||
{ | ||
} | ||
|
||
Red::Handle<EntityBuilderWrapper> entityBuilder; | ||
|
||
RTTI_IMPL_TYPEINFO(App::EntityBuilderEvent); | ||
RTTI_IMPL_ALLOCATOR(); | ||
}; | ||
} | ||
|
||
RTTI_DEFINE_CLASS(App::EntityBuilderEvent, { | ||
RTTI_PARENT(App::CallbackSystemEvent); | ||
RTTI_GETTER(entityBuilder); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.