Skip to main content

Game

Struct Game 

Source
pub struct Game { /* private fields */ }
Expand description

The anvil-game.game service.

Implementations§

Source§

impl Game

Source

pub fn get(host: &Host) -> Option<Self>

The service; None without anvil-game.

Source

pub fn c_api(&self) -> Table<AnvilGameService>

The C table, for what this crate does not wrap.

Source

pub fn ready(&self) -> bool

Whether anvil-game.ready was published.

Source

pub fn main_thread_id(&self) -> u32

The game’s main thread; 0 before its first frame.

Source

pub fn frame_number(&self) -> u64

The frame number of the last anvil-game.frame; 0 before it.

Source

pub fn run_on_main_thread( &self, work: impl FnOnce() + Send + 'static, ) -> Result<()>

Queues work to run on the main thread after the next frame of the main loop, in the order queued. Callable from any thread. Work still queued when the game quits never runs, and frames stop while a save loads: never wait for it without a limit.

Source

pub fn session(&self) -> Option<Session>

The running session, as of the last frame of the main loop.

Source

pub fn date(&self) -> Option<Date>

The current date while a session runs (anvil-game 1.6.0); None in the menu, while a save loads from it, or with an older anvil-game.

Source

pub fn main_menu(&self) -> Option<bool>

Whether the main menu is up (anvil-game 1.8.0); None with an older one.

Source

pub fn out_of_sync(&self) -> Option<OosFlags>

The session’s out-of-sync flags (anvil-game 1.14.0); None with an older one.

Source

pub fn keyboard(&self) -> Option<KeyboardFlags>

Whether the game’s GUI takes the keyboard for itself (anvil-game 1.18.0), read live: ask on the main thread. None with an older anvil-game or on a build that declares its symbols absent.

Source

pub fn restart(&self, host: &Host, close_campaign: bool) -> Result<()>

Asks the game for its own restart (anvil-game 1.23.0, Anvil’s ADR 0012), on the player’s request only. close_campaign is the caller’s word that the player accepted closing a running single-player campaign (ironman is saved, anything else loses its progress since the last save). WrongPhase before the game is ready, in a multiplayer session, or in a campaign without close_campaign; Unsupported with an older anvil-game or a build without its symbols. host is this plugin’s, for the log.

Source

pub fn speed(&self) -> Option<i32>

The game speed as the speed bar shows it, 1 to 5, as of the last frame (anvil-game 1.24.0); it keeps its value while paused. None without a session, with an older anvil-game or on a build without its symbols.

Source

pub fn paused(&self) -> Option<PauseFlags>

Why the game is paused, as of the last frame (anvil-game 1.24.0): Some while a session runs and is paused, None while it runs on, without a session, with an older anvil-game or on a build without its symbols. A pause for going out of sync is Game::out_of_sync’s.

Source

pub fn user_dir(&self) -> Option<PathBuf>

The game’s own write folder, where it keeps save games, logs and settings.txt (by default Documents\Paradox Interactive\Europa Universalis IV, or what -userdir and userdir.txt choose). None until the game set it at start-up (it has by anvil-game.ready), with an older anvil-game or on a build without its symbol. Any thread.

Trait Implementations§

Source§

impl Clone for Game

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Game

Source§

impl Debug for Game

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Game

§

impl Freeze for Game

§

impl Move for Game

§

impl RefUnwindSafe for Game

§

impl Send for Game

§

impl Sync for Game

§

impl Unpin for Game

§

impl UnsafeUnpin for Game

§

impl UnwindSafe for Game

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.