#pragma once #include "RocketSim.h" #include "rust/cxx.h" using namespace RocketSim; const CarConfig& getOctane(); const CarConfig& getDominus(); const CarConfig& getPlank(); const CarConfig& getBreakout(); const CarConfig& getHybrid(); const CarConfig& getMerc(); void Init(rust::Str collision_meshes_folder, bool silent); void InitFromMem(rust::Slice> soccar, rust::Slice> hoops); Angle AngleFromRotMat(RotMat mat); struct EArenaConfig { ArenaMemWeightMode memWeightMode; Vec minPos, maxPos; float maxAABBLen; bool noBallRot; bool useCustomBroadphase; int maxObjects; }; struct EBoostPadState { bool isActive; float cooldown; uint32_t curLockedCarId = 0; uint32_t prevLockedCarID = 0; }; struct Arenar { Arena* a; Arenar(Arena* arena) { a = arena; } Arenar(GameMode game_mode, EArenaConfig arenaConfig, float tick_rate) { ArenaConfig config = ArenaConfig { .memWeightMode = (ArenaMemWeightMode) arenaConfig.memWeightMode, .minPos = Vec(arenaConfig.minPos.x, arenaConfig.minPos.y, arenaConfig.minPos.z), .maxPos = Vec(arenaConfig.maxPos.x, arenaConfig.maxPos.y, arenaConfig.maxPos.z), .maxAABBLen = arenaConfig.maxAABBLen, .noBallRot = arenaConfig.noBallRot, .useCustomBroadphase = arenaConfig.useCustomBroadphase, .maxObjects = arenaConfig.maxObjects, .useCustomBoostPads = false, .customBoostPads = {} }; a = Arena::Create(game_mode, config, tick_rate); } ~Arenar() { delete a; } void SetGoalScoreCallback(rust::Fn callback, size_t); void SetCarBumpCallback(rust::Fn callback, size_t user_info); // No copy constructor Arenar(const Arenar & other) = delete; Arenar & operator =(const Arenar & other) = delete; // Move constructor Arenar(Arenar&& other) = default; Arenar& operator =(Arenar && other) = default; std::unique_ptr Clone(bool copy_callbacks) const { return std::make_unique(a->Clone(copy_callbacks)); } // extra car stuff size_t NumCars() const { return a->_cars.size(); } rust::Vec GetCars() const; CarConfig GetCarConfig(uint32_t car_id) const { return a->GetCar(car_id)->config; } Team GetCarTeam(uint32_t car_id) const { return a->GetCar(car_id)->team; } CarState GetCar(uint32_t car_id); /// @brief Sets the state of a car in the arena /// @param arena /// @param state /// @param carID /// @return True if the car was found and the state was set, false otherwise bool SetCar(uint32_t car_id, const CarState state); uint32_t AddCar(Team team, const CarConfig& config) { return a->AddCar(team, config)->id; } bool RemoveCar(uint32_t car_id); /// @brief Sets the controls of a car for the next tick /// @param arena /// @param state /// @param carID /// @return True if the car was found and the state was set, false otherwise bool SetCarControls(uint32_t car_id, const CarControls controls); bool DemolishCar(uint32_t car_id); bool RespawnCar(uint32_t car_id, int32_t seed, float boost_amount); // extra ball stuff BallState GetBall() { return a->ball->GetState(); } void SetBall(const BallState state) { a->ball->SetState(state); } float GetBallRadius() const { return a->ball->GetRadius(); } // boost pad stuff size_t NumPads() const { return a->_boostPads.size(); } BoostPadConfig GetPadConfig(size_t index) const; void SetPadState(size_t index, const EBoostPadState state); EBoostPadState GetPadState(size_t index) const; // extra misc stuff void ResetTickCount() { a->tickCount = 0; } uint64_t GetTickCount() const { return a->tickCount; } float GetTickRate() const { return 1 / a->tickTime; } GameMode GetGameMode() const { return a->gameMode; } void ResetToRandomKickoff(int32_t seed = -1) { a->ResetToRandomKickoff(seed); } void Step(uint32_t ticks = 1) { a->Step(ticks); } bool IsBallProbablyGoingIn(float maxTime = 2.f, float extraMargin = 0) const { return a->IsBallProbablyGoingIn(maxTime, extraMargin); } bool IsBallScored() const { return a->IsBallScored(); } MutatorConfig GetMutatorConfig() const { return a->GetMutatorConfig(); } void SetMutatorConfig(MutatorConfig mutatorConfig) { a->SetMutatorConfig(mutatorConfig); } }; std::unique_ptr CreateArena(GameMode game_mode, EArenaConfig arenaConfig, uint8_t tick_rate);