From 381a5ca63b89daf6986c2ee4cadb2bf83e144f4d Mon Sep 17 00:00:00 2001 From: Adam Mathieson Date: Sun, 31 Dec 2023 01:15:01 +0100 Subject: [PATCH 1/4] + Events Sample Code --- OmsiExtensions.sln | 36 ++++++---- OmsiHook/OmsiHook.cs | 3 +- .../Event_Sample/Event_Sample.csproj | 16 +++++ _OmsiHookExamples/Event_Sample/Program.cs | 65 +++++++++++++++++++ 4 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 _OmsiHookExamples/Event_Sample/Event_Sample.csproj create mode 100644 _OmsiHookExamples/Event_Sample/Program.cs diff --git a/OmsiExtensions.sln b/OmsiExtensions.sln index b488af9..e1a9c58 100644 --- a/OmsiExtensions.sln +++ b/OmsiExtensions.sln @@ -19,9 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmsiHookRPCPlugin", "OmsiHo EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic_CLI", "_OmsiHookExamples\Basic_CLI\Basic_CLI.csproj", "{BA833C68-E8BD-4C86-9555-85542DF02015}" - ProjectSection(ProjectDependencies) = postProject - {2E750CBE-F868-4AB7-96C2-27560F53E06B} = {2E750CBE-F868-4AB7-96C2-27560F53E06B} - EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Event_Sample", "_OmsiHookExamples\Event_Sample\Event_Sample.csproj", "{47659503-9923-4E74-AD26-103C1F9FF2B0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -99,17 +98,30 @@ Global {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x64.ActiveCfg = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.ActiveCfg = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.Build.0 = Release|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x64.ActiveCfg = Debug|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x64.Build.0 = Debug|Any CPU + {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.ActiveCfg = Debug|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.Build.0 = Debug|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x64.ActiveCfg = Debug|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x64.Build.0 = Debug|x86 {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x86.ActiveCfg = Debug|x86 {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x86.Build.0 = Debug|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.Build.0 = Release|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x64.ActiveCfg = Release|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x64.Build.0 = Release|Any CPU - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.ActiveCfg = Release|Any CPU + {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.ActiveCfg = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.Build.0 = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x64.ActiveCfg = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x64.Build.0 = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.ActiveCfg = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.Build.0 = Release|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x64.ActiveCfg = Debug|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x64.Build.0 = Debug|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.ActiveCfg = Debug|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.Build.0 = Debug|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|Any CPU.Build.0 = Release|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x64.ActiveCfg = Release|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x64.Build.0 = Release|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.ActiveCfg = Release|Any CPU + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OmsiHook/OmsiHook.cs b/OmsiHook/OmsiHook.cs index be8ff12..95e5908 100644 --- a/OmsiHook/OmsiHook.cs +++ b/OmsiHook/OmsiHook.cs @@ -173,8 +173,9 @@ private void OmsiHook_OnOmsiGotD3DContext(object sender, EventArgs e) [Obsolete("This will be obselete once TMyOMSIList is wrapped! The list of vehicles will be moved to OmsiGlobals.")] public OmsiRoadVehicleInst GetRoadVehicleInst(int index) { + // TODO: A More permanant fix should be done at some point. var vehPtr = GetListItem(0x00861508, index); - return vehPtr == 0 ? null : new OmsiRoadVehicleInst(omsiMemory, vehPtr); + return vehPtr < 1000 ? null : new OmsiRoadVehicleInst(omsiMemory, vehPtr); } /// diff --git a/_OmsiHookExamples/Event_Sample/Event_Sample.csproj b/_OmsiHookExamples/Event_Sample/Event_Sample.csproj new file mode 100644 index 0000000..f900fe8 --- /dev/null +++ b/_OmsiHookExamples/Event_Sample/Event_Sample.csproj @@ -0,0 +1,16 @@ + + + + Exe + net6.0-windows + enable + enable + Event_Sample.Program + x86 + + + + + + + diff --git a/_OmsiHookExamples/Event_Sample/Program.cs b/_OmsiHookExamples/Event_Sample/Program.cs new file mode 100644 index 0000000..f008fe2 --- /dev/null +++ b/_OmsiHookExamples/Event_Sample/Program.cs @@ -0,0 +1,65 @@ +using System; +using System.Threading; +using OmsiHook; + +namespace Event_Sample +{ + // Most Basic example of reading various values exposed by OMSIHook + class Program + { + static void Main(string[] args) + { + Console.OutputEncoding = System.Text.Encoding.UTF8; + Console.WriteLine("#=#=#=#=#=# OMSIHook Events Sample #=#=#=#=#=#"); + + OmsiHook.OmsiHook omsi = new(); + omsi.AttachToOMSI().Wait(); + omsi.OnMapChange += Omsi_OnMapChange; + omsi.OnMapLoaded += Omsi_OnMapLoaded; + // Await callbacks + while (true) + { + Thread.Sleep(1000); + } + } + + private static void Omsi_OnOmsiLostD3DContext(object? sender, EventArgs e) + { + Console.WriteLine("💻 D3D Context Lost"); + } + + private static void Omsi_OnOmsiGotD3DContext(object? sender, EventArgs e) + { + Console.WriteLine("💻 D3D Context Secured"); + } + + private static void Omsi_OnOmsiExited(object? sender, EventArgs e) + { + Console.WriteLine("🛑 OMSI Has Exited"); + } + + private static void Omsi_OnMapLoaded(object? sender, bool e) + { + if (sender != null) + Console.WriteLine($"🗺️ Map Loaded: {e}"); + } + + private static void Omsi_OnMapChange(object? sender, EventArgs e) + { + if (sender != null) + { + var omsi = sender as OmsiHook.OmsiHook; + Console.WriteLine($"🗺️ Map Changed: {omsi.Globals.Map.FriendlyName}"); + omsi.OnActiveVehicleChanged += Omsi_OnActiveVehicleChanged; + omsi.OnOmsiExited += Omsi_OnOmsiExited; + omsi.OnOmsiGotD3DContext += Omsi_OnOmsiGotD3DContext; + omsi.OnOmsiLostD3DContext += Omsi_OnOmsiLostD3DContext; + } + } + + private static void Omsi_OnActiveVehicleChanged(object? sender, OmsiRoadVehicleInst e) + { + Console.WriteLine($"🚌 Active Vehicle Changed: {e.RoadVehicle.FriendlyName}"); + } + } +} From 7ede5eb64c0aef92b22584f84fecf8a68f9aee15 Mon Sep 17 00:00:00 2001 From: Adam Mathieson Date: Sun, 31 Dec 2023 01:15:39 +0100 Subject: [PATCH 2/4] + Slightly more resonable event handlers --- _OmsiHookExamples/Event_Sample/Program.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_OmsiHookExamples/Event_Sample/Program.cs b/_OmsiHookExamples/Event_Sample/Program.cs index f008fe2..e6ef41e 100644 --- a/_OmsiHookExamples/Event_Sample/Program.cs +++ b/_OmsiHookExamples/Event_Sample/Program.cs @@ -16,6 +16,10 @@ static void Main(string[] args) omsi.AttachToOMSI().Wait(); omsi.OnMapChange += Omsi_OnMapChange; omsi.OnMapLoaded += Omsi_OnMapLoaded; + omsi.OnActiveVehicleChanged += Omsi_OnActiveVehicleChanged; + omsi.OnOmsiExited += Omsi_OnOmsiExited; + omsi.OnOmsiGotD3DContext += Omsi_OnOmsiGotD3DContext; + omsi.OnOmsiLostD3DContext += Omsi_OnOmsiLostD3DContext; // Await callbacks while (true) { @@ -50,10 +54,6 @@ private static void Omsi_OnMapChange(object? sender, EventArgs e) { var omsi = sender as OmsiHook.OmsiHook; Console.WriteLine($"🗺️ Map Changed: {omsi.Globals.Map.FriendlyName}"); - omsi.OnActiveVehicleChanged += Omsi_OnActiveVehicleChanged; - omsi.OnOmsiExited += Omsi_OnOmsiExited; - omsi.OnOmsiGotD3DContext += Omsi_OnOmsiGotD3DContext; - omsi.OnOmsiLostD3DContext += Omsi_OnOmsiLostD3DContext; } } From c4ff5db54b707bc11ffb80a9b288fe8f2b650f4c Mon Sep 17 00:00:00 2001 From: Adam Mathieson Date: Sun, 31 Dec 2023 02:59:52 +0100 Subject: [PATCH 3/4] + Documentation for the sample --- .../docs/articles/examples/Event_Sample.md | 62 +++++++++++++++++++ OmsiHook/docs/articles/toc.yml | 4 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 OmsiHook/docs/articles/examples/Event_Sample.md diff --git a/OmsiHook/docs/articles/examples/Event_Sample.md b/OmsiHook/docs/articles/examples/Event_Sample.md new file mode 100644 index 0000000..4805cfd --- /dev/null +++ b/OmsiHook/docs/articles/examples/Event_Sample.md @@ -0,0 +1,62 @@ +# Basic Events Example + +This article provides a basic understanding to a basic C# .NET example leveraging the OMSIHook library. The example focuses using the event handlers provided by OMSIHook. + +_This article is in direct relation to the Sample Project available [here](https://github.com/space928/Omsi-Extensions/tree/main/_OmsiHookExamples/Event_Sample)._ + +## Basic Usage +Similar to most C# .NET event handlers, you simply need to append the handler to the field as demonstraited below. + +```cs +OmsiHook.OmsiHook omsi = new(); +omsi.OnMapChange += Omsi_OnMapChange; +omsi.OnMapLoaded += Omsi_OnMapLoaded; +omsi.OnActiveVehicleChanged += Omsi_OnActiveVehicleChanged; +omsi.OnOmsiExited += Omsi_OnOmsiExited; +omsi.OnOmsiGotD3DContext += Omsi_OnOmsiGotD3DContext; +omsi.OnOmsiLostD3DContext += Omsi_OnOmsiLostD3DContext; +``` + +## Event Descriptions +The events all provide the current `OMSIHook` object as well as several of them provide references to the object that has changed. +### _MapChange_ Event +Triggered any time the current map has changed. +```cs +Omsi_OnMapChange(object? sender, EventArgs e) +``` +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` object is not used for this event. + +### _MapLoaded_ Event +Triggered any time a map is loaded or unloaded. +```cs +Omsi_OnMapLoaded(object? sender, bool e) +``` +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` is a bool that contains weather or not the event if for a map loading or unloading. + +### _ActiveVehicleChanged_ Event +Triggered any time a player changes vehicle. +```cs +Omsi_OnActiveVehicleChanged(object? sender, OmsiRoadVehicleInst e) +``` +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` is a reference to the current player vehicle instance. + +### _OmsiExited_ Event +Triggered upon OMSI exiting. +```cs +Omsi_OnOmsiExited(object? sender, EventArgs e) +``` +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` object is not used for this event. + +### _OmsiGotD3DContext_ Event +Triggered upon OMSI's Direct3D context being initialised. +```cs +Omsi_OnOmsiGotD3DContext(object? sender, EventArgs e) +``` +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` object is not used for this event. + +### _OmsiLostD3DContext_ Event +Triggered upon OMSI's Direct3D context being lost. +```cs +Omsi_OnOmsiLostD3DContext(object? sender, EventArgs e) +``` +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` object is not used for this event. diff --git a/OmsiHook/docs/articles/toc.yml b/OmsiHook/docs/articles/toc.yml index de1b476..a5fb87d 100644 --- a/OmsiHook/docs/articles/toc.yml +++ b/OmsiHook/docs/articles/toc.yml @@ -7,4 +7,6 @@ - name: Examples items: - name: Basic CLI Example - href: examples\Basic_CLI.md \ No newline at end of file + href: examples\Basic_CLI.md + - name: Basic Events Example + href: examples\Event_Sample.md \ No newline at end of file From d685c95a6f907a712c236176df53b9e5919c6e0a Mon Sep 17 00:00:00 2001 From: Thomas Mathieson Date: Tue, 2 Jan 2024 09:53:24 +0100 Subject: [PATCH 4/4] Somme refactoring and some fixes: - Refactored sample project to meet Thomas' draconian naming requirements - OnMapChange now provides the new OmsiMap objject as event args - Added separate ReleaseAndDocs build config to allow release builds to be built without having to wait for the docs to compile - Updated readme - Fixed solution file --- OmsiExtensions.sln | 120 ++++++------------ OmsiExtensionsCLI/OmsiExtensionsCLI.csproj | 7 +- OmsiExtensionsCLI/favicon.ico | Bin 0 -> 6518 bytes OmsiHook/OmsiHook.cs | 6 +- OmsiHook/OmsiHook.csproj | 52 +++++--- .../{Event_Sample.md => event-sample.md} | 5 +- OmsiHook/docs/articles/toc.yml | 2 +- README.md | 12 +- .../EventSample.csproj} | 7 +- .../{Event_Sample => EventSample}/Program.cs | 14 +- 10 files changed, 106 insertions(+), 119 deletions(-) create mode 100644 OmsiExtensionsCLI/favicon.ico rename OmsiHook/docs/articles/examples/{Event_Sample.md => event-sample.md} (94%) rename _OmsiHookExamples/{Event_Sample/Event_Sample.csproj => EventSample/EventSample.csproj} (60%) rename _OmsiHookExamples/{Event_Sample => EventSample}/Program.cs (85%) diff --git a/OmsiExtensions.sln b/OmsiExtensions.sln index babc37f..90fed48 100644 --- a/OmsiExtensions.sln +++ b/OmsiExtensions.sln @@ -17,119 +17,81 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OmsiHookRPCPlugin", "OmsiHo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicCLI", "_OmsiHookExamples\BasicCLI\BasicCLI.csproj", "{BA833C68-E8BD-4C86-9555-85542DF02015}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Event_Sample", "_OmsiHookExamples\Event_Sample\Event_Sample.csproj", "{47659503-9923-4E74-AD26-103C1F9FF2B0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventSample", "_OmsiHookExamples\EventSample\EventSample.csproj", "{47659503-9923-4E74-AD26-103C1F9FF2B0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{3F0BF441-D76C-4E0D-A5A8-B20895438EA5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TriggersSample", "_OmsiHookExamples\TriggersSample\TriggersSample.csproj", "{1DF326AE-4D10-4545-B36A-5622B76987EC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 Release|x86 = Release|x86 + ReleaseAndDocs|x86 = ReleaseAndDocs|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.ActiveCfg = Debug|x86 - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|Any CPU.Build.0 = Debug|x86 - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x64.ActiveCfg = Debug|x86 - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x64.Build.0 = Debug|x86 {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.ActiveCfg = Debug|x86 {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Debug|x86.Build.0 = Debug|x86 - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.ActiveCfg = Release|x86 - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|Any CPU.Build.0 = Release|x86 - {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x64.ActiveCfg = Release|x86 {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.ActiveCfg = Release|x86 {2E750CBE-F868-4AB7-96C2-27560F53E06B}.Release|x86.Build.0 = Release|x86 - {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|Any CPU.ActiveCfg = Debug|x86 - {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|Any CPU.Build.0 = Debug|x86 - {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x64.ActiveCfg = Debug|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x64.Build.0 = Debug|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x86.ActiveCfg = Debug|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x86.Build.0 = Debug|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Release|Any CPU.ActiveCfg = Release|x86 - {28DA0165-EAA7-4171-A065-319409682BD1}.Release|Any CPU.Build.0 = Release|x86 - {28DA0165-EAA7-4171-A065-319409682BD1}.Release|x64.ActiveCfg = Release|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Release|x64.Build.0 = Release|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Release|x86.ActiveCfg = Release|Any CPU - {28DA0165-EAA7-4171-A065-319409682BD1}.Release|x86.Build.0 = Release|Any CPU - {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|Any CPU.ActiveCfg = Debug|x86 - {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|Any CPU.Build.0 = Debug|x86 - {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|x64.ActiveCfg = Debug|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.ReleaseAndDocs|x86.ActiveCfg = ReleaseAndDocs|x86 + {2E750CBE-F868-4AB7-96C2-27560F53E06B}.ReleaseAndDocs|x86.Build.0 = ReleaseAndDocs|x86 + {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x86.ActiveCfg = Debug|x86 + {28DA0165-EAA7-4171-A065-319409682BD1}.Debug|x86.Build.0 = Debug|x86 + {28DA0165-EAA7-4171-A065-319409682BD1}.Release|x86.ActiveCfg = Release|x86 + {28DA0165-EAA7-4171-A065-319409682BD1}.Release|x86.Build.0 = Release|x86 + {28DA0165-EAA7-4171-A065-319409682BD1}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {28DA0165-EAA7-4171-A065-319409682BD1}.ReleaseAndDocs|x86.Build.0 = Release|x86 {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|x86.ActiveCfg = Debug|x86 - {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|Any CPU.ActiveCfg = Release|x86 - {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|x64.ActiveCfg = Release|x86 + {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Debug|x86.Build.0 = Debug|x86 {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|x86.ActiveCfg = Release|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|Any CPU.ActiveCfg = Debug|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|Any CPU.Build.0 = Debug|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|x64.ActiveCfg = Debug|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|x64.Build.0 = Debug|x86 + {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.Release|x86.Build.0 = Release|x86 + {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {FDA9A525-9722-46D3-B80C-8D2A76ABCA2D}.ReleaseAndDocs|x86.Build.0 = Release|x86 {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|x86.ActiveCfg = Debug|x86 {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Debug|x86.Build.0 = Debug|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|Any CPU.ActiveCfg = Release|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|Any CPU.Build.0 = Release|x86 - {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|x64.ActiveCfg = Release|x86 {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|x86.ActiveCfg = Release|x86 {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.Release|x86.Build.0 = Release|x86 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|Any CPU.Build.0 = Debug|Win32 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|x64.ActiveCfg = Debug|Win32 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|x64.Build.0 = Debug|Win32 + {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {D5CA6EEA-D436-456E-BCA5-34C3DFD5BFC7}.ReleaseAndDocs|x86.Build.0 = Release|x86 {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|x86.ActiveCfg = Debug|Win32 {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Debug|x86.Build.0 = Debug|Win32 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|Any CPU.ActiveCfg = Release|Win32 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|Any CPU.Build.0 = Release|Win32 - {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|x64.ActiveCfg = Release|Win32 {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|x86.ActiveCfg = Release|Win32 {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.Release|x86.Build.0 = Release|Win32 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.ActiveCfg = Debug|x86 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|Any CPU.Build.0 = Debug|x86 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x64.ActiveCfg = Debug|x86 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x64.Build.0 = Debug|x86 + {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|x86.ActiveCfg = Release|Win32 + {CBCB99EF-DD1A-4D4D-A9A8-9BF251FDCD1B}.ReleaseAndDocs|x86.Build.0 = Release|Win32 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x86.ActiveCfg = Debug|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Debug|x86.Build.0 = Debug|x86 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|Any CPU.ActiveCfg = Release|x86 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|Any CPU.Build.0 = Release|x86 - {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x64.ActiveCfg = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.ActiveCfg = Release|x86 {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.Release|x86.Build.0 = Release|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.ActiveCfg = Debug|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|Any CPU.Build.0 = Debug|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x64.ActiveCfg = Debug|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x64.Build.0 = Debug|x86 + {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {CDB17143-5653-48BE-AAC8-8419D5B4FD2C}.ReleaseAndDocs|x86.Build.0 = Release|x86 {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x86.ActiveCfg = Debug|x86 {BA833C68-E8BD-4C86-9555-85542DF02015}.Debug|x86.Build.0 = Debug|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.ActiveCfg = Release|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|Any CPU.Build.0 = Release|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x64.ActiveCfg = Release|x86 - {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x64.Build.0 = Release|x86 {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.ActiveCfg = Release|x86 {BA833C68-E8BD-4C86-9555-85542DF02015}.Release|x86.Build.0 = Release|x86 - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x64.ActiveCfg = Debug|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x64.Build.0 = Debug|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.ActiveCfg = Debug|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.Build.0 = Debug|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|Any CPU.Build.0 = Release|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x64.ActiveCfg = Release|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x64.Build.0 = Release|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.ActiveCfg = Release|Any CPU - {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.Build.0 = Release|Any CPU - {8950E419-6895-46E4-8CBE-68E24844D644}.Debug|Any CPU.ActiveCfg = Debug|x86 - {8950E419-6895-46E4-8CBE-68E24844D644}.Debug|Any CPU.Build.0 = Debug|x86 - {8950E419-6895-46E4-8CBE-68E24844D644}.Debug|x64.ActiveCfg = Debug|x86 - {8950E419-6895-46E4-8CBE-68E24844D644}.Debug|x86.ActiveCfg = Debug|x86 - {8950E419-6895-46E4-8CBE-68E24844D644}.Release|Any CPU.ActiveCfg = Release|x86 - {8950E419-6895-46E4-8CBE-68E24844D644}.Release|x64.ActiveCfg = Release|x86 - {8950E419-6895-46E4-8CBE-68E24844D644}.Release|x86.ActiveCfg = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {BA833C68-E8BD-4C86-9555-85542DF02015}.ReleaseAndDocs|x86.Build.0 = Release|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.ActiveCfg = Debug|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Debug|x86.Build.0 = Debug|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.ActiveCfg = Release|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.Release|x86.Build.0 = Release|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {47659503-9923-4E74-AD26-103C1F9FF2B0}.ReleaseAndDocs|x86.Build.0 = Release|x86 + {1DF326AE-4D10-4545-B36A-5622B76987EC}.Debug|x86.ActiveCfg = Debug|x86 + {1DF326AE-4D10-4545-B36A-5622B76987EC}.Debug|x86.Build.0 = Debug|x86 + {1DF326AE-4D10-4545-B36A-5622B76987EC}.Release|x86.ActiveCfg = Release|x86 + {1DF326AE-4D10-4545-B36A-5622B76987EC}.Release|x86.Build.0 = Release|x86 + {1DF326AE-4D10-4545-B36A-5622B76987EC}.ReleaseAndDocs|x86.ActiveCfg = Release|x86 + {1DF326AE-4D10-4545-B36A-5622B76987EC}.ReleaseAndDocs|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {BA833C68-E8BD-4C86-9555-85542DF02015} = {58156BDC-C261-460F-B8BA-749E994CC743} - {8950E419-6895-46E4-8CBE-68E24844D644} = {58156BDC-C261-460F-B8BA-749E994CC743} + {BA833C68-E8BD-4C86-9555-85542DF02015} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5} + {47659503-9923-4E74-AD26-103C1F9FF2B0} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5} + {1DF326AE-4D10-4545-B36A-5622B76987EC} = {3F0BF441-D76C-4E0D-A5A8-B20895438EA5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A5F55305-C8FF-444C-9B98-FD487ADC583A} diff --git a/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj b/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj index 4d5bef0..0bfd17a 100644 --- a/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj +++ b/OmsiExtensionsCLI/OmsiExtensionsCLI.csproj @@ -1,14 +1,19 @@ - + Exe net6.0-windows x86 x86 + favicon.ico + + + + diff --git a/OmsiExtensionsCLI/favicon.ico b/OmsiExtensionsCLI/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..b407cbdb4dbc1e0bcdec0473c797afff2fba084c GIT binary patch literal 6518 zcmdT|`8yO2(BCD5NbYMb9mstrEi2^Ma^JDYk&yd7S0pMVXXK0}v5VZ+T1h0wW*u9U zCFj~$_szb2-@oF0XP$Xx=9ynU^UU*^d7c3PfdBMA0Rlt;E&>1m@4xuDnTY`#iy+It zkj=Uxo{Js=7YIb4AH-OJBuH z&r1e6>Vz96j6NUKOVhuCRb2jcT(T6<-g-RKVNE-v%ur*CsnwO_j@FTCjbmHdPk-n? zDF2V-X}m4TOh?LC8c~OMi<7-Q0_1qrgJSi|x42ndd!NS}nb`@&phvAPtd;mmu`Fl- z{8*!na+g7~6KcY!`$t^aCg!yD=Dd?$bK2Qeq+2%o-pBWl&ZD(!Hb}sLwb!|2>#))n zDFkziRE921dL`cVqh}(p#2mCmL2bw@LKX}!x7ji#m#v%&t zg(6rWnR5KB165?xF@;I5 zXh4v+VV>8EjQbmF5f`ll>tCIy;3)UvifR65;$Oq5quQZy-WvP4q))WPt=2OqC=MF?Umzjmtz_gtCSjLp|oW zPqLZS>RQTR*80 z#jHf=i0uKoKB#2%ZGLiahuXk@hN|e-5_rm*JNcPH%jWT*h3U`0y7tQp+kLkTkC*es zKeI;U50h9qIhQox#MUSQY(*AfIEBW?kcd8k0c4s@Ok8 z){dw;>;k0jF-%n_qH-sUZH@Ycgck+}|8)Ra*w()pC71sE?wo1JzJaN!oqIpwV8*E< zQK=?p%L}<6WP%E0HNF?PIBc3!5v#GSTxJW<;`Rrcv{+5wee@W?XdhtwDLGO+I=?ux z*ioo@Ja1eA<*j@&^Od?l3%2w}o~hhyp8im;9%9+;v(C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eiD}X5mB&8SgHbz7V6Ox>%wZZRs>YE(9BcNj@gUQwN z$Lw2VAL5U3qEkf z(r>_r{*AS9M@>v59-hjsJx||`$yj25SxO~XlFOoQ4X631KW}au?wH}d;8U8R+R7nu z{_dK9-)U|Z!K0~n%jsFJwob;#cxf5=zRqdpkRS^b9WGm38gj*p&dc%9mhMUIkf3Ql z)GqQnZ^KY{%++2RE?03)-?)#};=MG(@n5_7300ArxNybcRDX)7W4O@R^rNCAdgAY% zJT7_iRn$jksqfLD9A7Gy(II@yMl?%y!dbtoy^>6s{SqM?DWNGelNH4T6)jKoOFCP9 z&$PkZ{xSFaTdzFH*lVHBKWJ(S-{L;LhY=;J2_w`09mQu-(8V@`sABgvv>8J$pw@~Q zE{852r4z(8l=uqKMZOB%vM2D%6cu3CQKA*jXsvy8Y%;Vk z)R_CiWdnJItGes)#;p^JJuLHWmpyVCU$1_nyT=={cjKB)@fQoG8P?v2zfBfj nsdL}<3g1cn{lEVCzkP_f*mVEU!#rH*Kd44`O!Uw?E(!kwMh#gq literal 0 HcmV?d00001 diff --git a/OmsiHook/OmsiHook.cs b/OmsiHook/OmsiHook.cs index 95e5908..3e04aa7 100644 --- a/OmsiHook/OmsiHook.cs +++ b/OmsiHook/OmsiHook.cs @@ -70,7 +70,7 @@ public class OmsiHook /// /// /// - public event EventHandler OnMapChange; + public event EventHandler OnMapChange; /// /// An event raised when Omsi has loaded or unloaded a new map. The EventArgs is a boolean representing whether the map is loaded. /// @@ -149,7 +149,7 @@ public D3DTexture CreateTextureObject() return new D3DTexture(omsiMemory, 0); } - private void OmsiHook_OnMapChange(object sender, EventArgs e) + private void OmsiHook_OnMapChange(object sender, OmsiMap e) { Task.Run(() => { while(!isD3DReady) @@ -223,7 +223,7 @@ private void MonitorStateTask() if(lastMapState != currentMapName) { if(currentMapName != 0) - OnMapChange?.Invoke(this, new()); + OnMapChange?.Invoke(this, Globals.Map); lastMapState = currentMapName; } if(lastMapLoaded != currentMapLoaded) diff --git a/OmsiHook/OmsiHook.csproj b/OmsiHook/OmsiHook.csproj index d6c43c6..b97d414 100644 --- a/OmsiHook/OmsiHook.csproj +++ b/OmsiHook/OmsiHook.csproj @@ -3,16 +3,16 @@ net6.0-windows Thomas Mathieson et al - Copyright Thomas Mathieson 2023 all rights reserved + Copyright Thomas Mathieson 2022-2024 all rights reserved https://github.com/space928/Omsi-Extensions https://github.com/space928/Omsi-Extensions OmsiHook is a simple library for hooking into Omsi's memory for modding. true true - 2.4.3.1 - 2.4.3.1 - 2.4.3 + 2.4.4.1 + 2.4.4.1 + 2.4.4 LGPL-3.0-only False README.md @@ -22,18 +22,34 @@ disable x86 False + Debug;Release;ReleaseAndDocs - - - true - $(MSBuildProjectDirectory)/docs/docfx.json - $(MSBuildProjectDirectory)/docs/_site - $(MSBuildProjectDirectory)/docs - $(MSBuildProjectDirectory)/docs/docfx_log.txt - Info - + + + + + + <_ConfigurationNormalized>$(Configuration) + false + + + + + <_ConfigurationNormalized>Release + $(MSBuildProjectDirectory)/bin/$(Platform)/Release/$(TargetFramework)/ + $(MSBuildProjectDirectory)/bin/$(Platform)/Release/ + + true + $(MSBuildProjectDirectory)/docs/docfx.json + $(MSBuildProjectDirectory)/docs/_site + $(MSBuildProjectDirectory)/docs + $(MSBuildProjectDirectory)/docs/docfx_log.txt + Info + + + @@ -45,22 +61,22 @@ True \ - + PreserveNewest True \lib\net6.0 - + PreserveNewest True \lib\net6.0 - + PreserveNewest True \lib\net6.0 - + PreserveNewest True \lib\net6.0 @@ -85,7 +101,7 @@ - + diff --git a/OmsiHook/docs/articles/examples/Event_Sample.md b/OmsiHook/docs/articles/examples/event-sample.md similarity index 94% rename from OmsiHook/docs/articles/examples/Event_Sample.md rename to OmsiHook/docs/articles/examples/event-sample.md index 4805cfd..9db7a42 100644 --- a/OmsiHook/docs/articles/examples/Event_Sample.md +++ b/OmsiHook/docs/articles/examples/event-sample.md @@ -19,12 +19,13 @@ omsi.OnOmsiLostD3DContext += Omsi_OnOmsiLostD3DContext; ## Event Descriptions The events all provide the current `OMSIHook` object as well as several of them provide references to the object that has changed. + ### _MapChange_ Event Triggered any time the current map has changed. ```cs -Omsi_OnMapChange(object? sender, EventArgs e) +Omsi_OnMapChange(object? sender, OmsiMap e) ``` -The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` object is not used for this event. +The `sender` object as with all the other events refers to the current `OMSIHook` object, the `e` object is a reference to the new `OmsiMap` object or `null`. ### _MapLoaded_ Event Triggered any time a map is loaded or unloaded. diff --git a/OmsiHook/docs/articles/toc.yml b/OmsiHook/docs/articles/toc.yml index 7a5c830..89d1cc9 100644 --- a/OmsiHook/docs/articles/toc.yml +++ b/OmsiHook/docs/articles/toc.yml @@ -11,4 +11,4 @@ - name: Basic Mouse Trigger & Sound Trigger Example href: examples\triggers-sample.md - name: Basic Events Example - href: examples\Event_Sample.md \ No newline at end of file + href: examples\event-sample.md \ No newline at end of file diff --git a/README.md b/README.md index 721c612..36cd720 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Omsi hooking and modding sdk. [![.NET](https://github.com/space928/Omsi-Extensions/actions/workflows/dotnet.yml/badge.svg)](https://github.com/space928/Omsi-Extensions/actions/workflows/dotnet.yml) -[![DocFX](https://github.com/space928/Omsi-Extensions/actions/workflows/docs.yml/badge.svg)](https://github.com/space928/Omsi-Extensions/actions/workflows/docs.yml) +[![DocFX](https://github.com/space928/Omsi-Extensions/actions/workflows/docs.yml/badge.svg)](https://space928.github.io/Omsi-Extensions/index.html) [![Nuget](https://img.shields.io/nuget/v/omsihook)](https://www.nuget.org/packages/OmsiHook/) [![OMSI Version](https://img.shields.io/badge/OMSI%20Version-2.3.004-orange)](https://store.steampowered.com/app/252530/OMSI_2_Steam_Edition/) @@ -25,9 +25,9 @@ class Program { static void Main(string[] args) { - // Create an OmsiHook and attach to any running instance of Omsi + // Create an OmsiHook and attach to any running instance of OMSI OmsiHook.OmsiHook omsi = new(); - omsi.AttachToOMSI(); + omsi.AttachToOMSI().Wait(); while (true) { @@ -35,7 +35,7 @@ class Program var pos = omsi.Globals.PlayerVehicle.Position; // Print the position to the console - Console.WriteLine($"Player vehicle pos: x:{pos.x:F3}\ty:{pos.y:F3}\tz:{pos.z:F3}"); + Console.WriteLine($"Player vehicle pos: {pos}"); Thread.Sleep(500); } @@ -52,6 +52,8 @@ Here's a summary of the project structure: ``` \Omsi-Extensions\ ┃ +┠─► \_OmsiHookExamples\ -> A collection of sample projects demonstrating various OmsiHook +┃ features. ┠─► \OmsiHook\ -> Base library containing all the Omsi hooking code and ┃ exposing Omsi's internal data. ┠─► \OmsiHookInvoker\ -> C++ plugin for invoking native Omsi methods from OmsiHook, @@ -63,7 +65,7 @@ Here's a summary of the project structure: ┠─► \OmsiExtensionsUI\ -> Example Avalonia UI (similar to WPF) application that uses ┃ OmsiHook; runs outside of Omsi. ┖─► \OmsiHookPlugin\ -> Example plugin that uses OmsiHook and compiles to a native - Omsi plugin by using DNNE. + Omsi plugin by using DNNE. ``` ## Building diff --git a/_OmsiHookExamples/Event_Sample/Event_Sample.csproj b/_OmsiHookExamples/EventSample/EventSample.csproj similarity index 60% rename from _OmsiHookExamples/Event_Sample/Event_Sample.csproj rename to _OmsiHookExamples/EventSample/EventSample.csproj index f900fe8..1b40390 100644 --- a/_OmsiHookExamples/Event_Sample/Event_Sample.csproj +++ b/_OmsiHookExamples/EventSample/EventSample.csproj @@ -1,16 +1,17 @@ - + Exe net6.0-windows enable enable - Event_Sample.Program + EventSample.Program x86 + x86 - + diff --git a/_OmsiHookExamples/Event_Sample/Program.cs b/_OmsiHookExamples/EventSample/Program.cs similarity index 85% rename from _OmsiHookExamples/Event_Sample/Program.cs rename to _OmsiHookExamples/EventSample/Program.cs index e6ef41e..b724624 100644 --- a/_OmsiHookExamples/Event_Sample/Program.cs +++ b/_OmsiHookExamples/EventSample/Program.cs @@ -2,7 +2,7 @@ using System.Threading; using OmsiHook; -namespace Event_Sample +namespace EventSample { // Most Basic example of reading various values exposed by OMSIHook class Program @@ -14,6 +14,9 @@ static void Main(string[] args) OmsiHook.OmsiHook omsi = new(); omsi.AttachToOMSI().Wait(); + + Console.WriteLine("Waiting for events..."); + omsi.OnMapChange += Omsi_OnMapChange; omsi.OnMapLoaded += Omsi_OnMapLoaded; omsi.OnActiveVehicleChanged += Omsi_OnActiveVehicleChanged; @@ -48,13 +51,10 @@ private static void Omsi_OnMapLoaded(object? sender, bool e) Console.WriteLine($"🗺️ Map Loaded: {e}"); } - private static void Omsi_OnMapChange(object? sender, EventArgs e) + private static void Omsi_OnMapChange(object? sender, OmsiMap e) { - if (sender != null) - { - var omsi = sender as OmsiHook.OmsiHook; - Console.WriteLine($"🗺️ Map Changed: {omsi.Globals.Map.FriendlyName}"); - } + if (e != null) + Console.WriteLine($"🗺️ Map Changed: {e.FriendlyName}"); } private static void Omsi_OnActiveVehicleChanged(object? sender, OmsiRoadVehicleInst e)