2020-09-17 23:02:14 +00:00
|
|
|
use crate::persistence::character_loader::CharacterLoader;
|
|
|
|
use common::{
|
2020-11-12 05:00:17 +00:00
|
|
|
comp::{item::tool::AbilityMap, Body, Inventory, Stats},
|
2020-09-17 23:02:14 +00:00
|
|
|
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>,
|
2020-11-12 05:00:17 +00:00
|
|
|
map: &AbilityMap,
|
2020-09-17 23:02:14 +00:00
|
|
|
) {
|
|
|
|
let stats = Stats::new(character_alias.to_string(), body);
|
|
|
|
|
|
|
|
let loadout = LoadoutBuilder::new()
|
|
|
|
.defaults()
|
|
|
|
.active_item(Some(LoadoutBuilder::default_item_config_from_str(
|
2020-11-12 05:00:17 +00:00
|
|
|
character_tool.as_deref().unwrap(), map
|
2020-09-17 23:02:14 +00:00
|
|
|
)))
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let inventory = Inventory::default();
|
2020-11-03 00:12:49 +00:00
|
|
|
let waypoint = None;
|
2020-09-17 23:02:14 +00:00
|
|
|
|
|
|
|
character_loader.create_character(
|
|
|
|
entity,
|
|
|
|
player_uuid,
|
|
|
|
character_alias,
|
2020-11-03 00:12:49 +00:00
|
|
|
(body, stats, inventory, loadout, waypoint),
|
2020-09-17 23:02:14 +00:00
|
|
|
);
|
|
|
|
}
|