public override void UpdateLights(EffectFrame frame) { Queue <EffectLayer> layers = new Queue <EffectLayer>(); ETS2Profile settings = (ETS2Profile)this.Application.Profile; if (Process.GetProcessesByName(processName).Length > 0 && memAccessor != null) { // -- Below code adapted from the ETS2 Telemetry Server by Funbit (https://github.com/Funbit/ets2-telemetry-server) -- IntPtr memPtr = IntPtr.Zero; try { byte[] raw = new byte[Marshal.SizeOf(typeof(ETS2MemoryStruct))]; memAccessor.ReadArray(0, raw, 0, raw.Length); memPtr = Marshal.AllocHGlobal(raw.Length); Marshal.Copy(raw, 0, memPtr, raw.Length); _game_state = new GameState_ETS2((ETS2MemoryStruct)Marshal.PtrToStructure(memPtr, typeof(ETS2MemoryStruct))); } finally { if (memPtr != IntPtr.Zero) { Marshal.FreeHGlobal(memPtr); } } // -- End ETS2 Telemetry Server code -- } foreach (var layer in this.Application.Profile.Layers.Reverse().ToArray()) { if (layer.Enabled && layer.LogicPass) { layers.Enqueue(layer.Render(_game_state)); } } this.Application.UpdateEffectScripts(layers); frame.AddLayers(layers.ToArray()); }
public override void UpdateTick() { if (Process.GetProcessesByName(processName).Length > 0 && memAccessor != null) { // -- Below code adapted from the ETS2 Telemetry Server by Funbit (https://github.com/Funbit/ets2-telemetry-server) -- IntPtr memPtr = IntPtr.Zero; try { byte[] raw = new byte[Marshal.SizeOf(typeof(ETS2MemoryStruct))]; memAccessor.ReadArray(0, raw, 0, raw.Length); memPtr = Marshal.AllocHGlobal(raw.Length); Marshal.Copy(raw, 0, memPtr, raw.Length); _game_state = new GameState_ETS2((ETS2MemoryStruct)Marshal.PtrToStructure(memPtr, typeof(ETS2MemoryStruct))); } finally { if (memPtr != IntPtr.Zero) { Marshal.FreeHGlobal(memPtr); } } // -- End ETS2 Telemetry Server code -- } }
public override void ResetGameState() { _game_state = new GameState_ETS2(default(ETS2MemoryStruct)); }