Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle inst #30

Merged
merged 5 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions OmsiExtensionsCLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading;
using OmsiHook;
using System.Threading.Tasks;

namespace OmsiExtensionsCLI
{
Expand All @@ -11,22 +12,31 @@ static void Main(string[] args)
Console.WriteLine("#=#=#=#=#=# OmsiExtensions Testing #=#=#=#=#=#");

OmsiHook.OmsiHook omsi = new();
omsi.AttachToOMSI();
Task.WaitAll(omsi.AttachToOMSI());
Console.Clear();

while (true)
{
var pos = omsi.PlayerVehicle.Position;
var posa = omsi.PlayerVehicle.AbsPosition;
var vel = omsi.PlayerVehicle.Velocity;
var map = omsi.Map;
var weather = omsi.Weather;
var tickets = omsi.TicketPack;

Console.WriteLine($"Read data: x:{pos.x:F3}\ty:{pos.y:F3}\tz:{pos.z:F3}\t\t" +
$"tile:{0}\trow45:{0:F3}\trow47:{0:F3}");
Console.SetCursorPosition(0, 0);
Console.WriteLine(($"Read data: x:{pos.x:F3} y:{pos.y:F3} z:{pos.z:F3} " +
$"tile:{omsi.PlayerVehicle.Kachel}").PadRight(Console.WindowWidth - 1));
Console.WriteLine($"Read data: vx:{vel.x:F3} vy:{vel.y:F3} vz:{vel.z:F3}".PadRight(Console.WindowWidth-1));
Console.WriteLine($"Read data: ax:{posa._30:F3} ay:{posa._31:F3} az:{posa._32:F3}".PadRight(Console.WindowWidth-1));

Console.WriteLine($"Read data: map:{map.Name}\tpath:{map.Filename}\tfriendly:{map.FriendlyName}");
Console.WriteLine($"Read data: act w name:{weather.ActWeather.name}");
Console.WriteLine($"Read data: map:{map.Name} path:{map.Filename} friendly:{map.FriendlyName}".PadRight(Console.WindowWidth-1));
Console.WriteLine($"{omsi.PlayerVehicle.PAI_LastBrake} {omsi.PlayerVehicle.Bremspedal}".PadRight(Console.WindowWidth - 1));
Console.WriteLine("".PadRight(Console.WindowWidth-1));
//omsi.PlayerVehicle.Velocity = new D3DVector { x=0, y=0, z=5 };
//omsi.PlayerVehicle.Bremspedal = 0;

Thread.Sleep(500);
Thread.Sleep(50);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion OmsiExtensionsCLI/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"OmsiExtensionsCLI": {
"commandName": "Project",
"nativeDebugging": true
"nativeDebugging": false
}
}
}
2 changes: 1 addition & 1 deletion OmsiHook/OmsiHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class OmsiHook
/// Attaches the hooking application to OMSI.exe.
/// Always call this at some point before trying to read and write data.
/// </summary>
public async void AttachToOMSI()
public async Task AttachToOMSI()
{
Console.WriteLine("Attaching to OMSI.exe...");

Expand Down
2 changes: 1 addition & 1 deletion OmsiHook/OmsiHook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<Version>1.3.0</Version>
<Version>1.4.0</Version>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<SignAssembly>False</SignAssembly>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
2 changes: 1 addition & 1 deletion OmsiHook/OmsiMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OmsiHook
public class OmsiMap : OmsiObject
{
internal OmsiMap(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiMap() : base() { }
public OmsiMap() : base() { }

public OmsiPoint NW_Corner
{
Expand Down
13 changes: 6 additions & 7 deletions OmsiHook/OmsiMapObjInst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,40 @@
public class OmsiMapObjInst : OmsiObject
{
internal OmsiMapObjInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiMapObjInst() : base() { }
public OmsiMapObjInst() : base() { }

public D3DVector Position
{
get => Memory.ReadMemory<D3DVector>(Address + 0x4);
set => Memory.WriteMemory(Address + 0x4, value);
}

public D3DMatrix Pos_Mat
{
get => Memory.ReadMemory<D3DMatrix>(Address + 0x10);
set => Memory.WriteMemory(Address + 0x10, value);
}

public D3DXQuaternion Rotation => Memory.ReadMemory<D3DXQuaternion>(Address + 0x50);
public D3DXQuaternion Rotation
{
get => Memory.ReadMemory<D3DXQuaternion>(Address + 0x50);
set => Memory.WriteMemory(Address + 0x50, value);
}
public float Scale
{
get => Memory.ReadMemory<float>(Address + 0x60);
set => Memory.WriteMemory(Address + 0x60, value);
}

public D3DMatrix RelMatrix => Memory.ReadMemory<D3DMatrix>(Address + 0x64);
public D3DMatrix Used_RelVec => Memory.ReadMemory<D3DMatrix>(Address + 0x68);
public int Kachel
{
get => Memory.ReadMemory<int>(Address + 0x74);
set => Memory.WriteMemory(Address + 0x74, value);
}

public D3DMatrix AbsPosition
{
get => Memory.ReadMemory<D3DMatrix>(Address + 0x78);
set => Memory.WriteMemory(Address + 0x78, value);
}

public D3DMatrix AbsPosition_Inv => Memory.ReadMemory<D3DMatrix>(Address + 0xb8);
public D3DMatrix AbsPosition_ThreadFree => Memory.ReadMemory<D3DMatrix>(Address + 0xf8);
}
Expand Down
2 changes: 1 addition & 1 deletion OmsiHook/OmsiMovingMapObjInst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public class OmsiMovingMapObjInst : OmsiComplMapObjInst
{
internal OmsiMovingMapObjInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiMovingMapObjInst() : base() { }
public OmsiMovingMapObjInst() : base() { }
}
}
5 changes: 2 additions & 3 deletions OmsiHook/OmsiPartikel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public D3DVector Veloc
set => Memory.WriteMemory(Address + 0x10, value);
}
/// <summary>
/// Birthday?
/// Birth time
/// </summary>
public uint Geburtsdatum
{
get => Memory.ReadMemory<uint>(Address + 0x1c);
set => Memory.WriteMemory(Address + 0x1c, value);
}
/// <summary>
/// Death Day?
/// Death time
/// </summary>
public uint Sterbedatum
{
Expand Down Expand Up @@ -114,6 +114,5 @@ public float TempAlpha
get => Memory.ReadMemory<float>(Address + 0x58);
set => Memory.WriteMemory(Address + 0x58, value);
}

}
}
7 changes: 1 addition & 6 deletions OmsiHook/OmsiPartikelemitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ public bool Spotlight_Calc
get => Memory.ReadMemory<bool>(Address + 0x60);
set => Memory.WriteMemory(Address + 0x60, value);
}
public OmsiPartikel[] Partikel
{
get => Memory.ReadMemoryObjArray<OmsiPartikel>(Address + 0x64);
//set => omsiMemory.WriteMemory(baseAddress + 0x64, value);
}
public OmsiPartikel[] Partikel => Memory.ReadMemoryObjArray<OmsiPartikel>(Address + 0x64);
public int Textur
{
get => Memory.ReadMemory<int>(Address + 0x68);
Expand All @@ -121,6 +117,5 @@ public D3DVector Position
get => Memory.ReadMemory<D3DVector>(Address + 0x6c);
set => Memory.WriteMemory(Address + 0x6c, value);
}

}
}
17 changes: 4 additions & 13 deletions OmsiHook/OmsiPassengerCabin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@
public class OmsiPassengerCabin : OmsiObject
{
internal OmsiPassengerCabin(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiPassengerCabin() : base() { }
public OmsiPassengerCabin() : base() { }

public OmsiSeat[] Seats
{
get => Memory.ReadMemoryStructArray<OmsiSeat>(Address + 0x4);
}
public OmsiPathPoint[] Entries
{
get => Memory.ReadMemoryObjArray<OmsiPathPoint>(Address + 0x8);
}
public OmsiPathPoint[] Entries => Memory.ReadMemoryObjArray<OmsiPathPoint>(Address + 0x8);
public OmsiEntryProp[] EntriesProp
{
get => Memory.ReadMemoryStructArray<OmsiEntryProp>(Address + 0xc);
}
public OmsiPathPoint[] Exits
{
get => Memory.ReadMemoryObjArray<OmsiPathPoint>(Address + 0x10);
}
public OmsiPathPoint[] Exits => Memory.ReadMemoryObjArray<OmsiPathPoint>(Address + 0x10);
public OmsiPassCabinStamper Stamper
{
get => Memory.ReadMemory<OmsiPassCabinStamper>(Address + 0x14);
Expand All @@ -30,9 +24,6 @@ public OmsiPassCabinTicketSale TicketSale
get => Memory.MarshalStruct<OmsiPassCabinTicketSale, OmsiPassCabinTicketSaleInternal>(
Memory.ReadMemory<OmsiPassCabinTicketSaleInternal>(Address + 0x28));
}
public OmsiPathPoint[] LinkToOtherVehicle
{
get => Memory.ReadMemoryObjArray<OmsiPathPoint>(Address + 0x7c);
}
public OmsiPathPoint[] LinkToOtherVehicle => Memory.ReadMemoryObjArray<OmsiPathPoint>(Address + 0x7c);
}
}
2 changes: 1 addition & 1 deletion OmsiHook/OmsiPathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class OmsiPathManager : OmsiObject
{
internal OmsiPathManager(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiPathManager() : base() { }
public OmsiPathManager() : base() { }

public int StepSoundPacks
{
Expand Down
2 changes: 2 additions & 0 deletions OmsiHook/OmsiPathPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ public class OmsiPathPoint : OmsiObject
{
internal OmsiPathPoint(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
public OmsiPathPoint() : base() { }

//TODO: Complete OmsiPathPoint
}
}
2 changes: 1 addition & 1 deletion OmsiHook/OmsiPhysObj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class OmsiPhysObj : OmsiObject
{
internal OmsiPhysObj(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiPhysObj() : base() { }
public OmsiPhysObj() : base() { }

public string FileName // ANSI String
{
Expand Down
4 changes: 2 additions & 2 deletions OmsiHook/OmsiPhysObjInst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
public class OmsiPhysObjInst : OmsiMapObjInst
{
internal OmsiPhysObjInst(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
internal OmsiPhysObjInst() : base() { }
public OmsiPhysObjInst() : base() { }

/*
* Unimplemented fields:
* TODO:Unimplemented fields:
* PdxBody PH_Body; 0x138
* PdxGeom PH_MainGeomTrafo; 0x13c
* PdxGeom PH_MainGeom; 0x140
Expand Down
2 changes: 1 addition & 1 deletion OmsiHook/OmsiRoadVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ public class OmsiRoadVehicle : OmsiVehicle
{
internal OmsiRoadVehicle(Memory omsiMemory, int baseAddress) : base(omsiMemory, baseAddress) { }
public OmsiRoadVehicle() : base() { }

/*public OMSIScriptVarIndizes ScriptVarIndizes
{
get => Memory.ReadMemory<OMSIScriptVarIndizes>(Address + 0x2b8);
set => Memory.WriteMemory(Address + 0x2b8, value);
}*/

public bool Show_Dialog
{
get => Memory.ReadMemory<bool>(Address + 0x500);
Expand Down
Loading