Exemple #1
0
    public void ApiTick(iRacingSDK api)
    {
        if (this.position < length)
        {
            switch (this.state)
            {
                case 1:
                    api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, this.max_value - ease(this.position) + 1, 1);
                    break;
                case -1:
                    api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, ease(this.position), 1);
                    break;
                default:
                    break;
            }
        }
        else if (this.position >= length+10 && this.state != 0)
        {
            Console.WriteLine("Finished..." + this.state);
            if(this.state == 1)
                api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 1, 0);
            else if(this.state == -1)
                api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, this.max_value, 1);
            this.state = 0;
        }

        if(this.state != 0)
            position++;
    }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
                return;

            Bookmarks myBookmarks = new Bookmarks(); ;
            Bookmark thisEvent = null;
            int currentIndex = 0;
            int CurrentFrame = 0;
            bool run = true;
            using (StreamReader sw = new StreamReader(args[0], Encoding.UTF8))
            {
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(myBookmarks.GetType());
                myBookmarks = x.Deserialize(sw) as Bookmarks;
            }

            Console.WriteLine("Waiting for iRacing to come up ....");
            sdk = new iRacingSDK();
            while (!Console.KeyAvailable && run)
            {
                //Check if the SDK is connected
                if (sdk.IsConnected())
                {
                    while (sdk.GetData("SessionNum") == null)
                    {
                        Console.WriteLine("Waiting for Session...");
                        Thread.Sleep(200); // Allow other windows to initialize more faster
                        
                    }
                    
                    thisEvent = myBookmarks.List[currentIndex];

                    switch (thisEvent.BookmarkType)
                    {
                        case BookmarkType.Start:
                            ReplaySeek( thisEvent );
                            currentIndex++;
                            break;
                        case BookmarkType.Play:                            
                            CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                            if (CurrentFrame < thisEvent.ReplayPos)
                                continue;
                            sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.CamSwitchNum, thisEvent.DriverIdx, thisEvent.CamIdx);
                            SetPlaySpeed(thisEvent.PlaySpeed);
                            currentIndex++;
                            break;
                        case BookmarkType.Stop:
                            CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                            if (CurrentFrame < thisEvent.ReplayPos)
                                continue;
                            sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 0, 0);
                            Console.WriteLine("End");
                            run = false;
                            break;
                        default:
                            run = false;
                            break;
                    }
                            
                    
                }
                else
                {                    
                    if ( sdk.Startup() )
                    {
                        Console.WriteLine("iRacing up and running.");
                    }
                    else
                        Thread.Sleep(2000);
                }
            }
            sdk.Shutdown();
        }