private static unsafe IntPtr DotNetCall(int callType, IntPtr value) { EDotNetCallType type = (EDotNetCallType)callType; switch (type) { case EDotNetCallType.SetGameInstance: GameInstance = UObject.Make <DotNetGameInstance>(value); break; case EDotNetCallType.LoadGameDLL: LoadDLL(new string((char *)value.ToPointer())); break; case EDotNetCallType.CallStartFunction: char **paramPointers = (char **)value.ToPointer(); var gameInstanceClass = new string(paramPointers[0]); var argument = new string(paramPointers[1]); IntPtr gameInstance = new IntPtr(paramPointers[2]); CallStartFunction(gameInstanceClass, argument, gameInstance); break; case EDotNetCallType.NewGame: Editor.NewGame(); break; case EDotNetCallType.NewClass: Log.Display("New Class"); break; case EDotNetCallType.BuildGame: Editor.BuildGame(); break; case EDotNetCallType.PlayGame: Log.Display("Play Game"); break; case EDotNetCallType.DebugGame: Log.Display("Debug Game"); break; default: Log.Fatal($"DotNetCall: Unknown call type: {callType}"); break; } return(IntPtr.Zero); }
private static void CallStartFunction(string gameInstanceClass, string argument, IntPtr gameInsteance) { try { var dir = Environment.CurrentDirectory; var classType = GameAssembly.GetType(gameInstanceClass); var baseType = classType.BaseType; var gameStart = classType.GetMethod("Start"); if (classType != null && classType.IsSubclassOf(typeof(DotNetGameInstance))) { GameInstance = (DotNetGameInstance)UObject.Make(gameInsteance, classType); GameInstance.Start(argument); } else { Log.Fatal($"Class {gameInstanceClass} not found or is not subclass of DotNetGameInstance"); } } catch (Exception ex) { Log.Fatal($"Calling '{gameInstanceClass}( \"{argument}\" );' threw exception {ex.ToString()}"); } }