Arena

The Arena class is the highest level class, which contains all Car instances, the Ball, and the arena collision geometry.

class Arena

The container for all game simulation Stores cars, the ball, all arena collisions, and manages the overall game state.

Public Functions

inline float GetTickRate()

Time in seconds each tick (1/tickrate)

inline const vector<Car*> &GetCars()
inline const vector<BoostPad*> &GetBoostPads()
Car *AddCar(Team team, const CarConfig &config = CAR_CONFIG_OCTANE)
bool RemoveCar(Car *car)

Returns false if the car was not found in the cars list NOTE: If the car was removed, the car will be freed and the pointer will be made invalid.

Car *GetCarFromID(uint32_t id)
void SetGoalScoreCallback(GoalScoreEventFn callbackFn, void *userInfo = NULL)
void WriteToFile(std::filesystem::path path)

Serialize cars, ball, and boostpads to a file.

Arena(const Arena &other) = delete

No copy constructor, use Arena::Clone() instead.

Arena &operator=(const Arena &other) = delete
Arena(Arena &&other) = delete

No move constructor.

Arena &operator=(Arena &&other) = delete
Arena *Clone(bool copyCallbacks)

Get a deep copy of the arena.

Car *DeserializeNewCar(DataStreamIn &in, Team team)
void Step(int ticksToSimulate = 1)

Simulate everything in the arena for a given number of ticks.

void ResetToRandomKickoff(int seed = -1)
~Arena()

Free all associated memory.

Public Members

GameMode gameMode
Ball *ball
float tickTime
uint64_t tickCount = 0

Total ticks this arena instance has been simulated for, never resets.

btCollisionConfiguration *collisionConfig
btCollisionDispatcher *collisionDispatcher
btDbvtBroadphase *overlappingPairCache
btConstraintSolver *constraintSolver
GoalScoreEventFn func = NULL
void *userInfo = NULL

Public Static Functions

static Arena *Create(GameMode gameMode, float tickRate = 120)

NOTE: Arena should be destroyed after use.

static Arena *LoadFromFile(std::filesystem::path path)

Create a new arena from a file written by Arena.WriteToFile()

static void SerializeCar(DataStreamOut &out, Car *car)