Struct GameState

Source
pub struct GameState {
Show 14 fields characters: HashMap<u32, Shared<GameObjectEntity<Character>>>, titles: HashMap<u32, Shared<GameObjectEntity<Title>>>, faiths: HashMap<u32, Shared<GameObjectEntity<Faith>>>, cultures: HashMap<u32, Shared<GameObjectEntity<Culture>>>, dynasties: HashMap<u32, Shared<GameObjectEntity<Dynasty>>>, houses: HashMap<u32, Shared<GameObjectEntity<House>>>, memories: HashMap<u32, Shared<GameObjectEntity<Memory>>>, artifacts: HashMap<u32, Shared<GameObjectEntity<Artifact>>>, traits_lookup: Vec<Rc<str>>, contract_transform: HashMap<u32, Shared<Option<Shared<GameObjectEntity<Character>>>>>, character_transform: HashMap<u32, u32>, county_data: HashMap<String, (Shared<GameObjectEntity<Faith>>, Shared<GameObjectEntity<Culture>>)>, current_date: Option<Date>, offset_date: Option<Date>,
}
Expand description

A struct representing all known game objects. It is guaranteed to always return a reference to the same object for the same key. Naturally the value of that reference may change as values are added to the game state. This is mainly used during the process of gathering data from the parsed save file.

Fields§

§characters: HashMap<u32, Shared<GameObjectEntity<Character>>>

A character id->Character transform

§titles: HashMap<u32, Shared<GameObjectEntity<Title>>>

A title id->Title transform

§faiths: HashMap<u32, Shared<GameObjectEntity<Faith>>>

A faith id->Title transform

§cultures: HashMap<u32, Shared<GameObjectEntity<Culture>>>

A culture id->Culture transform

§dynasties: HashMap<u32, Shared<GameObjectEntity<Dynasty>>>

A dynasty id->Dynasty transform

§houses: HashMap<u32, Shared<GameObjectEntity<House>>>§memories: HashMap<u32, Shared<GameObjectEntity<Memory>>>

A memory id->Memory transform

§artifacts: HashMap<u32, Shared<GameObjectEntity<Artifact>>>

A artifact id->Artifact transform

§traits_lookup: Vec<Rc<str>>

A trait id->Trait identifier transform

§contract_transform: HashMap<u32, Shared<Option<Shared<GameObjectEntity<Character>>>>>

A vassal contract id->Character transform

§character_transform: HashMap<u32, u32>§county_data: HashMap<String, (Shared<GameObjectEntity<Faith>>, Shared<GameObjectEntity<Culture>>)>§current_date: Option<Date>

The current date from the meta section

§offset_date: Option<Date>

The time Y.M.D from which the game started

Implementations§

Source§

impl GameState

Source

pub fn add_lookup(&mut self, array: Vec<Rc<str>>)

Add a lookup table for traits

Source

pub fn add_character_transform(&mut self, transform: HashMap<u32, u32>)

Source

pub fn get_trait(&self, id: u16) -> Rc<str>

Get a trait by id

Source

pub fn set_current_date(&mut self, date: Date, offset: Date)

Set the current date

Source

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

Get the current date

Source

pub fn get_character( &mut self, key: &u32, ) -> Shared<GameObjectEntity<Character>>

Get a character by key

Source

pub fn get_vassal( &mut self, contract_id: &u32, ) -> Shared<Option<Shared<GameObjectEntity<Character>>>>

Gets the vassal associated with the contract with the given id

Source

pub fn add_contract(&mut self, contract_id: &u32, character_id: &u32)

Adds a new vassal contract

Source

pub fn get_title(&mut self, key: &u32) -> Shared<GameObjectEntity<Title>>

Get a title by key

Source

pub fn get_faith(&mut self, key: &u32) -> Shared<GameObjectEntity<Faith>>

Get a faith by key

Source

pub fn get_culture(&mut self, key: &u32) -> Shared<GameObjectEntity<Culture>>

Get a culture by key

Source

pub fn get_dynasty(&mut self, key: &u32) -> Shared<GameObjectEntity<Dynasty>>

Get a dynasty by key

Source

pub fn get_memory(&mut self, key: &u32) -> Shared<GameObjectEntity<Memory>>

Get a memory by key

Source

pub fn get_artifact(&mut self, key: &u32) -> Shared<GameObjectEntity<Artifact>>

Get an artifact by key

Source

pub fn get_house(&mut self, key: &u32) -> Shared<GameObjectEntity<House>>

Source

pub fn add_house( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Source

pub fn add_artifact( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Source

pub fn add_character( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Add a character to the game state

Source

pub fn add_title( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Add a title to the game state

Source

pub fn add_faith( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Add a faith to the game state

Source

pub fn add_culture( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Add a culture to the game state

Source

pub fn add_dynasty( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Add a dynasty to the game state

Source

pub fn add_memory( &mut self, key: &u32, value: &HashMap<String, SaveFileValue>, ) -> Result<(), ParsingError>

Add a memory to the game state

Source

pub fn get_baronies_of_counties<F: Fn(&Title) -> bool>( &self, filter: F, ) -> Vec<Rc<str>>

Source

pub fn add_county_data( &mut self, county_data: HashMap<String, (Shared<GameObjectEntity<Faith>>, Shared<GameObjectEntity<Culture>>)>, )

Source

pub fn new_grapher(&self) -> Grapher

Source

pub fn new_timeline(&self) -> Timeline

Trait Implementations§

Source§

impl Default for GameState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Localizable for GameState

Source§

fn localize(&mut self, localization: &GameData) -> Result<(), LocalizationError>

Localizes the object.
Source§

impl Serialize for GameState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V