Removed /home, replaced with /respawn

This commit is contained in:
Joshua Barretto 2023-04-01 17:37:01 +01:00
parent c0723c659e
commit 42c534b7b4
2 changed files with 14 additions and 16 deletions

View File

@ -272,7 +272,6 @@ pub enum ServerChatCommand {
GroupPromote,
Health,
Help,
Home,
JoinFaction,
Jump,
Kick,
@ -294,6 +293,7 @@ pub enum ServerChatCommand {
Region,
ReloadChunks,
RemoveLights,
Respawn,
RevokeBuild,
RevokeBuildAll,
Safezone,
@ -487,7 +487,7 @@ impl ServerChatCommand {
"Display information about commands",
None,
),
ServerChatCommand::Home => cmd(vec![], "Return to the home town", Some(Moderator)),
ServerChatCommand::Respawn => cmd(vec![], "Teleport to your waypoint", Some(Moderator)),
ServerChatCommand::JoinFaction => ChatCommandData::new(
vec![Any("faction", Optional)],
"Join/leave the specified faction",
@ -762,7 +762,7 @@ impl ServerChatCommand {
ServerChatCommand::GroupLeave => "group_leave",
ServerChatCommand::Health => "health",
ServerChatCommand::Help => "help",
ServerChatCommand::Home => "home",
ServerChatCommand::Respawn => "respawn",
ServerChatCommand::JoinFaction => "join_faction",
ServerChatCommand::Jump => "jump",
ServerChatCommand::Kick => "kick",

View File

@ -13,7 +13,7 @@ use crate::{
weather::WeatherSim,
wiring,
wiring::OutputFormula,
Server, Settings, SpawnPoint, StateExt,
Server, Settings, StateExt,
};
use assets::AssetExt;
use authc::Uuid;
@ -150,7 +150,7 @@ fn do_command(
ServerChatCommand::GroupPromote => handle_group_promote,
ServerChatCommand::Health => handle_health,
ServerChatCommand::Help => handle_help,
ServerChatCommand::Home => handle_home,
ServerChatCommand::Respawn => handle_respawn,
ServerChatCommand::JoinFaction => handle_join_faction,
ServerChatCommand::Jump => handle_jump,
ServerChatCommand::Kick => handle_kick,
@ -874,25 +874,23 @@ fn handle_site(
Ok(())
}
fn handle_home(
fn handle_respawn(
server: &mut Server,
_client: EcsEntity,
target: EcsEntity,
_args: Vec<String>,
_action: &ServerChatCommand,
) -> CmdResult<()> {
let home_pos = server.state.mut_resource::<SpawnPoint>().0;
let time = *server.state.mut_resource::<Time>();
let waypoint = server
.state
.read_storage::<comp::Waypoint>()
.get(target)
.ok_or_else(|| format!("No waypoint set"))?
.get_pos();
position_mut(server, target, "target", |current_pos| {
current_pos.0 = home_pos
})?;
insert_or_replace_component(
server,
target,
comp::Waypoint::temp_new(home_pos, time),
"target",
)
current_pos.0 = waypoint;
})
}
fn handle_kill(