[−][src]Enum screeps::objects::Structure
Wrapper which can be any of the game Structures.
This is somewhat useful by itself, but has additional utility methods. Some tricks:
To get a particular type, match
on the structure:
use screeps::Structure; match my_struct { Structure::Container(cont) => { // cont here is StructureContainer } _ => { // other structure } }
To use structures of a particular type, like something that can be attacked, or something that can be transfered to, use helper methods:
use screeps::Structure; match my_struct.as_transferable() { Some(transf) => { // transf is a reference to `dyn Transferable`, and you can transfer to it. } None => { // my_struct is not transferable } }
See method documentation for a full list of possible helpers.
Variants
Container(StructureContainer)
Controller(StructureController)
Extension(StructureExtension)
Extractor(StructureExtractor)
KeeperLair(StructureKeeperLair)
Lab(StructureLab)
Link(StructureLink)
Nuker(StructureNuker)
Observer(StructureObserver)
PowerBank(StructurePowerBank)
PowerSpawn(StructurePowerSpawn)
Portal(StructurePortal)
Rampart(StructureRampart)
Road(StructureRoad)
Spawn(StructureSpawn)
Storage(StructureStorage)
Terminal(StructureTerminal)
Tower(StructureTower)
Wall(StructureWall)
Methods
impl Structure
[src]
pub fn as_transferable(&self) -> Option<&dyn Transferable>
[src]
Cast this structure as something Transferable, or return None if it isn't.
Example usage:
use screeps::{Creep, Structure, ResourceType}; match my_struct.as_transferable() { Some(transf) => { // transf is a reference to `dyn Transferable`, and you can transfer to it. my_creep.transfer_all(transf, ResourceType::Energy); } None => { // my_struct cannot be transfered to } }
pub fn as_withdrawable(&self) -> Option<&dyn Withdrawable>
[src]
Cast this as something which can be withdrawn from
pub fn as_attackable(&self) -> Option<&dyn Attackable>
[src]
Cast this as something which can be attacked and has hit points.
The only Structure which cannot be attacked is StructureController
.
pub fn as_owned(&self) -> Option<&dyn OwnedStructureProperties>
[src]
Cast this as something which can be owned.
Example:
use screeps::Structure; let is_my = my_struct.as_owned().map(|os| os.my()).unwrap_or(false);
pub fn as_can_decay(&self) -> Option<&dyn CanDecay>
[src]
pub fn as_can_store_energy(&self) -> Option<&dyn CanStoreEnergy>
[src]
pub fn as_has_cooldown(&self) -> Option<&dyn HasCooldown>
[src]
pub fn as_has_energy_for_spawn(&self) -> Option<&dyn HasEnergyForSpawn>
[src]
pub fn as_has_store(&self) -> Option<&dyn HasStore>
[src]
Trait Implementations
impl HasId for Structure
[src]
impl RoomObjectProperties for Structure
[src]
impl StructureProperties for Structure
[src]
fn structure_type(&self) -> StructureType
[src]
fn destroy(&self) -> ReturnCode
[src]
fn is_active(&self) -> bool
[src]
fn notify_when_attacked(&self, notify_when_attacked: bool) -> ReturnCode
[src]
Usable on either owned structures or neutral structures in owned rooms, returns ReturnCode::NotOwner
otherwise. Read more
fn as_structure(self) -> Structure where
Self: SizedRoomObject,
[src]
Self: SizedRoomObject,
impl FromExpectedType<Reference> for Structure
[src]
fn from_expected_type(reference: Reference) -> Result<Self, ConversionError>
[src]
impl From<Structure> for Reference
[src]
impl PartialEq<Structure> for Structure
[src]
fn eq(&self, other: &Structure) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl AsRef<Reference> for Structure
[src]
impl Eq for Structure
[src]
impl TryFrom<Reference> for Structure
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: Reference) -> Result<Self, ConversionError>
[src]
impl TryFrom<Value> for Structure
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(v: Value) -> Result<Structure, Self::Error>
[src]
impl InstanceOf for Structure
[src]
fn instance_of(reference: &Reference) -> bool
[src]
impl ReferenceType for Structure
[src]
unsafe fn from_reference_unchecked(reference: Reference) -> Self
[src]
Auto Trait Implementations
impl Unpin for Structure
impl Sync for Structure
impl Send for Structure
impl RefUnwindSafe for Structure
impl UnwindSafe for Structure
Blanket Implementations
impl<T> HasPosition for T where
T: RoomObjectProperties,
[src]
T: RoomObjectProperties,
fn pos(&Self) -> RoomPosition
[src]
impl<T> SizedRoomObject for T where
T: Into<Reference> + ReferenceType<Error = ConversionError, Error = ConversionError> + TryFrom<Value> + TryFrom<Reference> + RoomObjectProperties,
[src]
T: Into<Reference> + ReferenceType<Error = ConversionError, Error = ConversionError> + TryFrom<Value> + TryFrom<Reference> + RoomObjectProperties,
impl<T> FromExpectedType<Value> for T where
T: FromExpectedType<Reference>,
[src]
T: FromExpectedType<Reference>,
fn from_expected_type(Value) -> Result<T, ConversionError>
[src]
impl<T, U> IntoExpectedType<U> for T where
U: FromExpectedType<T>,
[src]
U: FromExpectedType<T>,
fn into_expected_type(Self) -> Result<U, ConversionError>
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,