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,
|
Group,
|
||||||
Health,
|
Health,
|
||||||
Help,
|
Help,
|
||||||
|
Home,
|
||||||
JoinFaction,
|
JoinFaction,
|
||||||
Jump,
|
Jump,
|
||||||
Kick,
|
Kick,
|
||||||
@ -98,6 +99,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[
|
|||||||
ChatCommand::Group,
|
ChatCommand::Group,
|
||||||
ChatCommand::Health,
|
ChatCommand::Health,
|
||||||
ChatCommand::Help,
|
ChatCommand::Help,
|
||||||
|
ChatCommand::Home,
|
||||||
ChatCommand::JoinFaction,
|
ChatCommand::JoinFaction,
|
||||||
ChatCommand::Jump,
|
ChatCommand::Jump,
|
||||||
ChatCommand::Kick,
|
ChatCommand::Kick,
|
||||||
@ -267,6 +269,7 @@ impl ChatCommand {
|
|||||||
"Display information about commands",
|
"Display information about commands",
|
||||||
NoAdmin,
|
NoAdmin,
|
||||||
),
|
),
|
||||||
|
ChatCommand::Home => cmd(vec![], "Return to the home town", NoAdmin),
|
||||||
ChatCommand::JoinFaction => ChatCommandData::new(
|
ChatCommand::JoinFaction => ChatCommandData::new(
|
||||||
vec![Any("faction", Optional)],
|
vec![Any("faction", Optional)],
|
||||||
"Join/leave the specified faction",
|
"Join/leave the specified faction",
|
||||||
@ -427,6 +430,7 @@ impl ChatCommand {
|
|||||||
ChatCommand::Health => "health",
|
ChatCommand::Health => "health",
|
||||||
ChatCommand::JoinFaction => "join_faction",
|
ChatCommand::JoinFaction => "join_faction",
|
||||||
ChatCommand::Help => "help",
|
ChatCommand::Help => "help",
|
||||||
|
ChatCommand::Home => "home",
|
||||||
ChatCommand::Jump => "jump",
|
ChatCommand::Jump => "jump",
|
||||||
ChatCommand::Kick => "kick",
|
ChatCommand::Kick => "kick",
|
||||||
ChatCommand::Kill => "kill",
|
ChatCommand::Kill => "kill",
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
settings::{BanRecord, EditableSetting},
|
settings::{BanRecord, EditableSetting},
|
||||||
Server, StateExt,
|
Server, SpawnPoint, StateExt,
|
||||||
};
|
};
|
||||||
use chrono::{NaiveTime, Timelike};
|
use chrono::{NaiveTime, Timelike};
|
||||||
use common::{
|
use common::{
|
||||||
@ -82,6 +82,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler {
|
|||||||
ChatCommand::Group => handle_group,
|
ChatCommand::Group => handle_group,
|
||||||
ChatCommand::Health => handle_health,
|
ChatCommand::Health => handle_health,
|
||||||
ChatCommand::Help => handle_help,
|
ChatCommand::Help => handle_help,
|
||||||
|
ChatCommand::Home => handle_home,
|
||||||
ChatCommand::JoinFaction => handle_join_faction,
|
ChatCommand::JoinFaction => handle_join_faction,
|
||||||
ChatCommand::Jump => handle_jump,
|
ChatCommand::Jump => handle_jump,
|
||||||
ChatCommand::Kick => handle_kick,
|
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(
|
fn handle_kill(
|
||||||
server: &mut Server,
|
server: &mut Server,
|
||||||
client: EcsEntity,
|
client: EcsEntity,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user