pub struct Host { /* private fields */ }Expand description
Implementations§
Source§impl Host
impl Host
Sourcepub fn game_resource(&self, key: ResourceKey) -> Option<Vec<u8>>
pub fn game_resource(&self, key: ResourceKey) -> Option<Vec<u8>>
A vanilla resource’s bytes from the game’s archive; see
game_resource.
§Examples
use enshwick::content::{Guid, types};
if let Some(host) = enshwick::host() {
let chest = Guid::parse("6943053a-32c1-4718-ae22-e61427ddf54d");
if let Ok(key) = chest.key(types::ITEM_INFO) {
let _ = host.game_resource(key);
}
}Source§impl Host
impl Host
Sourcepub fn api(&self) -> &'static HostApi
pub fn api(&self) -> &'static HostApi
The raw table, for calls the safe layer does not wrap.
§Examples
if let Some(host) = enshwick::host() {
assert_eq!(host.api().header.abi_major, enshwick::abi::ABI_MAJOR);
}Sourcepub fn handle(&self) -> ModHandle
pub fn handle(&self) -> ModHandle
This mod’s handle.
§Examples
if let Some(host) = enshwick::host() {
assert_ne!(host.handle(), enshwick::abi::ModHandle::NONE);
}Sourcepub fn build(&self) -> BuildInfo
pub fn build(&self) -> BuildInfo
The running game: side, image base and build fingerprint.
§Examples
if let Some(host) = enshwick::host() {
let build = host.build();
assert_ne!(build.base, 0);
}Sourcepub fn hosting(&self) -> bool
pub fn hosting(&self) -> bool
Whether this process runs a game server now: always on the dedicated server; on the client while it hosts a game, solo play included, from the built-in server’s first step until the game stops.
§Examples
if let Some(host) = enshwick::host() {
let acts = host.hosting();
}Sourcepub fn log_level(&self) -> Level
pub fn log_level(&self) -> Level
The most detailed level the loader keeps for this mod’s lines, from
mod-configs/enshwick.toml.
§Examples
use enshwick::abi::Level;
if let Some(host) = enshwick::host() {
let verbose = host.log_level() >= Level::DEBUG;
}Sourcepub fn fault(&self, reason: &str)
pub fn fault(&self, reason: &str)
Reports that this mod failed at run time. The loader unlinks every hook of the mod, so the game runs vanilla where the mod was.
§Examples
if let Some(host) = enshwick::host() {
host.fault("the altar table is corrupt");
}Sourcepub fn caller_frame(&self) -> CallerFrame
pub fn caller_frame(&self) -> CallerFrame
The game caller’s context at entry of the running hook chain, for hooks
declared with HookFlags::CALLER_FRAME.
Valid until the hook calls anything hooked.
§Examples
if let Some(host) = enshwick::host() {
let frame = host.caller_frame();
let _ = frame.stack();
}