C# Entity Scrips now working(OnInit, update, destroy) [ Broke reloading]

- added UI button to generate a .sln in the games folder
- added UI for adding new component and drag n drop .cs file
- added modular Core API module system
This commit is contained in:
Antoine Pilote
2023-10-16 00:21:28 -04:00
parent 9807f0fa8f
commit af2546fb21
21 changed files with 677 additions and 50 deletions

View File

@@ -1,22 +1,44 @@
#pragma once
#include "src/Core/Core.h"
#include "src/Scene/Entities/Entity.h"
#include "src/Scripting/NetModules/NetAPIModule.h"
namespace Coral
{
class HostInstance;
class AssemblyLoadContext;
class Type;
}
namespace Nuake
{
#include <Coral/Assembly.hpp>
namespace Nuake {
class Project;
class ScriptingEngineNet
{
private:
const std::string m_Scope = "Nuake.Net";
const std::string m_EngineAssemblyName = "NuakeNet.dll";
const std::string m_NetDirectory = ".net";
const std::string m_ContextName = "NuakeEngineContext";
Coral::HostInstance* m_HostInstance;
Coral::AssemblyLoadContext* m_LoadContext;
Coral::AssemblyLoadContext m_LoadContext;
std::unordered_map<std::string, Coral::AssemblyLoadContext*> m_LoadedAssemblies;
std::vector<Ref<NetAPIModule>> m_Modules;
Coral::ManagedAssembly m_NuakeAssembly; // Nuake DLL
Coral::ManagedAssembly m_GameAssembly; // Game DLL
// This is a map of all the entity scripts detected in the game's assembly.
// This is filled when loading the game's assembly.
// This is a map that contains all the instances of entity scripts.
std::unordered_map<std::string, Coral::Type*> m_GameEntityTypes;
std::unordered_map<uint32_t, Coral::ManagedObject> m_EntityToManagedObjects;
ScriptingEngineNet();
~ScriptingEngineNet();
@@ -25,5 +47,15 @@ namespace Nuake
static ScriptingEngineNet& Get();
void Initialize();
void Uninitialize();
void LoadProjectAssembly(Ref<Project> project);
void RegisterEntityScript(Entity& entity);
Coral::ManagedObject GetEntityScript(const Entity& entity);
bool HasEntityScriptInstance(const Entity& entity);
void GenerateSolution(const std::string& path, const std::string& projectName);
void CreateEntityScript(const std::string& path, const std::string& entityName);
};
}