pub struct Game { /* private fields */ }Expand description
The anvil-game.game service.
Implementations§
Source§impl Game
impl Game
Sourcepub fn c_api(&self) -> Table<AnvilGameService>
pub fn c_api(&self) -> Table<AnvilGameService>
The C table, for what this crate does not wrap.
Sourcepub fn main_thread_id(&self) -> u32
pub fn main_thread_id(&self) -> u32
The game’s main thread; 0 before its first frame.
Sourcepub fn frame_number(&self) -> u64
pub fn frame_number(&self) -> u64
The frame number of the last anvil-game.frame; 0 before it.
Sourcepub fn run_on_main_thread(
&self,
work: impl FnOnce() + Send + 'static,
) -> Result<()>
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.
Sourcepub fn session(&self) -> Option<Session>
pub fn session(&self) -> Option<Session>
The running session, as of the last frame of the main loop.
Sourcepub fn date(&self) -> Option<Date>
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.
Whether the main menu is up (anvil-game 1.8.0); None with an older one.
Sourcepub fn out_of_sync(&self) -> Option<OosFlags>
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.
Sourcepub fn keyboard(&self) -> Option<KeyboardFlags>
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.
Sourcepub fn restart(&self, host: &Host, close_campaign: bool) -> Result<()>
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.
Sourcepub fn speed(&self) -> Option<i32>
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.
Sourcepub fn paused(&self) -> Option<PauseFlags>
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.
Sourcepub fn user_dir(&self) -> Option<PathBuf>
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.