pub struct TerrainCache { /* private fields */ }
Expand description
A simple passthrough cache that preferentially returns cached terrain data, dynamically pulling terrain data as-needed from game state and caching it before returning it.
Implementations§
Source§impl TerrainCache
impl TerrainCache
Sourcepub fn get_cached_terrain(
&self,
room_name: &RoomName,
) -> Option<&LocalRoomTerrain>
pub fn get_cached_terrain( &self, room_name: &RoomName, ) -> Option<&LocalRoomTerrain>
Returns the cached room terrain, if it exists.
Returns None if the room terrain isn’t cached.
Sourcepub fn is_terrain_cached(&self, room_name: &RoomName) -> bool
pub fn is_terrain_cached(&self, room_name: &RoomName) -> bool
Returns whether the terrain is cached for a particular room.
Sourcepub fn get_terrain(&mut self, room_name: &RoomName) -> Option<&LocalRoomTerrain>
pub fn get_terrain(&mut self, room_name: &RoomName) -> Option<&LocalRoomTerrain>
Returns the room terrain, pulling and caching it from the game state if it’s not already cached.
Returns None only if screeps::objects::RoomTerrain::new returns None.
Note: This method can, but might not, pull from the game state, which requires crossing the WASM boundary.
Sourcepub fn update_cached_terrain(
&mut self,
room_name: RoomName,
local_terrain: LocalRoomTerrain,
)
pub fn update_cached_terrain( &mut self, room_name: RoomName, local_terrain: LocalRoomTerrain, )
Updates the terrain cache for a specific room.
This allows for pre-loading the cache with any existing room terrain you might already have available.
Sourcepub fn remove_cached_terrain(&mut self, room_name: &RoomName)
pub fn remove_cached_terrain(&mut self, room_name: &RoomName)
Removes the terrain cached for a specific room.
Trait Implementations§
Source§impl Clone for TerrainCache
impl Clone for TerrainCache
Source§fn clone(&self) -> TerrainCache
fn clone(&self) -> TerrainCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more