R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
rtype::Bot Class Reference

A client without window nor sound: a ClientSession whose inputs are RandomInputs, or ScriptedInputs when its settings have a script. More...

#include </__w/project-rtype/project-rtype/tools/bot/include/rtype/bot.hpp>

Public Types

using Clock = std::chrono::steady_clock
 Clock of the session and the inputs.
 

Public Member Functions

 Bot (aegis2d::net::NetworkContext &context, const BotSettings &settings)
 Creates a bot, not started.
 
void start ()
 Connects to the server and logs in.
 
void update (Clock::time_point now)
 Runs the session's timers and, in game, picks the inputs; a script starts at the first update in game.
 
void leave ()
 Leaves the server: sends Logout; keep running the context a little for it to leave.
 
const ClientSession & session () const noexcept
 The session with the server: its state, error, traffic and world.
 
aegis2d::ecs::PlayerInput input () const noexcept
 The actions held now.
 
std::uint64_t picks () const noexcept
 Number of inputs picked: random holds, or steps of the script.
 

Detailed Description

A client without window nor sound: a ClientSession whose inputs are RandomInputs, or ScriptedInputs when its settings have a script.

start() joins the server as any client does (TCP login, then UDP binding); once in game, update() sends its inputs, one Input per server tick, which also keep the session alive. leave() says goodbye with Logout. Same threading rules as ClientSession: use it on the thread running the context.

Member Typedef Documentation

◆ Clock

using rtype::Bot::Clock = std::chrono::steady_clock

Clock of the session and the inputs.

Constructor & Destructor Documentation

◆ Bot()

rtype::Bot::Bot ( aegis2d::net::NetworkContext &  context,
const BotSettings &  settings 
)

Creates a bot, not started.

Parameters
contextContext that runs its sockets; it must outlive this object.
settingsServer, name and seed.

Member Function Documentation

◆ input()

aegis2d::ecs::PlayerInput rtype::Bot::input ( ) const
noexcept

The actions held now.

Returns
The last input given to the session.

◆ leave()

void rtype::Bot::leave ( )

Leaves the server: sends Logout; keep running the context a little for it to leave.

◆ picks()

std::uint64_t rtype::Bot::picks ( ) const
noexcept

Number of inputs picked: random holds, or steps of the script.

Returns
The count since the game started.

◆ session()

const ClientSession & rtype::Bot::session ( ) const
noexcept

The session with the server: its state, error, traffic and world.

Returns
The session.

◆ start()

void rtype::Bot::start ( )

Connects to the server and logs in.

◆ update()

void rtype::Bot::update ( Clock::time_point  now)

Runs the session's timers and, in game, picks the inputs; a script starts at the first update in game.

Parameters
nowCurrent time.

The documentation for this class was generated from the following file: