mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
implement /home to return to home town
This commit is contained in:
parent
9e905b297a
commit
ac92c8a6af
@ -51,6 +51,7 @@ pub enum ChatCommand {
|
||||
Group,
|
||||
Health,
|
||||
Help,
|
||||
Home,
|
||||
JoinFaction,
|
||||
Jump,
|
||||
Kick,
|
||||
@ -98,6 +99,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
|
||||
ChatCommand::Group,
|
||||
ChatCommand::Health,
|
||||
ChatCommand::Help,
|
||||
ChatCommand::Home,
|
||||
ChatCommand::JoinFaction,
|
||||
ChatCommand::Jump,
|
||||
ChatCommand::Kick,
|
||||
@ -267,6 +269,7 @@ impl ChatCommand {
|
||||
"Display information about commands",
|
||||
NoAdmin,
|
||||
),
|
||||
ChatCommand::Home => cmd(vec![], "Return to the home town", NoAdmin),
|
||||
ChatCommand::JoinFaction => ChatCommandData::new(
|
||||
vec![Any("faction", Optional)],
|
||||
"Join/leave the specified faction",
|
||||
@ -427,6 +430,7 @@ impl ChatCommand {
|
||||
ChatCommand::Health => "health",
|
||||
ChatCommand::JoinFaction => "join_faction",
|
||||
ChatCommand::Help => "help",
|
||||
ChatCommand::Home => "home",
|
||||
ChatCommand::Jump => "jump",
|
||||
ChatCommand::Kick => "kick",
|
||||
ChatCommand::Kill => "kill",
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use crate::{
|
||||
settings::{BanRecord, EditableSetting},
|
||||
Server, StateExt,
|
||||
Server, SpawnPoint, StateExt,
|
||||
};
|
||||
use chrono::{NaiveTime, Timelike};
|
||||
use common::{
|
||||
@ -82,6 +82,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
|
||||
ChatCommand::Group => handle_group,
|
||||
ChatCommand::Health => handle_health,
|
||||
ChatCommand::Help => handle_help,
|
||||
ChatCommand::Home => handle_home,
|
||||
ChatCommand::JoinFaction => handle_join_faction,
|
||||
ChatCommand::Jump => handle_jump,
|
||||
ChatCommand::Kick => handle_kick,
|
||||
@ -359,6 +360,29 @@ fn handle_goto(
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_home(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
target: EcsEntity,
|
||||
_args: String,
|
||||
_action: &ChatCommand,
|
||||
) {
|
||||
if server
|
||||
.state
|
||||
.read_component_copied::<comp::Pos>(target)
|
||||
.is_some()
|
||||
{
|
||||
let home_pos = server.state.ecs().read_resource::<SpawnPoint>().0;
|
||||
server.state.write_component(target, comp::Pos(home_pos));
|
||||
server.state.write_component(target, comp::ForceUpdate);
|
||||
} else {
|
||||
server.notify_client(
|
||||
client,
|
||||
ChatType::CommandError.server_msg("You have no position."),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_kill(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
|
Loading…
Reference in New Issue
Block a user