public LeaderboardEntry(ACSProtocolReader reader) { CarId = reader.ReadByte(); Time = TimeSpan.FromMilliseconds(reader.ReadUInt32()); Laps = reader.ReadUInt16(); HasCompleted = reader.ReadByte() != 0; }
public CarUpdateEvent(ACSProtocolReader reader) { CarId = reader.ReadByte(); Position = new Vector3f(reader); Velocity = new Vector3f(reader); Gear = reader.ReadByte(); Rpm = reader.ReadUInt16(); NormalizedSplinePosition = reader.ReadSingle(); }
public CarInfoEvent(ACSProtocolReader reader) { CarId = reader.ReadByte(); IsConnected = reader.ReadByte() != 0; Model = reader.ReadStringW(); Skin = reader.ReadStringW(); DriverName = reader.ReadStringW(); DriverTeam = reader.ReadStringW(); DriverGuid = reader.ReadStringW(); }
public LapCompletedEvent(ACSProtocolReader reader) { CarId = reader.ReadByte(); LapTime = TimeSpan.FromMilliseconds(reader.ReadUInt32()); Cuts = reader.ReadByte(); CarsCount = reader.ReadByte(); Leaderboard = new List <LeaderboardEntry>(); for (int i = 0; i < CarsCount; i++) { var entry = new LeaderboardEntry(reader); Leaderboard.Add(entry); } GripLevel = reader.ReadSingle(); }
public ClientEventEvent(ACSProtocolReader reader) { EventType = reader.ReadByte(); CarId = reader.ReadByte(); if (EventType == ACSProtocol.ACSP_CE_COLLISION_WITH_CAR) { OtherCarId = reader.ReadByte(); } else { OtherCarId = 255; } Speed = reader.ReadSingle(); WorldPosition = new Vector3f(reader); RelationalPosition = new Vector3f(reader); }
public ConnectionEvent(ACSProtocolReader reader) { DriverName = reader.ReadStringW(); DriverGuid = reader.ReadStringW(); CarId = reader.ReadByte(); CarModel = reader.ReadString(); CarSkin = reader.ReadString(); }
public readonly TimeSpan Elapsed; // Elapsed time from the start(this might be negative for races with WaitTime) public SessionInfoEvent(ACSProtocolReader reader) { Version = reader.ReadByte(); SessionIndex = reader.ReadByte(); CurrentSessionIndex = reader.ReadByte(); SessionCount = reader.ReadByte(); ServerName = reader.ReadStringW(); Track = reader.ReadString(); TrackConfig = reader.ReadString(); Name = reader.ReadString(); Type = reader.ReadByte(); Time = TimeSpan.FromSeconds(reader.ReadUInt16()); Laps = reader.ReadUInt16(); WaitTime = TimeSpan.FromSeconds(reader.ReadUInt16()); AmbientTemp = reader.ReadByte(); RoadTemp = reader.ReadByte(); WeatherGraphics = reader.ReadString(); Elapsed = TimeSpan.FromMilliseconds(reader.ReadInt32()); }
public ChatEvent(ACSProtocolReader reader) { CarId = reader.ReadByte(); Message = reader.ReadStringW(); }
public async Task DispatchMessagesAsync() { while (true) { var receiveResult = await _udpClient.ReceiveAsync(); var acsReader = new ACSProtocolReader(receiveResult.Buffer); var packetId = acsReader.ReadByte(); switch (packetId) { case ACSProtocol.ACSP_ERROR: { var message = acsReader.ReadStringW(); OnError?.Invoke(packetId, message); } break; case ACSProtocol.ACSP_CHAT: { var eventData = new ChatEvent(acsReader); OnChat?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_CLIENT_LOADED: { var carId = acsReader.ReadByte(); OnClientLoaded?.Invoke(packetId, carId); } break; case ACSProtocol.ACSP_VERSION: { var protocolVersion = acsReader.ReadByte(); OnVersion?.Invoke(packetId, protocolVersion); } break; case ACSProtocol.ACSP_NEW_SESSION: { var eventData = new SessionInfoEvent(acsReader); OnNewSession?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_SESSION_INFO: { var eventData = new SessionInfoEvent(acsReader); OnSessionInfo?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_END_SESSION: { var reportFile = acsReader.ReadStringW(); OnEndSession?.Invoke(packetId, reportFile); } break; case ACSProtocol.ACSP_CLIENT_EVENT: { var eventData = new ClientEventEvent(acsReader); OnClientEvent?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_CAR_INFO: { var eventData = new CarInfoEvent(acsReader); OnCarInfo?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_CAR_UPDATE: { var eventData = new CarUpdateEvent(acsReader); OnCarUpdate?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_NEW_CONNECTION: { var eventData = new ConnectionEvent(acsReader); OnNewConnection?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_CONNECTION_CLOSED: { var eventData = new ConnectionEvent(acsReader); OnConnectionClosed?.Invoke(packetId, eventData); } break; case ACSProtocol.ACSP_LAP_COMPLETED: { var eventData = new LapCompletedEvent(acsReader); OnLapCompleted?.Invoke(packetId, eventData); } break; } } }