Coder Social home page Coder Social logo

vatthaphon / accsharedmemory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codermaff/accsharedmemory

0.0 0.0 0.0 33 KB

Based on https://github.com/mdjarv/assettocorsasharedmemory. Updated to ACC 1.8 For documentation go to https://github.com/mdjarv/assettocorsasharedmemory/blob/master/README.md

License: MIT License

C# 100.00%

accsharedmemory's Introduction

This package is based on https://github.com/ProBun/ACCSharedMemory who made this https://github.com/mdjarv/assettocorsasharedmemory work with ACC.

Maff updated it to ACC 1.8.x from documentation supplied here : https://www.assettocorsa.net/forum/index.php?threads/acc-shared-memory-documentation.59965/

Assetto Corsa Shared Memory Library

Assetto Corsa Shared Memory library written in C# to access live game data

The code was built around the shared memory structures described here on the official Assetto Corsa forum: http://www.assettocorsa.net/forum/index.php?threads/shared-memory-reference.3352/

class: AssettoCorsa

This is the centerpiece of the library. Using this you can add your own event listeners to trigger for updates.

There are three events to listen for:

  • AssettoCorsa.StaticInfoUpdated
  • AssettoCorsa.GraphicsUpdated
  • AssettoCorsa.PhysicsUpdated

These events have individual timers and their respective update intervals can be changed to fit your own needs. Timers will not be running if an event has no listeners.

The default update intervals are:

AssettoCorsa.StaticInfoInterval: 1000 ms
AssettoCorsa.GraphicsInterval: 1000 ms
AssettoCorsa.PhysicsInterval: 10 ms

The AssettoCorsa.Start() and AssettoCorsa.Stop() functions are to connect and disconnect from the shared memory and also to start and stop the timers for the events. After you've executed Start() you can use IsRunning to check if it successfully connected to the shared memory.

Usage Example

In Visual Studio you have two easy options:

  1. Add the AssettoCorsaSharedMemory.dll as a reference to your project
  2. Add the complete AssettoCorsaSharedMemory project to your solution and then add it as a reference

Here is some example code to read the StaticInfo and output it to the console:

using AssettoCorsaSharedMemory;
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            AssettoCorsa ac = new AssettoCorsa();
            ac.StaticInfoInterval = 5000; // Get StaticInfo updates ever 5 seconds
            ac.StaticInfoUpdated += ac_StaticInfoUpdated; // Add event listener for StaticInfo
            ac.Start(); // Connect to shared memory and start interval timers 

            Console.ReadKey();
        }

        static void ac_StaticInfoUpdated(object sender, StaticInfoEventArgs e)
        {
            // Print out some data from StaticInfo
            Console.WriteLine("StaticInfo");
            Console.WriteLine("  Car Model: " + e.StaticInfo.CarModel);
            Console.WriteLine("  Track:     " + e.StaticInfo.Track);
            Console.WriteLine("  Max RPM:   " + e.StaticInfo.MaxRpm);
        }
    }
}

accsharedmemory's People

Contributors

mdjarv avatar probun avatar codermaff avatar probosch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.