Trait veloren_server::state_ext::StateExt
source · pub trait StateExt {
Show 23 methods
// Required methods
fn create_npc(
&mut self,
pos: Pos,
ori: Ori,
stats: Stats,
skill_set: SkillSet,
health: Option<Health>,
poise: Poise,
inventory: Inventory,
body: Body,
) -> EcsEntityBuilder<'_>;
fn create_empty(&mut self, pos: Pos) -> EcsEntityBuilder<'_>;
fn create_object(&mut self, pos: Pos, object: Body) -> EcsEntityBuilder<'_>;
fn create_item_drop(
&mut self,
pos: Pos,
ori: Ori,
vel: Vel,
item: PickupItem,
loot_owner: Option<LootOwner>,
) -> Option<EcsEntity>;
fn create_ship<F: FnOnce(Body) -> Collider>(
&mut self,
pos: Pos,
ori: Ori,
ship: Body,
make_collider: F,
) -> EcsEntityBuilder<'_>;
fn create_projectile(
&mut self,
pos: Pos,
vel: Vel,
body: Body,
projectile: Projectile,
) -> EcsEntityBuilder<'_>;
fn create_shockwave(
&mut self,
properties: Properties,
pos: Pos,
ori: Ori,
) -> EcsEntityBuilder<'_>;
fn create_safezone(
&mut self,
range: Option<f32>,
pos: Pos,
) -> EcsEntityBuilder<'_>;
fn create_wiring(
&mut self,
pos: Pos,
object: Body,
wiring_element: WiringElement,
) -> EcsEntityBuilder<'_>;
fn create_persister(
&mut self,
pos: Pos,
view_distance: u32,
world: &Arc<World>,
index: &IndexOwned,
) -> EcsEntityBuilder<'_>;
fn create_teleporter(
&mut self,
pos: Pos,
portal: PortalData,
) -> EcsEntityBuilder<'_>;
fn initialize_character_data(
&mut self,
entity: EcsEntity,
character_id: CharacterId,
view_distances: ViewDistances,
);
fn initialize_spectator_data(
&mut self,
entity: EcsEntity,
view_distances: ViewDistances,
);
fn update_character_data(
&mut self,
entity: EcsEntity,
components: PersistedComponents,
) -> Result<(), String>;
fn validate_chat_msg(
&self,
player: EcsEntity,
chat_type: &ChatType<Group>,
msg: &str,
) -> bool;
fn send_chat(&self, msg: UnresolvedChatMsg);
fn notify_players(&self, msg: ServerGeneral);
fn notify_in_game_clients(&self, msg: ServerGeneral);
fn link<L: Link>(&mut self, link: L) -> Result<(), L::Error>;
fn maintain_links(&mut self);
fn delete_entity_recorded(
&mut self,
entity: EcsEntity,
) -> Result<(), WrongGeneration>;
fn entity_as_actor(&self, entity: EcsEntity) -> Option<Actor>;
fn position_mut<T>(
&mut self,
entity: EcsEntity,
dismount_volume: bool,
f: impl for<'a> FnOnce(&'a mut Pos) -> T,
) -> Result<T, Content>;
}
Required Methods§
sourcefn create_npc(
&mut self,
pos: Pos,
ori: Ori,
stats: Stats,
skill_set: SkillSet,
health: Option<Health>,
poise: Poise,
inventory: Inventory,
body: Body,
) -> EcsEntityBuilder<'_>
fn create_npc( &mut self, pos: Pos, ori: Ori, stats: Stats, skill_set: SkillSet, health: Option<Health>, poise: Poise, inventory: Inventory, body: Body, ) -> EcsEntityBuilder<'_>
Build a non-player character
sourcefn create_empty(&mut self, pos: Pos) -> EcsEntityBuilder<'_>
fn create_empty(&mut self, pos: Pos) -> EcsEntityBuilder<'_>
Create an entity with only a position
sourcefn create_object(&mut self, pos: Pos, object: Body) -> EcsEntityBuilder<'_>
fn create_object(&mut self, pos: Pos, object: Body) -> EcsEntityBuilder<'_>
Build a static object entity
sourcefn create_item_drop(
&mut self,
pos: Pos,
ori: Ori,
vel: Vel,
item: PickupItem,
loot_owner: Option<LootOwner>,
) -> Option<EcsEntity>
fn create_item_drop( &mut self, pos: Pos, ori: Ori, vel: Vel, item: PickupItem, loot_owner: Option<LootOwner>, ) -> Option<EcsEntity>
Create an item drop or merge the item with an existing drop, if a suitable candidate exists.
fn create_ship<F: FnOnce(Body) -> Collider>( &mut self, pos: Pos, ori: Ori, ship: Body, make_collider: F, ) -> EcsEntityBuilder<'_>
sourcefn create_projectile(
&mut self,
pos: Pos,
vel: Vel,
body: Body,
projectile: Projectile,
) -> EcsEntityBuilder<'_>
fn create_projectile( &mut self, pos: Pos, vel: Vel, body: Body, projectile: Projectile, ) -> EcsEntityBuilder<'_>
Build a projectile
sourcefn create_shockwave(
&mut self,
properties: Properties,
pos: Pos,
ori: Ori,
) -> EcsEntityBuilder<'_>
fn create_shockwave( &mut self, properties: Properties, pos: Pos, ori: Ori, ) -> EcsEntityBuilder<'_>
Build a shockwave entity
sourcefn create_safezone(
&mut self,
range: Option<f32>,
pos: Pos,
) -> EcsEntityBuilder<'_>
fn create_safezone( &mut self, range: Option<f32>, pos: Pos, ) -> EcsEntityBuilder<'_>
Creates a safezone
fn create_wiring( &mut self, pos: Pos, object: Body, wiring_element: WiringElement, ) -> EcsEntityBuilder<'_>
sourcefn create_persister(
&mut self,
pos: Pos,
view_distance: u32,
world: &Arc<World>,
index: &IndexOwned,
) -> EcsEntityBuilder<'_>
fn create_persister( &mut self, pos: Pos, view_distance: u32, world: &Arc<World>, index: &IndexOwned, ) -> EcsEntityBuilder<'_>
Queues chunk generation in the view distance of the persister, this entity must be built before those chunks are received (the builder borrows the ecs world so that is kind of impossible in practice)
sourcefn create_teleporter(
&mut self,
pos: Pos,
portal: PortalData,
) -> EcsEntityBuilder<'_>
fn create_teleporter( &mut self, pos: Pos, portal: PortalData, ) -> EcsEntityBuilder<'_>
Creates a teleporter entity, which allows players to teleport to the
target
position. You might want to require the teleporting entity
to not have agro for teleporting.
sourcefn initialize_character_data(
&mut self,
entity: EcsEntity,
character_id: CharacterId,
view_distances: ViewDistances,
)
fn initialize_character_data( &mut self, entity: EcsEntity, character_id: CharacterId, view_distances: ViewDistances, )
Insert common/default components for a new character joining the server
sourcefn initialize_spectator_data(
&mut self,
entity: EcsEntity,
view_distances: ViewDistances,
)
fn initialize_spectator_data( &mut self, entity: EcsEntity, view_distances: ViewDistances, )
Insert common/default components for a new spectator joining the server
sourcefn update_character_data(
&mut self,
entity: EcsEntity,
components: PersistedComponents,
) -> Result<(), String>
fn update_character_data( &mut self, entity: EcsEntity, components: PersistedComponents, ) -> Result<(), String>
Update the components associated with the entity’s current character. Performed after loading component data from the database
sourcefn validate_chat_msg(
&self,
player: EcsEntity,
chat_type: &ChatType<Group>,
msg: &str,
) -> bool
fn validate_chat_msg( &self, player: EcsEntity, chat_type: &ChatType<Group>, msg: &str, ) -> bool
Iterates over registered clients and send each ServerMsg
fn send_chat(&self, msg: UnresolvedChatMsg)
fn notify_players(&self, msg: ServerGeneral)
fn notify_in_game_clients(&self, msg: ServerGeneral)
sourcefn link<L: Link>(&mut self, link: L) -> Result<(), L::Error>
fn link<L: Link>(&mut self, link: L) -> Result<(), L::Error>
Create a new link between entities (see [common::mounting
] for an
example).
sourcefn maintain_links(&mut self)
fn maintain_links(&mut self)
Maintain active links between entities
sourcefn delete_entity_recorded(
&mut self,
entity: EcsEntity,
) -> Result<(), WrongGeneration>
fn delete_entity_recorded( &mut self, entity: EcsEntity, ) -> Result<(), WrongGeneration>
Delete an entity, recording the deletion in DeletedEntities
sourcefn entity_as_actor(&self, entity: EcsEntity) -> Option<Actor>
fn entity_as_actor(&self, entity: EcsEntity) -> Option<Actor>
Get the given entity as an [Actor
], if it is one.
sourcefn position_mut<T>(
&mut self,
entity: EcsEntity,
dismount_volume: bool,
f: impl for<'a> FnOnce(&'a mut Pos) -> T,
) -> Result<T, Content>
fn position_mut<T>( &mut self, entity: EcsEntity, dismount_volume: bool, f: impl for<'a> FnOnce(&'a mut Pos) -> T, ) -> Result<T, Content>
Mutate the position of an entity or, if the entity is mounted, the mount.
If dismount_volume
is true
, an entity mounted on a volume entity
(such as an airship) will be dismounted to avoid teleporting the volume
entity.
Object Safety§
Implementations on Foreign Types§
source§impl StateExt for State
impl StateExt for State
source§fn create_persister(
&mut self,
pos: Pos,
view_distance: u32,
world: &Arc<World>,
index: &IndexOwned,
) -> EcsEntityBuilder<'_>
fn create_persister( &mut self, pos: Pos, view_distance: u32, world: &Arc<World>, index: &IndexOwned, ) -> EcsEntityBuilder<'_>
Queues chunk generation in the view distance of the persister, this entity must be built before those chunks are received (the builder borrows the ecs world so that is kind of impossible in practice)
source§fn update_character_data(
&mut self,
entity: EcsEntity,
components: PersistedComponents,
) -> Result<(), String>
fn update_character_data( &mut self, entity: EcsEntity, components: PersistedComponents, ) -> Result<(), String>
Returned error intended to be sent to the client.
source§fn send_chat(&self, msg: UnresolvedChatMsg)
fn send_chat(&self, msg: UnresolvedChatMsg)
Send the chat message to the proper players. Say and region are limited by location. Faction and group are limited by component.
source§fn notify_players(&self, msg: ServerGeneral)
fn notify_players(&self, msg: ServerGeneral)
Sends the message to all connected clients
source§fn notify_in_game_clients(&self, msg: ServerGeneral)
fn notify_in_game_clients(&self, msg: ServerGeneral)
Sends the message to all clients playing in game