#[repr(transparent)]pub struct Creep { /* private fields */ }
Expand description
A Creep
unit in the game world.
Implementations§
source§impl Creep
impl Creep
source§impl Creep
impl Creep
source§impl Creep
impl Creep
sourcepub fn set_memory(&self, val: &JsValue)
pub fn set_memory(&self, val: &JsValue)
Sets a new value to Memory.creeps[creep.name]
.
source§impl Creep
impl Creep
source§impl Creep
impl Creep
source§impl Creep
impl Creep
sourcepub fn ticks_to_live(&self) -> Option<u32>
pub fn ticks_to_live(&self) -> Option<u32>
The number of ticks the creep has left to live
source§impl Creep
impl Creep
sourcepub fn attack_controller(&self, target: &StructureController) -> ReturnCode
pub fn attack_controller(&self, target: &StructureController) -> ReturnCode
Attack a StructureController
in melee range using a creep’s claim
parts.
source§impl Creep
impl Creep
sourcepub fn build(&self, target: &ConstructionSite) -> ReturnCode
pub fn build(&self, target: &ConstructionSite) -> ReturnCode
Use a creep’s work parts to consume carried energy, putting it toward
progress in a ConstructionSite
in range 3.
source§impl Creep
impl Creep
sourcepub fn cancel_order(&self, target: &JsString) -> ReturnCode
pub fn cancel_order(&self, target: &JsString) -> ReturnCode
Cancel an a successfully called creep function from earlier in the tick,
with a JsString
that must contain the JS version of the function
name.
source§impl Creep
impl Creep
sourcepub fn claim_controller(&self, target: &StructureController) -> ReturnCode
pub fn claim_controller(&self, target: &StructureController) -> ReturnCode
Claim an unowned StructureController
in melee range as your own
using a creep’s claim parts.
source§impl Creep
impl Creep
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 creep’s Store
.
source§impl Creep
impl Creep
sourcepub fn generate_safe_mode(&self, target: &StructureController) -> ReturnCode
pub fn generate_safe_mode(&self, target: &StructureController) -> ReturnCode
Consume ResourceType::Ghodium
(in the amount of SAFE_MODE_COST
)
from the creep’s Store
to add a safe mode activation to a
StructureController
in melee range.
source§impl Creep
impl Creep
sourcepub fn get_active_bodyparts(&self, ty: Part) -> u8
pub fn get_active_bodyparts(&self, ty: Part) -> u8
Get the number of parts of the given type the creep has in its body, excluding fully damaged parts.
source§impl Creep
impl Creep
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 Creep
impl Creep
sourcepub fn move_pulled_by(&self, target: &Creep) -> ReturnCode
pub fn move_pulled_by(&self, target: &Creep) -> ReturnCode
Accept an attempt by another creep to pull this one.
source§impl Creep
impl Creep
sourcepub fn move_by_path(&self, path: &JsValue) -> ReturnCode
pub fn move_by_path(&self, path: &JsValue) -> ReturnCode
Move the creep along a previously determined path returned from a pathfinding function, in array or serialized string form.
source§impl Creep
impl Creep
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 creep is attacked.
source§impl Creep
impl Creep
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 Creep
impl Creep
sourcepub fn pull(&self, target: &Creep) -> ReturnCode
pub fn pull(&self, target: &Creep) -> ReturnCode
Help another creep to move by pulling, if the second creep accepts.
source§impl Creep
impl Creep
sourcepub fn ranged_mass_attack(&self) -> ReturnCode
pub fn ranged_mass_attack(&self) -> ReturnCode
Attack all enemy targets in range using a creep’s ranged attack parts, with lower damage depending on range.
source§impl Creep
impl Creep
sourcepub fn repair(&self, target: &RoomObject) -> ReturnCode
pub fn repair(&self, target: &RoomObject) -> ReturnCode
Repair a target in range 3 using carried energy and the creep’s work parts.
source§impl Creep
impl Creep
sourcepub fn reserve_controller(&self, target: &StructureController) -> ReturnCode
pub fn reserve_controller(&self, target: &StructureController) -> ReturnCode
Reserve an unowned StructureController
in melee range using a
creep’s claim parts.
source§impl Creep
impl Creep
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 creep next tick. 10 character limit.
source§impl Creep
impl Creep
sourcepub fn sign_controller(
&self,
target: &StructureController,
text: &str
) -> ReturnCode
pub fn sign_controller( &self, target: &StructureController, text: &str ) -> ReturnCode
Add (or remove, using an empty string) a sign to a
StructureController
in melee range.
source§impl Creep
impl Creep
sourcepub fn upgrade_controller(&self, target: &StructureController) -> ReturnCode
pub fn upgrade_controller(&self, target: &StructureController) -> ReturnCode
Upgrade a StructureController
in range 3 using carried energy and
the creep’s work parts.
source§impl Creep
impl Creep
sourcepub fn body(&self) -> Vec<BodyPart>
pub fn body(&self) -> Vec<BodyPart>
Retrieve a Vec<BodyPart>
containing details about the creep’s body
parts and boosts.
sourcepub fn attack<T>(&self, target: &T) -> ReturnCodewhere
T: ?Sized + Attackable,
pub fn attack<T>(&self, target: &T) -> ReturnCodewhere T: ?Sized + Attackable,
Attack a target in melee range using a creep’s attack parts.
sourcepub fn dismantle<T>(&self, target: &T) -> ReturnCodewhere
T: ?Sized + Dismantleable,
pub fn dismantle<T>(&self, target: &T) -> ReturnCodewhere T: ?Sized + Dismantleable,
Dismantle a Structure
in melee range, removing DISMANTLE_POWER
hits per effective work part, giving the creep energy equivalent to half
of the cost to repair the same hits. Can only be used against types
of structures that can be constructed; if
StructureType::construction_cost
is None
, dismantling is
impossible.
sourcepub fn harvest<T>(&self, target: &T) -> ReturnCodewhere
T: ?Sized + Harvestable,
pub fn harvest<T>(&self, target: &T) -> ReturnCodewhere T: ?Sized + Harvestable,
sourcepub fn heal<T>(&self, target: &T) -> ReturnCodewhere
T: ?Sized + Healable,
pub fn heal<T>(&self, target: &T) -> ReturnCodewhere T: ?Sized + Healable,
Heal a Creep
or PowerCreep
in melee range, including itself.
sourcepub fn ranged_attack<T>(&self, target: &T) -> ReturnCodewhere
T: ?Sized + Attackable,
pub fn ranged_attack<T>(&self, target: &T) -> ReturnCodewhere T: ?Sized + Attackable,
Attack a target in range 3 using a creep’s ranged attack parts.
sourcepub fn ranged_heal<T>(&self, target: &T) -> ReturnCodewhere
T: ?Sized + Healable,
pub fn ranged_heal<T>(&self, target: &T) -> ReturnCodewhere T: ?Sized + Healable,
Heal a target in range 3 using a creep’s heal parts.
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<RoomObject> for Creep
impl AsRef<RoomObject> for Creep
source§fn as_ref(&self) -> &RoomObject
fn as_ref(&self) -> &RoomObject
source§impl Deref for Creep
impl Deref for Creep
§type Target = RoomObject
type Target = RoomObject
source§fn deref(&self) -> &RoomObject
fn deref(&self) -> &RoomObject
source§impl From<Creep> for MovableObject
impl From<Creep> for MovableObject
source§fn from(v: Creep) -> MovableObject
fn from(v: Creep) -> MovableObject
source§impl From<Creep> for ObjectWithMaybeId
impl From<Creep> for ObjectWithMaybeId
source§fn from(v: Creep) -> ObjectWithMaybeId
fn from(v: Creep) -> ObjectWithMaybeId
source§impl From<Creep> for ObjectWithPosition
impl From<Creep> for ObjectWithPosition
source§fn from(v: Creep) -> ObjectWithPosition
fn from(v: Creep) -> ObjectWithPosition
source§impl From<Creep> for RoomObject
impl From<Creep> for RoomObject
source§fn from(obj: Creep) -> RoomObject
fn from(obj: Creep) -> RoomObject
source§impl From<Creep> for StoreObject
impl From<Creep> for StoreObject
source§fn from(v: Creep) -> StoreObject
fn from(v: Creep) -> StoreObject
source§impl From<Creep> for TransferableObject
impl From<Creep> for TransferableObject
source§fn from(v: Creep) -> TransferableObject
fn from(v: Creep) -> TransferableObject
source§impl From<Creep> for TypedRoomObject
impl From<Creep> for TypedRoomObject
source§fn from(v: Creep) -> TypedRoomObject
fn from(v: Creep) -> TypedRoomObject
source§impl FromWasmAbi for Creep
impl FromWasmAbi for Creep
source§impl<'a> IntoWasmAbi for &'a Creep
impl<'a> IntoWasmAbi for &'a Creep
source§impl IntoWasmAbi for Creep
impl IntoWasmAbi for Creep
source§impl JsCast for Creep
impl JsCast for Creep
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 JsCollectionFromValue for Creep
impl JsCollectionFromValue for Creep
fn from_value(val: JsValue) -> Self
source§impl LongRefFromWasmAbi for Creep
impl LongRefFromWasmAbi for Creep
source§impl MaybeHasNativeId for Creep
impl MaybeHasNativeId for Creep
fn try_native_id(&self) -> Option<JsString>
source§impl OptionFromWasmAbi for Creep
impl OptionFromWasmAbi for Creep
source§impl<'a> OptionIntoWasmAbi for &'a Creep
impl<'a> OptionIntoWasmAbi for &'a Creep
source§impl OptionIntoWasmAbi for Creep
impl OptionIntoWasmAbi for Creep
source§impl RefFromWasmAbi for Creep
impl RefFromWasmAbi for Creep
§type Abi = <JsValue as RefFromWasmAbi>::Abi
type Abi = <JsValue as RefFromWasmAbi>::Abi
Self
are recovered from.§type Anchor = ManuallyDrop<Creep>
type Anchor = ManuallyDrop<Creep>
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<Creep> for MovableObject
impl TryInto<Creep> for MovableObject
source§impl TryInto<Creep> for ObjectWithMaybeId
impl TryInto<Creep> for ObjectWithMaybeId
source§impl TryInto<Creep> for ObjectWithPosition
impl TryInto<Creep> for ObjectWithPosition
source§impl TryInto<Creep> for StoreObject
impl TryInto<Creep> for StoreObject
source§impl TryInto<Creep> for TransferableObject
impl TryInto<Creep> for TransferableObject
source§impl TryInto<Creep> for TypedRoomObject
impl TryInto<Creep> for TypedRoomObject
impl Attackable for Creep
impl Healable for Creep
impl Transferable for Creep
Auto Trait Implementations§
impl RefUnwindSafe for Creep
impl !Send for Creep
impl !Sync for Creep
impl Unpin for Creep
impl UnwindSafe for Creep
Blanket Implementations§
source§impl<T> HasPosition for Twhere
T: AsRef<RoomObject>,
impl<T> HasPosition for Twhere T: AsRef<RoomObject>,
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> 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
.