Struct screeps::objects::PowerCreep
source · #[repr(transparent)]pub struct PowerCreep { /* private fields */ }
Expand description
A PowerCreep
unit in the game world.
Implementations§
source§impl PowerCreep
impl PowerCreep
sourcepub fn create(name: &JsString, _class: PowerCreepClass) -> ReturnCode
pub fn create(name: &JsString, _class: PowerCreepClass) -> ReturnCode
Create a new power creep in your account. Note that it will not initially be spawned.
source§impl PowerCreep
impl PowerCreep
sourcepub fn class(&self) -> PowerCreepClass
pub fn class(&self) -> PowerCreepClass
Retrieve this power creep’s PowerCreepClass
.
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
sourcepub fn set_memory(&self, val: &JsValue)
pub fn set_memory(&self, val: &JsValue)
Sets a new value to Memory.powerCreeps[power_creep.name]
.
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
source§impl PowerCreep
impl PowerCreep
sourcepub fn ticks_to_live(&self) -> Option<u32>
pub fn ticks_to_live(&self) -> Option<u32>
The number of ticks the power creep has left to live, which can be
renewed at a StructurePowerSpawn
or [StructurePowerBank
]
source§impl PowerCreep
impl PowerCreep
sourcepub fn cancel_order(&self, target: &JsString) -> ReturnCode
pub fn cancel_order(&self, target: &JsString) -> ReturnCode
Cancel an a successfully called power creep function from earlier in the
tick, with a JsString
that must contain the JS version of the
function name.
source§impl PowerCreep
impl PowerCreep
sourcepub fn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode
pub fn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode
Drop a resource on the ground from the power creep’s Store
.
source§impl PowerCreep
impl PowerCreep
sourcepub fn enable_room(&self, target: &StructureController) -> ReturnCode
pub fn enable_room(&self, target: &StructureController) -> ReturnCode
Enable powers to be used in this room on a StructureController
in
melee range. You do not need to own the controller.
source§impl PowerCreep
impl PowerCreep
sourcepub fn move_direction(&self, direction: Direction) -> ReturnCode
pub fn move_direction(&self, direction: Direction) -> ReturnCode
Move one square in the specified direction.
source§impl PowerCreep
impl PowerCreep
sourcepub fn move_by_path(&self, path: &JsValue) -> ReturnCode
pub fn move_by_path(&self, path: &JsValue) -> ReturnCode
Move the power creep along a previously determined path returned from a pathfinding function, in array or serialized string form.
source§impl PowerCreep
impl PowerCreep
sourcepub fn notify_when_attacked(&self, enabled: bool) -> ReturnCode
pub fn notify_when_attacked(&self, enabled: bool) -> ReturnCode
Whether to send an email notification when this power creep is attacked.
source§impl PowerCreep
impl PowerCreep
sourcepub fn pickup(&self, target: &Resource) -> ReturnCode
pub fn pickup(&self, target: &Resource) -> ReturnCode
Pick up a Resource
in melee range (or at the same position as the
creep).
source§impl PowerCreep
impl PowerCreep
sourcepub fn renew(&self, target: &RoomObject) -> ReturnCode
pub fn renew(&self, target: &RoomObject) -> ReturnCode
Renew the power creep’s TTL using a StructurePowerSpawn
or
[StructurePowerBank
] in melee range.
source§impl PowerCreep
impl PowerCreep
sourcepub fn say(&self, message: &str, public: bool) -> ReturnCode
pub fn say(&self, message: &str, public: bool) -> ReturnCode
Display a string in a bubble above the power creep next tick. 10 character limit.
source§impl PowerCreep
impl PowerCreep
sourcepub fn suicide(&self) -> ReturnCode
pub fn suicide(&self) -> ReturnCode
Immediately kill the power creep.
source§impl PowerCreep
impl PowerCreep
sourcepub fn use_power(
&self,
power: PowerType,
target: Option<&RoomObject>
) -> ReturnCode
pub fn use_power( &self, power: PowerType, target: Option<&RoomObject> ) -> ReturnCode
Use one of the power creep’s powers.
source§impl PowerCreep
impl PowerCreep
Methods from Deref<Target = RoomObject>§
sourcepub fn pos(&self) -> RoomPosition
pub fn pos(&self) -> RoomPosition
Position of the object.
Methods from Deref<Target = JsValue>§
pub const NULL: JsValue = JsValue{ idx: JSIDX_NULL, _marker: marker::PhantomData,}
pub const UNDEFINED: JsValue = JsValue{ idx: JSIDX_UNDEFINED, _marker: marker::PhantomData,}
pub const TRUE: JsValue = JsValue{ idx: JSIDX_TRUE, _marker: marker::PhantomData,}
pub const FALSE: JsValue = JsValue{ idx: JSIDX_FALSE, _marker: marker::PhantomData,}
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the f64
value of this JS value if it’s an instance of a
number.
If this JS value is not an instance of a number then this returns
None
.
sourcepub fn as_string(&self) -> Option<String>
Available on crate feature std
only.
pub fn as_string(&self) -> Option<String>
std
only.If this JS value is a string value, this function copies the JS string
value into wasm linear memory, encoded as UTF-8, and returns it as a
Rust String
.
To avoid the copying and re-encoding, consider the
JsString::try_from()
function from js-sys
instead.
If this JS value is not an instance of a string or if it’s not valid
utf-8 then this returns None
.
UTF-16 vs UTF-8
JavaScript strings in general are encoded as UTF-16, but Rust strings
are encoded as UTF-8. This can cause the Rust string to look a bit
different than the JS string sometimes. For more details see the
documentation about the str
type which contains a few
caveats about the encodings.
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the bool
value of this JS value if it’s an instance of a
boolean.
If this JS value is not an instance of a boolean then this returns
None
.
sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Tests whether this JS value is undefined
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Tests whether the type of this JS value is function
.
sourcepub fn js_in(&self, obj: &JsValue) -> bool
pub fn js_in(&self, obj: &JsValue) -> bool
Applies the binary in
JS operator on the two JsValue
s.
sourcepub fn loose_eq(&self, other: &JsValue) -> bool
pub fn loose_eq(&self, other: &JsValue) -> bool
Compare two JsValue
s for equality, using the ==
operator in JS.
sourcepub fn unsigned_shr(&self, rhs: &JsValue) -> u32
pub fn unsigned_shr(&self, rhs: &JsValue) -> u32
Applies the binary >>>
JS operator on the two JsValue
s.
sourcepub fn checked_div(&self, rhs: &JsValue) -> JsValue
pub fn checked_div(&self, rhs: &JsValue) -> JsValue
Applies the binary /
JS operator on two JsValue
s, catching and returning any RangeError
thrown.
sourcepub fn pow(&self, rhs: &JsValue) -> JsValue
pub fn pow(&self, rhs: &JsValue) -> JsValue
Applies the binary **
JS operator on the two JsValue
s.
sourcepub fn lt(&self, other: &JsValue) -> bool
pub fn lt(&self, other: &JsValue) -> bool
Applies the binary <
JS operator on the two JsValue
s.
sourcepub fn le(&self, other: &JsValue) -> bool
pub fn le(&self, other: &JsValue) -> bool
Applies the binary <=
JS operator on the two JsValue
s.
sourcepub fn ge(&self, other: &JsValue) -> bool
pub fn ge(&self, other: &JsValue) -> bool
Applies the binary >=
JS operator on the two JsValue
s.
sourcepub fn gt(&self, other: &JsValue) -> bool
pub fn gt(&self, other: &JsValue) -> bool
Applies the binary >
JS operator on the two JsValue
s.
sourcepub fn unchecked_into_f64(&self) -> f64
pub fn unchecked_into_f64(&self) -> f64
Applies the unary +
JS operator on a JsValue
. Can throw.
Trait Implementations§
source§impl AsRef<JsValue> for PowerCreep
impl AsRef<JsValue> for PowerCreep
source§impl AsRef<PowerCreep> for PowerCreep
impl AsRef<PowerCreep> for PowerCreep
source§fn as_ref(&self) -> &PowerCreep
fn as_ref(&self) -> &PowerCreep
source§impl AsRef<RoomObject> for PowerCreep
impl AsRef<RoomObject> for PowerCreep
source§fn as_ref(&self) -> &RoomObject
fn as_ref(&self) -> &RoomObject
source§impl Clone for PowerCreep
impl Clone for PowerCreep
source§fn clone(&self) -> PowerCreep
fn clone(&self) -> PowerCreep
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PowerCreep
impl Debug for PowerCreep
source§impl Deref for PowerCreep
impl Deref for PowerCreep
§type Target = RoomObject
type Target = RoomObject
source§fn deref(&self) -> &RoomObject
fn deref(&self) -> &RoomObject
source§impl From<JsValue> for PowerCreep
impl From<JsValue> for PowerCreep
source§fn from(obj: JsValue) -> PowerCreep
fn from(obj: JsValue) -> PowerCreep
source§impl From<PowerCreep> for JsValue
impl From<PowerCreep> for JsValue
source§fn from(obj: PowerCreep) -> JsValue
fn from(obj: PowerCreep) -> JsValue
source§impl From<PowerCreep> for MovableObject
impl From<PowerCreep> for MovableObject
source§fn from(v: PowerCreep) -> MovableObject
fn from(v: PowerCreep) -> MovableObject
source§impl From<PowerCreep> for ObjectWithMaybeId
impl From<PowerCreep> for ObjectWithMaybeId
source§fn from(v: PowerCreep) -> ObjectWithMaybeId
fn from(v: PowerCreep) -> ObjectWithMaybeId
source§impl From<PowerCreep> for ObjectWithPosition
impl From<PowerCreep> for ObjectWithPosition
source§fn from(v: PowerCreep) -> ObjectWithPosition
fn from(v: PowerCreep) -> ObjectWithPosition
source§impl From<PowerCreep> for RoomObject
impl From<PowerCreep> for RoomObject
source§fn from(obj: PowerCreep) -> RoomObject
fn from(obj: PowerCreep) -> RoomObject
source§impl From<PowerCreep> for StoreObject
impl From<PowerCreep> for StoreObject
source§fn from(v: PowerCreep) -> StoreObject
fn from(v: PowerCreep) -> StoreObject
source§impl From<PowerCreep> for TransferableObject
impl From<PowerCreep> for TransferableObject
source§fn from(v: PowerCreep) -> TransferableObject
fn from(v: PowerCreep) -> TransferableObject
source§impl From<PowerCreep> for TypedRoomObject
impl From<PowerCreep> for TypedRoomObject
source§fn from(v: PowerCreep) -> TypedRoomObject
fn from(v: PowerCreep) -> TypedRoomObject
source§impl FromWasmAbi for PowerCreep
impl FromWasmAbi for PowerCreep
source§impl HasHits for PowerCreep
impl HasHits for PowerCreep
source§impl HasNativeId for PowerCreep
impl HasNativeId for PowerCreep
source§impl HasStore for PowerCreep
impl HasStore for PowerCreep
source§impl<'a> IntoWasmAbi for &'a PowerCreep
impl<'a> IntoWasmAbi for &'a PowerCreep
source§impl IntoWasmAbi for PowerCreep
impl IntoWasmAbi for PowerCreep
source§impl JsCast for PowerCreep
impl JsCast for PowerCreep
source§fn instanceof(val: &JsValue) -> bool
fn instanceof(val: &JsValue) -> bool
instanceof
check to see whether the JsValue
provided is an instance of this type. Read moresource§fn unchecked_from_js(val: JsValue) -> Self
fn unchecked_from_js(val: JsValue) -> Self
source§fn unchecked_from_js_ref(val: &JsValue) -> &Self
fn unchecked_from_js_ref(val: &JsValue) -> &Self
source§fn has_type<T>(&self) -> boolwhere
T: JsCast,
fn has_type<T>(&self) -> boolwhere T: JsCast,
T
. Read moresource§fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self>where T: JsCast,
T
. Read moresource§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where T: JsCast,
T
. Read moresource§fn unchecked_into<T>(self) -> Twhere
T: JsCast,
fn unchecked_into<T>(self) -> Twhere T: JsCast,
source§fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
fn unchecked_ref<T>(&self) -> &Twhere T: JsCast,
source§impl LongRefFromWasmAbi for PowerCreep
impl LongRefFromWasmAbi for PowerCreep
§type Abi = <JsValue as LongRefFromWasmAbi>::Abi
type Abi = <JsValue as LongRefFromWasmAbi>::Abi
RefFromWasmAbi::Abi
§type Anchor = PowerCreep
type Anchor = PowerCreep
RefFromWasmAbi::Anchor
source§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abi
source§impl OptionFromWasmAbi for PowerCreep
impl OptionFromWasmAbi for PowerCreep
source§impl<'a> OptionIntoWasmAbi for &'a PowerCreep
impl<'a> OptionIntoWasmAbi for &'a PowerCreep
source§impl OptionIntoWasmAbi for PowerCreep
impl OptionIntoWasmAbi for PowerCreep
source§impl RefFromWasmAbi for PowerCreep
impl RefFromWasmAbi for PowerCreep
§type Abi = <JsValue as RefFromWasmAbi>::Abi
type Abi = <JsValue as RefFromWasmAbi>::Abi
Self
are recovered from.§type Anchor = ManuallyDrop<PowerCreep>
type Anchor = ManuallyDrop<PowerCreep>
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.source§fn memory(&self) -> JsValue
fn memory(&self) -> JsValue
Memory
tree used for this creep by
defaultsource§fn set_memory(&self, val: &JsValue)
fn set_memory(&self, val: &JsValue)
source§fn ticks_to_live(&self) -> Option<u32>
fn ticks_to_live(&self) -> Option<u32>
source§fn cancel_order(&self, target: &JsString) -> ReturnCode
fn cancel_order(&self, target: &JsString) -> ReturnCode
JsString
that must contain the JS version of the function
name.source§fn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode
fn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode
Store
.source§fn move_direction(&self, direction: Direction) -> ReturnCode
fn move_direction(&self, direction: Direction) -> ReturnCode
source§fn move_by_path(&self, path: &JsValue) -> ReturnCode
fn move_by_path(&self, path: &JsValue) -> ReturnCode
source§fn move_to<T>(&self, target: T) -> ReturnCodewhere
T: HasPosition,
fn move_to<T>(&self, target: T) -> ReturnCodewhere T: HasPosition,
RoomPosition
or
RoomObject
. Note that using this function will store data in
Memory.creeps[creep_name]
and enable the default serialization
behavior of the Memory
object, which may hamper attempts to directly
use RawMemory
.source§fn move_to_with_options<T, F>(
&self,
target: T,
options: Option<MoveToOptions<F>>
) -> ReturnCodewhere
T: HasPosition,
F: FnMut(RoomName, CostMatrix) -> SingleRoomCostResult,
fn move_to_with_options<T, F>( &self, target: T, options: Option<MoveToOptions<F>> ) -> ReturnCodewhere T: HasPosition, F: FnMut(RoomName, CostMatrix) -> SingleRoomCostResult,
RoomPosition
or
RoomObject
. Note that using this function will store data in
Memory.creeps[creep_name]
and enable the default serialization
behavior of the Memory
object, which may hamper attempts to directly
use RawMemory
.source§fn notify_when_attacked(&self, enabled: bool) -> ReturnCode
fn notify_when_attacked(&self, enabled: bool) -> ReturnCode
source§fn pickup(&self, target: &Resource) -> ReturnCode
fn pickup(&self, target: &Resource) -> ReturnCode
Resource
in melee range (or at the same position as the
creep).source§fn say(&self, message: &str, public: bool) -> ReturnCode
fn say(&self, message: &str, public: bool) -> ReturnCode
source§fn suicide(&self) -> ReturnCode
fn suicide(&self) -> ReturnCode
source§fn transfer<T>(
&self,
target: &T,
ty: ResourceType,
amount: Option<u32>
) -> ReturnCodewhere
T: Transferable,
fn transfer<T>( &self, target: &T, ty: ResourceType, amount: Option<u32> ) -> ReturnCodewhere T: Transferable,
source§fn withdraw<T>(
&self,
target: &T,
ty: ResourceType,
amount: Option<u32>
) -> ReturnCodewhere
T: Withdrawable,
fn withdraw<T>( &self, target: &T, ty: ResourceType, amount: Option<u32> ) -> ReturnCodewhere T: Withdrawable,
source§impl TryInto<PowerCreep> for MovableObject
impl TryInto<PowerCreep> for MovableObject
source§impl TryInto<PowerCreep> for ObjectWithMaybeId
impl TryInto<PowerCreep> for ObjectWithMaybeId
source§impl TryInto<PowerCreep> for ObjectWithPosition
impl TryInto<PowerCreep> for ObjectWithPosition
source§impl TryInto<PowerCreep> for StoreObject
impl TryInto<PowerCreep> for StoreObject
source§impl TryInto<PowerCreep> for TransferableObject
impl TryInto<PowerCreep> for TransferableObject
source§impl TryInto<PowerCreep> for TypedRoomObject
impl TryInto<PowerCreep> for TypedRoomObject
impl Attackable for PowerCreep
impl Healable for PowerCreep
impl Transferable for PowerCreep
Auto Trait Implementations§
impl RefUnwindSafe for PowerCreep
impl !Send for PowerCreep
impl !Sync for PowerCreep
impl Unpin for PowerCreep
impl UnwindSafe for PowerCreep
Blanket Implementations§
source§impl<T> HasId for Twhere
T: HasNativeId,
impl<T> HasId for Twhere T: HasNativeId,
source§fn raw_id(&self) -> RawObjectId
fn raw_id(&self) -> RawObjectId
source§impl<T> HasPosition for Twhere
T: AsRef<RoomObject>,
impl<T> HasPosition for Twhere T: AsRef<RoomObject>,
source§impl<T> HasTypedId<T> for Twhere
T: HasId + HasNativeId,
impl<T> HasTypedId<T> for Twhere T: HasId + HasNativeId,
source§impl<T> MaybeHasId for Twhere
T: MaybeHasNativeId,
impl<T> MaybeHasId for Twhere T: MaybeHasNativeId,
source§fn try_raw_id(&self) -> Option<RawObjectId>
fn try_raw_id(&self) -> Option<RawObjectId>
None
if the
object doesn’t currently have an id.source§impl<T> MaybeHasNativeId for Twhere
T: HasNativeId,
impl<T> MaybeHasNativeId for Twhere T: HasNativeId,
fn try_native_id(&self) -> Option<JsString>
source§impl<T> MaybeHasTypedId<T> for Twhere
T: MaybeHasId,
impl<T> MaybeHasTypedId<T> for Twhere T: MaybeHasId,
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere T: IntoWasmAbi,
§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.