Add /body command that allows you to switch body

This commit is contained in:
juliancoffee 2022-08-20 15:20:27 +03:00
parent 74e8dbf757
commit a371aad05e
2 changed files with 28 additions and 0 deletions

View File

@ -240,6 +240,7 @@ pub enum ServerChatCommand {
Ban,
BattleMode,
BattleModeForce,
Body,
Build,
BuildAreaAdd,
BuildAreaList,
@ -365,6 +366,11 @@ impl ServerChatCommand {
None,
),
ServerChatCommand::Body => cmd(
vec![Enum("body", ENTITIES.clone(), Required)],
"Change your body to different species",
Some(Admin),
),
ServerChatCommand::BattleModeForce => cmd(
vec![Enum(
"battle mode",
@ -720,6 +726,7 @@ impl ServerChatCommand {
ServerChatCommand::Ban => "ban",
ServerChatCommand::BattleMode => "battlemode",
ServerChatCommand::BattleModeForce => "battlemode_force",
ServerChatCommand::Body => "body",
ServerChatCommand::Build => "build",
ServerChatCommand::BuildAreaAdd => "build_area_add",
ServerChatCommand::BuildAreaList => "build_area_list",

View File

@ -129,6 +129,7 @@ fn do_command(
ServerChatCommand::Ban => handle_ban,
ServerChatCommand::BattleMode => handle_battlemode,
ServerChatCommand::BattleModeForce => handle_battlemode_force,
ServerChatCommand::Body => handle_body,
ServerChatCommand::Build => handle_build,
ServerChatCommand::BuildAreaAdd => handle_build_area_add,
ServerChatCommand::BuildAreaList => handle_build_area_list,
@ -3704,3 +3705,23 @@ fn handle_lightning(
.emit_now(Outcome::Lightning { pos });
Ok(())
}
fn handle_body(
server: &mut Server,
_client: EcsEntity,
target: EcsEntity,
args: Vec<String>,
action: &ServerChatCommand,
) -> CmdResult<()> {
if let Some(npc::NpcBody(_id, mut body)) = parse_cmd_args!(args, npc::NpcBody) {
let body = body();
let ecs = &server.state.ecs();
let mut bodies = ecs.write_storage::<comp::Body>();
if let Some(mut target_body) = bodies.get_mut(target) {
*target_body = body;
}
Ok(())
} else {
Err(action.help_string())
}
}