Trait screeps::traits::SharedCreepProperties
source · pub trait SharedCreepProperties {
Show 19 methods
// Required methods
fn memory(&self) -> JsValue;
fn set_memory(&self, val: &JsValue);
fn my(&self) -> bool;
fn name(&self) -> String;
fn owner(&self) -> Owner;
fn saying(&self) -> Option<JsString>;
fn ticks_to_live(&self) -> Option<u32>;
fn cancel_order(&self, target: &JsString) -> ReturnCode;
fn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode;
fn move_direction(&self, direction: Direction) -> ReturnCode;
fn move_by_path(&self, path: &JsValue) -> ReturnCode;
fn move_to<T>(&self, target: T) -> ReturnCode
where T: HasPosition;
fn move_to_with_options<T, F>(
&self,
target: T,
options: Option<MoveToOptions<F>>
) -> ReturnCode
where T: HasPosition,
F: FnMut(RoomName, CostMatrix) -> SingleRoomCostResult;
fn notify_when_attacked(&self, enabled: bool) -> ReturnCode;
fn pickup(&self, target: &Resource) -> ReturnCode;
fn say(&self, message: &str, public: bool) -> ReturnCode;
fn suicide(&self) -> ReturnCode;
fn transfer<T>(
&self,
target: &T,
ty: ResourceType,
amount: Option<u32>
) -> ReturnCode
where T: Transferable;
fn withdraw<T>(
&self,
target: &T,
ty: ResourceType,
amount: Option<u32>
) -> ReturnCode
where T: Withdrawable;
}
Required Methods§
sourcefn memory(&self) -> JsValue
fn memory(&self) -> JsValue
A shortcut to the part of the Memory
tree used for this creep by
default
sourcefn set_memory(&self, val: &JsValue)
fn set_memory(&self, val: &JsValue)
Sets a new value to the memory object shortcut for this creep.
sourcefn ticks_to_live(&self) -> Option<u32>
fn ticks_to_live(&self) -> Option<u32>
The number of ticks the creep has left to live.
sourcefn cancel_order(&self, target: &JsString) -> ReturnCode
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.
sourcefn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode
fn drop(&self, ty: ResourceType, amount: Option<u32>) -> ReturnCode
Drop a resource on the ground from the creep’s Store
.
sourcefn move_direction(&self, direction: Direction) -> ReturnCode
fn move_direction(&self, direction: Direction) -> ReturnCode
Move one square in the specified direction.
sourcefn move_by_path(&self, path: &JsValue) -> ReturnCode
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.
sourcefn move_to<T>(&self, target: T) -> ReturnCodewhere
T: HasPosition,
fn move_to<T>(&self, target: T) -> ReturnCodewhere T: HasPosition,
Move the creep toward the specified goal, either a 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
.
sourcefn 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,
Move the creep toward the specified goal, either a 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
.
sourcefn notify_when_attacked(&self, enabled: bool) -> ReturnCode
fn notify_when_attacked(&self, enabled: bool) -> ReturnCode
Whether to send an email notification when this creep is attacked.
sourcefn pickup(&self, target: &Resource) -> ReturnCode
fn pickup(&self, target: &Resource) -> ReturnCode
Pick up a Resource
in melee range (or at the same position as the
creep).
sourcefn say(&self, message: &str, public: bool) -> ReturnCode
fn say(&self, message: &str, public: bool) -> ReturnCode
Display a string in a bubble above the creep next tick. 10 character limit.
sourcefn suicide(&self) -> ReturnCode
fn suicide(&self) -> ReturnCode
Immediately kill the creep.
sourcefn 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,
Transfer a resource from the creep’s store to Structure
,
PowerCreep
, or another Creep
.