Coder Social home page Coder Social logo

cccarv82 / iracingsdk.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from merlincooper/iracingsdk.net

0.0 0.0 0.0 1.53 MB

Alternative dot.net (c#) implementation to access iracing game data

License: GNU General Public License v3.0

C# 99.75% Batchfile 0.25%

iracingsdk.net's Introduction

#iRacingSDK.Net - Alternative

[Build status

This dot.net library allows access to the raw data stream from the iRacing Motorsport Racing simulation (www.iracing.com). It also provides an interface to control certain aspects of the game. It is based on the official C++ SDK.

It provides access to the game's data interface using conventional dot.net paradigms.

At this point in time, it is heavily focused on supporting the data stream provided by the game during a replay session. But it should also be useful for live non-replay mode.

There are other dot.net implementations of the iRacing SDK library - see the iRacing Developer's forum for references and downloads for those.

##Accessing game data

You can use the enumeration access of the iRacing class to access a stream of data samples, generated by the game. For example, to get a single sample you can use the following:

var iracing = new iRacingConnection();
var data = iracing.GetDataFeed().First();

This will return a single DataSample value.

Alternatively you can get a infinite sample set, or a set of samples until some condition is met.

foreach( var data in iracing
             .GetDataFeed()
             .TakeWhile( d => d.Telemetry.SessionState != SessionState.CoolDown ))
{
    Console.WriteLine(data.Telemetry.RaceLaps);

    Thread.Sleep(1000);
}

Console.WriteLine("Finished.");

For more examples of accessing this data - checkout the Sample project within this repo.

##Access game data via Events

You can access the DataSample in an event handler. Add your event handler to the NewData event of the iRacing type.

public void Setup()
{
    ...
    iracing.NewData += iRacing_NewData;
    iracing.StartListening();
}

void iRacing_NewData(DataSample data)
{
    var tractionControl = data.Telemetry.dcTractionControl;

    ...
}

NB: You can not access the GetDataFeed() enumerator inside an Event Handler - You can not use the two types of accessors to DataSamples - events or enumerators - but not both.

##Sending Messages to the game

You can use the Replay object to control various aspects of the game. For example, to change the camera to a specific car:

var data = iracing.GetDataFeed().First();
var camera = data.SessionData.CameraInfo.Groups.First(g => g.GroupName == "TV3");

var carIdx = 3;
var number = data.SessionData.DriverInfo.Drivers[carIdx].CarNumberRaw;
iRacing.Replay.CameraOnDriver((short)number, (short)camera.GroupNum, 0);

##DataSample

This type is the container for all data retrieved from iRacing. More details here

##Data Feed Filters

There are a set of extension methods to the IEnumerable<DataSample> set to enhance and refine some of the game's data stream. More details here

iracingsdk.net's People

Contributors

vipoo avatar merlincooper avatar herbstein 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.