public static BotState ParseFromGameState(GameState gameState, int botIndex) { BotState botState = new BotState(); rlbot.flat.PlayerInfo info = gameState.GetPlayerInfo(botIndex); botState.Location = Conversion.ToVector3(info.Physics.GetValueOrDefault().Location.GetValueOrDefault()); botState.Rotation = Conversion.ToRotation(info.Physics.GetValueOrDefault().Rotation.GetValueOrDefault()); return(botState); }
public Player(rlbot.flat.PlayerInfo playerInfo) { Physics = new Physics(playerInfo.Physics.Value); IsSupersonic = playerInfo.IsSupersonic; HasWheelContact = playerInfo.HasWheelContact; Jumped = playerInfo.Jumped; DoubleJumped = playerInfo.DoubleJumped; Name = playerInfo.Name; Team = playerInfo.Team; Boost = playerInfo.Boost; }
public void Update(rlbot.flat.PlayerInfo car, float dt) { if (car.Physics.HasValue) { if (car.Physics.Value.Location.HasValue) { Position = car.Physics.Value.Location.Value.ToVector3(); } if (car.Physics.Value.Velocity.HasValue) { Velocity = car.Physics.Value.Velocity.Value.ToVector3(); } if (car.Physics.Value.Rotation.HasValue) { Rotation = car.Physics.Value.Rotation.Value.ToQuaternion(); } if (car.Physics.Value.AngularVelocity.HasValue) { AngularVelocity = car.Physics.Value.AngularVelocity.Value.ToVector3(); } } Forward = Vector3.Transform(Vector3.UnitX, Rotation); Left = Vector3.Transform(Vector3.UnitY, Rotation); Up = Vector3.Transform(Vector3.UnitZ, Rotation); Jumped = car.Jumped; DoubleJumped = car.DoubleJumped; HasWheelContact = car.HasWheelContact; if (HasWheelContact) { CanDodge = false; DodgeTimer = 1.5f; } else if (DoubleJumped) { CanDodge = false; DodgeTimer = 0; } else if (Jumped) { DodgeTimer -= dt; if (DodgeTimer < 0) { DodgeTimer = 0; } CanDodge = DodgeTimer > 0f; } else { CanDodge = true; } IsSupersonic = car.IsSupersonic; IsDemolished = car.IsDemolished; Boost = car.Boost; Team = car.Team; Name = car.Name; }