защита, подвижки всякие
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
#ifndef __CORECLR_DELEGATES_H__
|
||||
#define __CORECLR_DELEGATES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define CORECLR_DELEGATE_CALLTYPE __stdcall
|
||||
#ifdef _WCHAR_T_DEFINED
|
||||
typedef wchar_t char_t;
|
||||
#else
|
||||
typedef unsigned short char_t;
|
||||
#endif
|
||||
#else
|
||||
#define CORECLR_DELEGATE_CALLTYPE
|
||||
typedef char char_t;
|
||||
#endif
|
||||
|
||||
#define UNMANAGEDCALLERSONLY_METHOD ((const char_t*)-1)
|
||||
|
||||
// Signature of delegate returned by coreclr_delegate_type::load_assembly_and_get_function_pointer
|
||||
typedef int (CORECLR_DELEGATE_CALLTYPE *load_assembly_and_get_function_pointer_fn)(
|
||||
const char_t *assembly_path /* Fully qualified path to assembly */,
|
||||
const char_t *type_name /* Assembly qualified type name */,
|
||||
const char_t *method_name /* Public static method name compatible with delegateType */,
|
||||
const char_t *delegate_type_name /* Assembly qualified delegate type name or null
|
||||
or UNMANAGEDCALLERSONLY_METHOD if the method is marked with
|
||||
the UnmanagedCallersOnlyAttribute. */,
|
||||
void *reserved /* Extensibility parameter (currently unused and must be 0) */,
|
||||
/*out*/ void **delegate /* Pointer where to store the function pointer result */);
|
||||
|
||||
// Signature of delegate returned by load_assembly_and_get_function_pointer_fn when delegate_type_name == null (default)
|
||||
typedef int (CORECLR_DELEGATE_CALLTYPE *component_entry_point_fn)(void *arg, int32_t arg_size_in_bytes);
|
||||
|
||||
typedef int (CORECLR_DELEGATE_CALLTYPE *get_function_pointer_fn)(
|
||||
const char_t *type_name /* Assembly qualified type name */,
|
||||
const char_t *method_name /* Public static method name compatible with delegateType */,
|
||||
const char_t *delegate_type_name /* Assembly qualified delegate type name or null,
|
||||
or UNMANAGEDCALLERSONLY_METHOD if the method is marked with
|
||||
the UnmanagedCallersOnlyAttribute. */,
|
||||
void *load_context /* Extensibility parameter (currently unused and must be 0) */,
|
||||
void *reserved /* Extensibility parameter (currently unused and must be 0) */,
|
||||
/*out*/ void **delegate /* Pointer where to store the function pointer result */);
|
||||
|
||||
#endif // __CORECLR_DELEGATES_H__
|
||||
@@ -0,0 +1,288 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
#ifndef __HOSTFXR_H__
|
||||
#define __HOSTFXR_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define HOSTFXR_CALLTYPE __cdecl
|
||||
#ifdef _WCHAR_T_DEFINED
|
||||
typedef wchar_t char_t;
|
||||
#else
|
||||
typedef unsigned short char_t;
|
||||
#endif
|
||||
#else
|
||||
#define HOSTFXR_CALLTYPE
|
||||
typedef char char_t;
|
||||
#endif
|
||||
|
||||
enum hostfxr_delegate_type
|
||||
{
|
||||
hdt_com_activation,
|
||||
hdt_load_in_memory_assembly,
|
||||
hdt_winrt_activation,
|
||||
hdt_com_register,
|
||||
hdt_com_unregister,
|
||||
hdt_load_assembly_and_get_function_pointer,
|
||||
hdt_get_function_pointer,
|
||||
};
|
||||
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_main_fn)(const int argc, const char_t **argv);
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_main_startupinfo_fn)(
|
||||
const int argc,
|
||||
const char_t **argv,
|
||||
const char_t *host_path,
|
||||
const char_t *dotnet_root,
|
||||
const char_t *app_path);
|
||||
typedef int32_t(HOSTFXR_CALLTYPE* hostfxr_main_bundle_startupinfo_fn)(
|
||||
const int argc,
|
||||
const char_t** argv,
|
||||
const char_t* host_path,
|
||||
const char_t* dotnet_root,
|
||||
const char_t* app_path,
|
||||
int64_t bundle_header_offset);
|
||||
|
||||
typedef void(HOSTFXR_CALLTYPE *hostfxr_error_writer_fn)(const char_t *message);
|
||||
|
||||
//
|
||||
// Sets a callback which is to be used to write errors to.
|
||||
//
|
||||
// Parameters:
|
||||
// error_writer
|
||||
// A callback function which will be invoked every time an error is to be reported.
|
||||
// Or nullptr to unregister previously registered callback and return to the default behavior.
|
||||
// Return value:
|
||||
// The previously registered callback (which is now unregistered), or nullptr if no previous callback
|
||||
// was registered
|
||||
//
|
||||
// The error writer is registered per-thread, so the registration is thread-local. On each thread
|
||||
// only one callback can be registered. Subsequent registrations overwrite the previous ones.
|
||||
//
|
||||
// By default no callback is registered in which case the errors are written to stderr.
|
||||
//
|
||||
// Each call to the error writer is sort of like writing a single line (the EOL character is omitted).
|
||||
// Multiple calls to the error writer may occure for one failure.
|
||||
//
|
||||
// If the hostfxr invokes functions in hostpolicy as part of its operation, the error writer
|
||||
// will be propagated to hostpolicy for the duration of the call. This means that errors from
|
||||
// both hostfxr and hostpolicy will be reporter through the same error writer.
|
||||
//
|
||||
typedef hostfxr_error_writer_fn(HOSTFXR_CALLTYPE *hostfxr_set_error_writer_fn)(hostfxr_error_writer_fn error_writer);
|
||||
|
||||
typedef void* hostfxr_handle;
|
||||
struct hostfxr_initialize_parameters
|
||||
{
|
||||
size_t size;
|
||||
const char_t *host_path;
|
||||
const char_t *dotnet_root;
|
||||
};
|
||||
|
||||
//
|
||||
// Initializes the hosting components for a dotnet command line running an application
|
||||
//
|
||||
// Parameters:
|
||||
// argc
|
||||
// Number of argv arguments
|
||||
// argv
|
||||
// Command-line arguments for running an application (as if through the dotnet executable).
|
||||
// parameters
|
||||
// Optional. Additional parameters for initialization
|
||||
// host_context_handle
|
||||
// On success, this will be populated with an opaque value representing the initialized host context
|
||||
//
|
||||
// Return value:
|
||||
// Success - Hosting components were successfully initialized
|
||||
// HostInvalidState - Hosting components are already initialized
|
||||
//
|
||||
// This function parses the specified command-line arguments to determine the application to run. It will
|
||||
// then find the corresponding .runtimeconfig.json and .deps.json with which to resolve frameworks and
|
||||
// dependencies and prepare everything needed to load the runtime.
|
||||
//
|
||||
// This function only supports arguments for running an application. It does not support SDK commands.
|
||||
//
|
||||
// This function does not load the runtime.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_initialize_for_dotnet_command_line_fn)(
|
||||
int argc,
|
||||
const char_t **argv,
|
||||
const struct hostfxr_initialize_parameters *parameters,
|
||||
/*out*/ hostfxr_handle *host_context_handle);
|
||||
|
||||
//
|
||||
// Initializes the hosting components using a .runtimeconfig.json file
|
||||
//
|
||||
// Parameters:
|
||||
// runtime_config_path
|
||||
// Path to the .runtimeconfig.json file
|
||||
// parameters
|
||||
// Optional. Additional parameters for initialization
|
||||
// host_context_handle
|
||||
// On success, this will be populated with an opaque value representing the initialized host context
|
||||
//
|
||||
// Return value:
|
||||
// Success - Hosting components were successfully initialized
|
||||
// Success_HostAlreadyInitialized - Config is compatible with already initialized hosting components
|
||||
// Success_DifferentRuntimeProperties - Config has runtime properties that differ from already initialized hosting components
|
||||
// CoreHostIncompatibleConfig - Config is incompatible with already initialized hosting components
|
||||
//
|
||||
// This function will process the .runtimeconfig.json to resolve frameworks and prepare everything needed
|
||||
// to load the runtime. It will only process the .deps.json from frameworks (not any app/component that
|
||||
// may be next to the .runtimeconfig.json).
|
||||
//
|
||||
// This function does not load the runtime.
|
||||
//
|
||||
// If called when the runtime has already been loaded, this function will check if the specified runtime
|
||||
// config is compatible with the existing runtime.
|
||||
//
|
||||
// Both Success_HostAlreadyInitialized and Success_DifferentRuntimeProperties codes are considered successful
|
||||
// initializations. In the case of Success_DifferentRuntimeProperties, it is left to the consumer to verify that
|
||||
// the difference in properties is acceptable.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_initialize_for_runtime_config_fn)(
|
||||
const char_t *runtime_config_path,
|
||||
const struct hostfxr_initialize_parameters *parameters,
|
||||
/*out*/ hostfxr_handle *host_context_handle);
|
||||
|
||||
//
|
||||
// Gets the runtime property value for an initialized host context
|
||||
//
|
||||
// Parameters:
|
||||
// host_context_handle
|
||||
// Handle to the initialized host context
|
||||
// name
|
||||
// Runtime property name
|
||||
// value
|
||||
// Out parameter. Pointer to a buffer with the property value.
|
||||
//
|
||||
// Return value:
|
||||
// The error code result.
|
||||
//
|
||||
// The buffer pointed to by value is owned by the host context. The lifetime of the buffer is only
|
||||
// guaranteed until any of the below occur:
|
||||
// - a 'run' method is called for the host context
|
||||
// - properties are changed via hostfxr_set_runtime_property_value
|
||||
// - the host context is closed via 'hostfxr_close'
|
||||
//
|
||||
// If host_context_handle is nullptr and an active host context exists, this function will get the
|
||||
// property value for the active host context.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_get_runtime_property_value_fn)(
|
||||
const hostfxr_handle host_context_handle,
|
||||
const char_t *name,
|
||||
/*out*/ const char_t **value);
|
||||
|
||||
//
|
||||
// Sets the value of a runtime property for an initialized host context
|
||||
//
|
||||
// Parameters:
|
||||
// host_context_handle
|
||||
// Handle to the initialized host context
|
||||
// name
|
||||
// Runtime property name
|
||||
// value
|
||||
// Value to set
|
||||
//
|
||||
// Return value:
|
||||
// The error code result.
|
||||
//
|
||||
// Setting properties is only supported for the first host context, before the runtime has been loaded.
|
||||
//
|
||||
// If the property already exists in the host context, it will be overwritten. If value is nullptr, the
|
||||
// property will be removed.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_set_runtime_property_value_fn)(
|
||||
const hostfxr_handle host_context_handle,
|
||||
const char_t *name,
|
||||
const char_t *value);
|
||||
|
||||
//
|
||||
// Gets all the runtime properties for an initialized host context
|
||||
//
|
||||
// Parameters:
|
||||
// host_context_handle
|
||||
// Handle to the initialized host context
|
||||
// count
|
||||
// [in] Size of the keys and values buffers
|
||||
// [out] Number of properties returned (size of keys/values buffers used). If the input value is too
|
||||
// small or keys/values is nullptr, this is populated with the number of available properties
|
||||
// keys
|
||||
// Array of pointers to buffers with runtime property keys
|
||||
// values
|
||||
// Array of pointers to buffers with runtime property values
|
||||
//
|
||||
// Return value:
|
||||
// The error code result.
|
||||
//
|
||||
// The buffers pointed to by keys and values are owned by the host context. The lifetime of the buffers is only
|
||||
// guaranteed until any of the below occur:
|
||||
// - a 'run' method is called for the host context
|
||||
// - properties are changed via hostfxr_set_runtime_property_value
|
||||
// - the host context is closed via 'hostfxr_close'
|
||||
//
|
||||
// If host_context_handle is nullptr and an active host context exists, this function will get the
|
||||
// properties for the active host context.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_get_runtime_properties_fn)(
|
||||
const hostfxr_handle host_context_handle,
|
||||
/*inout*/ size_t * count,
|
||||
/*out*/ const char_t **keys,
|
||||
/*out*/ const char_t **values);
|
||||
|
||||
//
|
||||
// Load CoreCLR and run the application for an initialized host context
|
||||
//
|
||||
// Parameters:
|
||||
// host_context_handle
|
||||
// Handle to the initialized host context
|
||||
//
|
||||
// Return value:
|
||||
// If the app was successfully run, the exit code of the application. Otherwise, the error code result.
|
||||
//
|
||||
// The host_context_handle must have been initialized using hostfxr_initialize_for_dotnet_command_line.
|
||||
//
|
||||
// This function will not return until the managed application exits.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_run_app_fn)(const hostfxr_handle host_context_handle);
|
||||
|
||||
//
|
||||
// Gets a typed delegate from the currently loaded CoreCLR or from a newly created one.
|
||||
//
|
||||
// Parameters:
|
||||
// host_context_handle
|
||||
// Handle to the initialized host context
|
||||
// type
|
||||
// Type of runtime delegate requested
|
||||
// delegate
|
||||
// An out parameter that will be assigned the delegate.
|
||||
//
|
||||
// Return value:
|
||||
// The error code result.
|
||||
//
|
||||
// If the host_context_handle was initialized using hostfxr_initialize_for_runtime_config,
|
||||
// then all delegate types are supported.
|
||||
// If the host_context_handle was initialized using hostfxr_initialize_for_dotnet_command_line,
|
||||
// then only the following delegate types are currently supported:
|
||||
// hdt_load_assembly_and_get_function_pointer
|
||||
// hdt_get_function_pointer
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_get_runtime_delegate_fn)(
|
||||
const hostfxr_handle host_context_handle,
|
||||
enum hostfxr_delegate_type type,
|
||||
/*out*/ void **delegate);
|
||||
|
||||
//
|
||||
// Closes an initialized host context
|
||||
//
|
||||
// Parameters:
|
||||
// host_context_handle
|
||||
// Handle to the initialized host context
|
||||
//
|
||||
// Return value:
|
||||
// The error code result.
|
||||
//
|
||||
typedef int32_t(HOSTFXR_CALLTYPE *hostfxr_close_fn)(const hostfxr_handle host_context_handle);
|
||||
|
||||
#endif //__HOSTFXR_H__
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Unreal Engine .NET 5 integration
|
||||
* Copyright (c) 2021 Stanislav Denisov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "UnrealCLRLibrary.h"
|
||||
|
||||
FManagedFunction::FManagedFunction() : Pointer() { }
|
||||
|
||||
UUnrealCLRLibrary::UUnrealCLRLibrary(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { }
|
||||
|
||||
void UUnrealCLRLibrary::ExecuteManagedFunction(FManagedFunction ManagedFunction, UObject* Object = nullptr) {
|
||||
if (UnrealCLR::Status == UnrealCLR::StatusType::Running && ManagedFunction.Pointer)
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(ManagedFunction.Pointer, Object));
|
||||
}
|
||||
|
||||
FManagedFunction UUnrealCLRLibrary::FindManagedFunction(FString Method, bool Optional, bool& Result) {
|
||||
FManagedFunction managedFunction;
|
||||
|
||||
if (UnrealCLR::Status == UnrealCLR::StatusType::Running && !Method.IsEmpty())
|
||||
managedFunction.Pointer = UnrealCLR::ManagedCommand(UnrealCLR::Command(TCHAR_TO_ANSI(*Method), Optional));
|
||||
|
||||
Result = managedFunction.Pointer != nullptr;
|
||||
|
||||
return managedFunction;
|
||||
}
|
||||
|
||||
UUnrealCLRCharacter::UUnrealCLRCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { }
|
||||
|
||||
void UUnrealCLRCharacter::Landed(const FHitResult& Hit) {
|
||||
UnrealCLRFramework::Hit hit(Hit);
|
||||
|
||||
void* parameters[1] = {
|
||||
&hit
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(LandedCallback, UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::CharacterLandedDelegate)));
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Unreal Engine .NET 5 integration
|
||||
* Copyright (c) 2021 Stanislav Denisov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "UnrealCLRManager.h"
|
||||
|
||||
void UUnrealCLRManager::ActorBeginOverlap(AActor* OverlapActor, AActor* OtherActor) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorBeginOverlap]) {
|
||||
void* parameters[2] = {
|
||||
OverlapActor,
|
||||
OtherActor
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorBeginOverlap], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorOverlapDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ActorEndOverlap(AActor* OverlapActor, AActor* OtherActor) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorEndOverlap]) {
|
||||
void* parameters[2] = {
|
||||
OverlapActor,
|
||||
OtherActor
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorEndOverlap], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorOverlapDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ActorHit(AActor* HitActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorHit]) {
|
||||
UnrealCLRFramework::Vector3 normalImpulse(NormalImpulse);
|
||||
UnrealCLRFramework::Hit hit(Hit);
|
||||
|
||||
void* parameters[4] = {
|
||||
HitActor,
|
||||
OtherActor,
|
||||
&normalImpulse,
|
||||
&hit
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorHit], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorHitDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ActorBeginCursorOver(AActor* Actor) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorBeginCursorOver]) {
|
||||
void* parameters[1] = {
|
||||
Actor
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorBeginCursorOver], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorCursorDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ActorEndCursorOver(AActor* Actor) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorEndCursorOver]) {
|
||||
void* parameters[1] = {
|
||||
Actor
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorEndCursorOver], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorCursorDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ActorClicked(AActor* Actor, FKey Key) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorClicked]) {
|
||||
FString key = Key.ToString();
|
||||
|
||||
void* parameters[2] = {
|
||||
Actor,
|
||||
TCHAR_TO_ANSI(*key)
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorClicked], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorKeyDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ActorReleased(AActor* Actor, FKey Key) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorReleased]) {
|
||||
FString key = Key.ToString();
|
||||
|
||||
void* parameters[2] = {
|
||||
Actor,
|
||||
TCHAR_TO_ANSI(*key)
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnActorReleased], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ActorKeyDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentBeginOverlap(UPrimitiveComponent* OverlapComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnComponentBeginOverlap]) {
|
||||
void* parameters[2] = {
|
||||
OverlapComponent,
|
||||
OtherComponent
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentBeginOverlap], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentOverlapDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentEndOverlap(UPrimitiveComponent* OverlapComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnComponentEndOverlap]) {
|
||||
void* parameters[2] = {
|
||||
OverlapComponent,
|
||||
OtherComponent
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentEndOverlap], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentOverlapDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnComponentHit]) {
|
||||
UnrealCLRFramework::Vector3 normalImpulse(NormalImpulse);
|
||||
UnrealCLRFramework::Hit hit(Hit);
|
||||
|
||||
void* parameters[4] = {
|
||||
HitComponent,
|
||||
OtherComponent,
|
||||
&normalImpulse,
|
||||
&hit
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentHit], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentHitDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentBeginCursorOver(UPrimitiveComponent* Component) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnActorBeginCursorOver]) {
|
||||
void* parameters[1] = {
|
||||
Component
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentBeginCursorOver], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentCursorDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentEndCursorOver(UPrimitiveComponent* Component) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnComponentEndCursorOver]) {
|
||||
void* parameters[1] = {
|
||||
Component
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentEndCursorOver], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentCursorDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentClicked(UPrimitiveComponent* Component, FKey Key) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnComponentClicked]) {
|
||||
FString key = Key.ToString();
|
||||
|
||||
void* parameters[2] = {
|
||||
Component,
|
||||
TCHAR_TO_ANSI(*key)
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentClicked], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentKeyDelegate)));
|
||||
}
|
||||
}
|
||||
|
||||
void UUnrealCLRManager::ComponentReleased(UPrimitiveComponent* Component, FKey Key) {
|
||||
if (UnrealCLR::Shared::Events[UnrealCLR::OnComponentReleased]) {
|
||||
FString key = Key.ToString();
|
||||
|
||||
void* parameters[2] = {
|
||||
Component,
|
||||
TCHAR_TO_ANSI(*key)
|
||||
};
|
||||
|
||||
UnrealCLR::ManagedCommand(UnrealCLR::Command(UnrealCLR::Shared::Events[UnrealCLR::OnComponentReleased], UnrealCLR::Callback(parameters, UnrealCLR::CallbackType::ComponentKeyDelegate)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
/*
|
||||
* Unreal Engine .NET 5 integration
|
||||
* Copyright (c) 2021 Stanislav Denisov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// @third party code - BEGIN CoreCLR
|
||||
#include "../../Dependencies/CoreCLR/includes/coreclr_delegates.h"
|
||||
#include "../../Dependencies/CoreCLR/includes/hostfxr.h"
|
||||
// @third party code - END CoreCLR
|
||||
|
||||
#include "AIController.h"
|
||||
#include "Animation/AnimInstance.h"
|
||||
#include "AssetRegistryModule.h"
|
||||
#include "Camera/CameraActor.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/AudioComponent.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/DirectionalLightComponent.h"
|
||||
#include "Components/HierarchicalInstancedStaticMeshComponent.h"
|
||||
#include "Components/InputComponent.h"
|
||||
#include "Components/LightComponent.h"
|
||||
#include "Components/LightComponentBase.h"
|
||||
#include "Components/PostProcessComponent.h"
|
||||
#include "Components/ShapeComponent.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "Components/SplineComponent.h"
|
||||
#include "Components/TextRenderComponent.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Engine/DirectionalLight.h"
|
||||
#include "Engine/Font.h"
|
||||
#include "Engine/GameEngine.h"
|
||||
#include "Engine/LevelScriptActor.h"
|
||||
#include "Engine/Light.h"
|
||||
#include "Engine/Player.h"
|
||||
#include "Engine/PointLight.h"
|
||||
#include "Engine/PostProcessVolume.h"
|
||||
#include "Engine/RectLight.h"
|
||||
#include "Engine/SpotLight.h"
|
||||
#include "Engine/TriggerBox.h"
|
||||
#include "Engine/TriggerCapsule.h"
|
||||
#include "Engine/TriggerSphere.h"
|
||||
#include "Engine/TriggerVolume.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/GameModeBase.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "GameFramework/PlayerInput.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "HeadMountedDisplayFunctionLibrary.h"
|
||||
#include "IAssetRegistry.h"
|
||||
#include "ImageUtils.h"
|
||||
#include "Materials/MaterialInstanceDynamic.h"
|
||||
#include "Misc/DefaultValueHelper.h"
|
||||
#include "Misc/OutputDeviceNull.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "MotionControllerComponent.h"
|
||||
#include "PhysicsEngine/RadialForceComponent.h"
|
||||
#include "Sound/AmbientSound.h"
|
||||
#include "UnrealEngine.h"
|
||||
|
||||
#include "UnrealCLRFramework.h"
|
||||
#include "UnrealCLRLibrary.h"
|
||||
#include "UnrealCLRManager.h"
|
||||
|
||||
#if WITH_EDITOR
|
||||
#include "Editor.h"
|
||||
#include "Framework/Notifications/NotificationManager.h"
|
||||
#include "Widgets/Notifications/SNotificationList.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define UNREALCLR_WINDOWS 1
|
||||
#elif defined(__unix__)
|
||||
#define UNREALCLR_UNIX 2
|
||||
#elif defined(__APPLE__)
|
||||
#define UNREALCLR_MAC 3
|
||||
#endif
|
||||
|
||||
#define UNREALCLR_NONE
|
||||
#define UNREALCLR_BRACKET_LEFT (
|
||||
#define UNREALCLR_BRACKET_RIGHT )
|
||||
|
||||
UNREALCLR_API DECLARE_LOG_CATEGORY_EXTERN(LogUnrealCLR, Log, All);
|
||||
|
||||
namespace UnrealCLR {
|
||||
enum struct StatusType : int32 {
|
||||
Stopped,
|
||||
Idle,
|
||||
Running
|
||||
};
|
||||
|
||||
enum struct TickState : int32 {
|
||||
Stopped,
|
||||
Registered,
|
||||
Started
|
||||
};
|
||||
|
||||
enum struct LogLevel : int32 {
|
||||
Display,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal
|
||||
};
|
||||
|
||||
enum struct CallbackType : int32 {
|
||||
ActorOverlapDelegate,
|
||||
ActorHitDelegate,
|
||||
ActorCursorDelegate,
|
||||
ActorKeyDelegate,
|
||||
ComponentOverlapDelegate,
|
||||
ComponentHitDelegate,
|
||||
ComponentCursorDelegate,
|
||||
ComponentKeyDelegate,
|
||||
CharacterLandedDelegate
|
||||
};
|
||||
|
||||
enum struct ArgumentType : int32 {
|
||||
None,
|
||||
Single,
|
||||
Integer,
|
||||
Pointer,
|
||||
Callback
|
||||
};
|
||||
|
||||
enum struct CommandType : int32 {
|
||||
Initialize = 1,
|
||||
LoadAssemblies = 2,
|
||||
UnloadAssemblies = 3,
|
||||
Find = 4,
|
||||
Execute = 5
|
||||
};
|
||||
|
||||
enum {
|
||||
OnWorldBegin,
|
||||
OnWorldPostBegin,
|
||||
OnWorldPrePhysicsTick,
|
||||
OnWorldDuringPhysicsTick,
|
||||
OnWorldPostPhysicsTick,
|
||||
OnWorldPostUpdateTick,
|
||||
OnWorldEnd,
|
||||
OnActorBeginOverlap,
|
||||
OnActorEndOverlap,
|
||||
OnActorHit,
|
||||
OnActorBeginCursorOver,
|
||||
OnActorEndCursorOver,
|
||||
OnActorClicked,
|
||||
OnActorReleased,
|
||||
OnComponentBeginOverlap,
|
||||
OnComponentEndOverlap,
|
||||
OnComponentHit,
|
||||
OnComponentBeginCursorOver,
|
||||
OnComponentEndCursorOver,
|
||||
OnComponentClicked,
|
||||
OnComponentReleased
|
||||
};
|
||||
|
||||
struct Callback {
|
||||
void** Parameters;
|
||||
CallbackType Type;
|
||||
|
||||
FORCEINLINE Callback(void** Parameters, CallbackType Type) {
|
||||
this->Parameters = Parameters;
|
||||
this->Type = Type;
|
||||
}
|
||||
};
|
||||
|
||||
struct Argument {
|
||||
union {
|
||||
float Single;
|
||||
uint32_t Integer;
|
||||
void* Pointer;
|
||||
Callback Callback;
|
||||
};
|
||||
ArgumentType Type;
|
||||
|
||||
FORCEINLINE Argument(float Value) {
|
||||
this->Single = Value;
|
||||
this->Type = ArgumentType::Single;
|
||||
}
|
||||
|
||||
FORCEINLINE Argument(uint32_t Value) {
|
||||
this->Integer = Value;
|
||||
this->Type = ArgumentType::Integer;
|
||||
}
|
||||
|
||||
FORCEINLINE Argument(void* Value) {
|
||||
this->Pointer = Value;
|
||||
this->Type = !Value ? ArgumentType::None : ArgumentType::Pointer;
|
||||
}
|
||||
|
||||
FORCEINLINE Argument(UnrealCLR::Callback Value) {
|
||||
this->Callback = Value;
|
||||
this->Type = ArgumentType::Callback;
|
||||
}
|
||||
};
|
||||
|
||||
struct Command {
|
||||
union {
|
||||
struct {
|
||||
void* Buffer;
|
||||
int32 Checksum;
|
||||
};
|
||||
struct {
|
||||
char* Method;
|
||||
int32 Optional;
|
||||
};
|
||||
struct {
|
||||
void* Function;
|
||||
Argument Value;
|
||||
};
|
||||
};
|
||||
CommandType Type;
|
||||
|
||||
FORCEINLINE Command(void* const Functions[3], int32 Checksum) {
|
||||
this->Buffer = (void*)Functions;
|
||||
this->Checksum = Checksum;
|
||||
this->Type = CommandType::Initialize;
|
||||
}
|
||||
|
||||
FORCEINLINE Command(CommandType Type) {
|
||||
this->Type = Type;
|
||||
}
|
||||
|
||||
FORCEINLINE Command(const char* Method, bool Optional) {
|
||||
this->Method = (char*)Method;
|
||||
this->Optional = Optional;
|
||||
this->Type = CommandType::Find;
|
||||
}
|
||||
|
||||
FORCEINLINE Command(void* Function) {
|
||||
this->Function = Function;
|
||||
this->Value = nullptr;
|
||||
this->Type = CommandType::Execute;
|
||||
}
|
||||
|
||||
FORCEINLINE Command(void* Function, Argument Value) {
|
||||
this->Function = Function;
|
||||
this->Value = Value;
|
||||
this->Type = CommandType::Execute;
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(Callback) == 16, "Invalid size of the [Callback] structure");
|
||||
static_assert(sizeof(Argument) == 24, "Invalid size of the [Argument] structure");
|
||||
static_assert(sizeof(Command) == 40, "Invalid size of the [Command] structure");
|
||||
|
||||
static void* (*ManagedCommand)(Command);
|
||||
|
||||
static FString ProjectPath;
|
||||
static FString UserAssembliesPath;
|
||||
|
||||
static StatusType Status = StatusType::Stopped;
|
||||
static TickState WorldTickState = TickState::Stopped;
|
||||
|
||||
struct PrePhysicsTickFunction : public FTickFunction {
|
||||
virtual void ExecuteTick(float DeltaTime, enum ELevelTick TickType, ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) override;
|
||||
virtual FString DiagnosticMessage() override;
|
||||
};
|
||||
|
||||
struct DuringPhysicsTickFunction : public FTickFunction {
|
||||
virtual void ExecuteTick(float DeltaTime, enum ELevelTick TickType, ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) override;
|
||||
virtual FString DiagnosticMessage() override;
|
||||
};
|
||||
|
||||
struct PostPhysicsTickFunction : public FTickFunction {
|
||||
virtual void ExecuteTick(float DeltaTime, enum ELevelTick TickType, ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) override;
|
||||
virtual FString DiagnosticMessage() override;
|
||||
};
|
||||
|
||||
struct PostUpdateTickFunction : public FTickFunction {
|
||||
virtual void ExecuteTick(float DeltaTime, enum ELevelTick TickType, ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) override;
|
||||
virtual FString DiagnosticMessage() override;
|
||||
};
|
||||
|
||||
class Module : public IModuleInterface {
|
||||
protected:
|
||||
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
|
||||
void OnWorldPostInitialization(UWorld* World, const UWorld::InitializationValues InitializationValues);
|
||||
void OnWorldCleanup(UWorld* World, bool SessionEnded, bool CleanupResources);
|
||||
|
||||
static void RegisterTickFunction(FTickFunction& TickFunction, ETickingGroup TickGroup, AWorldSettings* LevelActor);
|
||||
static void HostError(const char_t* Message);
|
||||
static void Exception(const char* Message);
|
||||
static void Log(UnrealCLR::LogLevel Level, const char* Message);
|
||||
|
||||
FDelegateHandle OnWorldPostInitializationHandle;
|
||||
FDelegateHandle OnWorldCleanupHandle;
|
||||
|
||||
PrePhysicsTickFunction OnPrePhysicsTickFunction;
|
||||
DuringPhysicsTickFunction OnDuringPhysicsTickFunction;
|
||||
PostPhysicsTickFunction OnPostPhysicsTickFunction;
|
||||
PostUpdateTickFunction OnPostUpdateTickFunction;
|
||||
|
||||
void* HostfxrLibrary;
|
||||
};
|
||||
|
||||
namespace Engine {
|
||||
static UUnrealCLRManager* Manager;
|
||||
static UWorld* World;
|
||||
}
|
||||
|
||||
namespace Shared {
|
||||
constexpr static int32 storageSize = 128;
|
||||
|
||||
// Non-instantiable
|
||||
|
||||
static void* AssertFunctions[storageSize];
|
||||
static void* CommandLineFunctions[storageSize];
|
||||
static void* DebugFunctions[storageSize];
|
||||
static void* ObjectFunctions[storageSize];
|
||||
static void* ApplicationFunctions[storageSize];
|
||||
static void* ConsoleManagerFunctions[storageSize];
|
||||
static void* EngineFunctions[storageSize];
|
||||
static void* WorldFunctions[storageSize];
|
||||
|
||||
// Instantiable
|
||||
|
||||
static void* AssetFunctions[storageSize];
|
||||
static void* AssetRegistryFunctions[storageSize];
|
||||
static void* BlueprintFunctions[storageSize];
|
||||
static void* ConsoleObjectFunctions[storageSize];
|
||||
static void* ConsoleVariableFunctions[storageSize];
|
||||
static void* ActorFunctions[storageSize];
|
||||
static void* GameModeBaseFunctions[storageSize];
|
||||
static void* PawnFunctions[storageSize];
|
||||
static void* CharacterFunctions[storageSize];
|
||||
static void* ControllerFunctions[storageSize];
|
||||
static void* AIControllerFunctions[storageSize];
|
||||
static void* PlayerControllerFunctions[storageSize];
|
||||
static void* VolumeFunctions[storageSize];
|
||||
static void* PostProcessVolumeFunctions[storageSize];
|
||||
static void* SoundBaseFunctions[storageSize];
|
||||
static void* SoundWaveFunctions[storageSize];
|
||||
static void* AnimationInstanceFunctions[storageSize];
|
||||
static void* PlayerFunctions[storageSize];
|
||||
static void* PlayerInputFunctions[storageSize];
|
||||
static void* FontFunctions[storageSize];
|
||||
static void* Texture2DFunctions[storageSize];
|
||||
static void* ActorComponentFunctions[storageSize];
|
||||
static void* InputComponentFunctions[storageSize];
|
||||
static void* SceneComponentFunctions[storageSize];
|
||||
static void* AudioComponentFunctions[storageSize];
|
||||
static void* CameraComponentFunctions[storageSize];
|
||||
static void* ChildActorComponentFunctions[storageSize];
|
||||
static void* SpringArmComponentFunctions[storageSize];
|
||||
static void* PostProcessComponentFunctions[storageSize];
|
||||
static void* PrimitiveComponentFunctions[storageSize];
|
||||
static void* ShapeComponentFunctions[storageSize];
|
||||
static void* BoxComponentFunctions[storageSize];
|
||||
static void* SphereComponentFunctions[storageSize];
|
||||
static void* CapsuleComponentFunctions[storageSize];
|
||||
static void* MeshComponentFunctions[storageSize];
|
||||
static void* TextRenderComponentFunctions[storageSize];
|
||||
static void* LightComponentBaseFunctions[storageSize];
|
||||
static void* LightComponentFunctions[storageSize];
|
||||
static void* MotionControllerComponentFunctions[storageSize];
|
||||
static void* StaticMeshComponentFunctions[storageSize];
|
||||
static void* InstancedStaticMeshComponentFunctions[storageSize];
|
||||
static void* HierarchicalInstancedStaticMeshComponentFunctions[storageSize];
|
||||
static void* SkinnedMeshComponentFunctions[storageSize];
|
||||
static void* SkeletalMeshComponentFunctions[storageSize];
|
||||
static void* SplineComponentFunctions[storageSize];
|
||||
static void* RadialForceComponentFunctions[storageSize];
|
||||
static void* MaterialInterfaceFunctions[storageSize];
|
||||
static void* MaterialFunctions[storageSize];
|
||||
static void* MaterialInstanceFunctions[storageSize];
|
||||
static void* MaterialInstanceDynamicFunctions[storageSize];
|
||||
static void* HeadMountedDisplayFunctions[storageSize];
|
||||
|
||||
static void* RuntimeFunctions[2];
|
||||
static void* Events[128];
|
||||
static void* Functions[128];
|
||||
}
|
||||
|
||||
namespace Utility {
|
||||
FORCEINLINE static size_t Strcpy(char* Destination, const char* Source, size_t Length);
|
||||
FORCEINLINE static size_t Strlen(const char* Source);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Unreal Engine .NET 5 integration
|
||||
* Copyright (c) 2021 Stanislav Denisov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "UnrealCLRLibrary.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct UNREALCLR_API FManagedFunction {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
void* Pointer;
|
||||
|
||||
FManagedFunction();
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UNREALCLR_API UUnrealCLRLibrary : public UBlueprintFunctionLibrary {
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = ".NET", meta = (ToolTip = "Executes the managed function with optional object reference argument"))
|
||||
static void ExecuteManagedFunction(FManagedFunction ManagedFunction, UObject* Object);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = ".NET", meta = (ToolTip = "Finds the managed function from loaded assembly, optional parameter suppresses errors if the function was not found"))
|
||||
static FManagedFunction FindManagedFunction(FString Method, bool Optional, bool& Result);
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UNREALCLR_API UUnrealCLRCharacter : public UObject {
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
public:
|
||||
|
||||
void* LandedCallback;
|
||||
|
||||
UFUNCTION()
|
||||
void Landed(const FHitResult& Hit);
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Unreal Engine .NET 5 integration
|
||||
* Copyright (c) 2021 Stanislav Denisov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "UnrealCLRManager.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UNREALCLR_API UUnrealCLRManager : public UObject {
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION()
|
||||
void ActorBeginOverlap(AActor* OverlapActor, AActor* OtherActor);
|
||||
|
||||
UFUNCTION()
|
||||
void ActorEndOverlap(AActor* OverlapActor, AActor* OtherActor);
|
||||
|
||||
UFUNCTION()
|
||||
void ActorHit(AActor* HitActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit);
|
||||
|
||||
UFUNCTION()
|
||||
void ActorBeginCursorOver(AActor* Actor);
|
||||
|
||||
UFUNCTION()
|
||||
void ActorEndCursorOver(AActor* Actor);
|
||||
|
||||
UFUNCTION()
|
||||
void ActorClicked(AActor* Actor, FKey Button);
|
||||
|
||||
UFUNCTION()
|
||||
void ActorReleased(AActor* Actor, FKey Button);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentBeginOverlap(UPrimitiveComponent* OverlapComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex, bool FromSweep, const FHitResult& SweepResult);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentEndOverlap(UPrimitiveComponent* OverlapComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, int32 OtherBodyIndex);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentBeginCursorOver(UPrimitiveComponent* Component);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentEndCursorOver(UPrimitiveComponent* Component);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentClicked(UPrimitiveComponent* Component, FKey Key);
|
||||
|
||||
UFUNCTION()
|
||||
void ComponentReleased(UPrimitiveComponent* Component, FKey Key);
|
||||
};
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Unreal Engine .NET 5 integration
|
||||
* Copyright (c) 2021 Stanislav Denisov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class UnrealCLR : ModuleRules {
|
||||
public UnrealCLR(ReadOnlyTargetRules Target) : base(Target) {
|
||||
#if UE_4_24_OR_LATER
|
||||
bLegacyPublicIncludePaths = false;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V2;
|
||||
#else
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
#endif
|
||||
|
||||
PublicIncludePaths.AddRange(new string[] { });
|
||||
|
||||
PrivateIncludePaths.AddRange(new string[] { });
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] {
|
||||
"Core"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] {
|
||||
"AIModule",
|
||||
"AssetRegistry",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"HeadMountedDisplay",
|
||||
"InputCore",
|
||||
"Slate",
|
||||
"SlateCore"
|
||||
});
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(new string[] { });
|
||||
|
||||
if (Target.bBuildEditor) {
|
||||
PrivateDependencyModuleNames.AddRange(new string[] {
|
||||
"UnrealEd"
|
||||
});
|
||||
} else {
|
||||
string runtimePath = null;
|
||||
|
||||
if (Target.Platform == UnrealTargetPlatform.Win64)
|
||||
runtimePath = Path.Combine(ModuleDirectory, "../../Runtime/Win64");
|
||||
else if (Target.Platform == UnrealTargetPlatform.Linux)
|
||||
runtimePath = Path.Combine(ModuleDirectory, "../../Runtime/Linux");
|
||||
else if (Target.Platform == UnrealTargetPlatform.Mac)
|
||||
runtimePath = Path.Combine(ModuleDirectory, "../../Runtime/Mac");
|
||||
else
|
||||
throw new Exception("Unknown platform");
|
||||
|
||||
string[] files = Directory.GetFiles(runtimePath, "*.*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files) {
|
||||
RuntimeDependencies.Add(file);
|
||||
}
|
||||
|
||||
files = Directory.GetFiles(Path.Combine(ModuleDirectory, "../../Managed"), "*.*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files) {
|
||||
RuntimeDependencies.Add(file);
|
||||
}
|
||||
|
||||
string userAssemblies = Path.Combine(PluginDirectory , "../../Managed");
|
||||
|
||||
if (Directory.Exists(userAssemblies)) {
|
||||
files = Directory.GetFiles(userAssemblies, "*.*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string file in files) {
|
||||
RuntimeDependencies.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user