[][src]Enum screeps::objects::Structure

pub enum Structure {
    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),
}

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]

fn id(&self) -> String[src]

impl RoomObjectProperties for Structure[src]

fn room(&self) -> Room[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]

impl FromExpectedType<Reference> for Structure[src]

impl From<Structure> for Reference[src]

impl PartialEq<Structure> for Structure[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.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.

impl TryFrom<Value> for Structure[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl InstanceOf for Structure[src]

impl ReferenceType for Structure[src]

Auto Trait Implementations

Blanket Implementations

impl<T> HasPosition for T where
    T: RoomObjectProperties
[src]

impl<T> SizedRoomObject for T where
    T: Into<Reference> + ReferenceType<Error = ConversionError, Error = ConversionError> + TryFrom<Value> + TryFrom<Reference> + RoomObjectProperties
[src]

impl<T> FromExpectedType<Value> for T where
    T: FromExpectedType<Reference>, 
[src]

impl<T, U> IntoExpectedType<U> for T where
    U: FromExpectedType<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.