veloren/server/src/character_creator.rs

36 lines
950 B
Rust
Raw Normal View History

use crate::persistence::character_loader::CharacterLoader;
use common::{
comp::{item::tool::AbilityMap, Body, Inventory, Stats},
loadout_builder::LoadoutBuilder,
};
use specs::{Entity, ReadExpect};
pub fn create_character(
entity: Entity,
player_uuid: String,
character_alias: String,
character_tool: Option<String>,
body: Body,
character_loader: &ReadExpect<'_, CharacterLoader>,
map: &AbilityMap,
) {
let stats = Stats::new(character_alias.to_string(), body);
let loadout = LoadoutBuilder::new()
.defaults()
.active_item(Some(LoadoutBuilder::default_item_config_from_str(
character_tool.as_deref().unwrap(), map
)))
.build();
let inventory = Inventory::default();
2020-11-03 00:12:49 +00:00
let waypoint = None;
character_loader.create_character(
entity,
player_uuid,
character_alias,
2020-11-03 00:12:49 +00:00
(body, stats, inventory, loadout, waypoint),
);
}