diff --git a/common/src/cmd.rs b/common/src/cmd.rs index 6d8ed3af46..e128901f46 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -38,6 +38,7 @@ pub enum ChatCommand { Adminify, Alias, Build, + Campfire, Debug, DebugColumn, Dummy, @@ -79,6 +80,7 @@ pub static CHAT_COMMANDS: &[ChatCommand] = &[ ChatCommand::Adminify, ChatCommand::Alias, ChatCommand::Build, + ChatCommand::Campfire, ChatCommand::Debug, ChatCommand::DebugColumn, ChatCommand::Dummy, @@ -185,6 +187,7 @@ impl ChatCommand { ), ChatCommand::Alias => cmd(vec![Any("name", Required)], "Change your alias", NoAdmin), ChatCommand::Build => cmd(vec![], "Toggles build mode on and off", Admin), + ChatCommand::Campfire => cmd(vec![], "Spawns a campfire", Admin), ChatCommand::Debug => cmd(vec![], "Place all debug items into your pack.", Admin), ChatCommand::DebugColumn => cmd( vec![Integer("x", 15000, Required), Integer("y", 15000, Required)], @@ -365,6 +368,7 @@ impl ChatCommand { ChatCommand::Adminify => "adminify", ChatCommand::Alias => "alias", ChatCommand::Build => "build", + ChatCommand::Campfire => "campfire", ChatCommand::Debug => "debug", ChatCommand::DebugColumn => "debug_column", ChatCommand::Dummy => "dummy", diff --git a/server/src/cmd.rs b/server/src/cmd.rs index b580cfbd98..3d8d3bef72 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -65,6 +65,7 @@ fn get_handler(cmd: &ChatCommand) -> CommandHandler { ChatCommand::Adminify => handle_adminify, ChatCommand::Alias => handle_alias, ChatCommand::Build => handle_build, + ChatCommand::Campfire => handle_spawn_campfire, ChatCommand::Debug => handle_debug, ChatCommand::DebugColumn => handle_debug_column, ChatCommand::Dummy => handle_spawn_training_dummy, @@ -664,6 +665,47 @@ fn handle_spawn_training_dummy( } } +fn handle_spawn_campfire( + server: &mut Server, + client: EcsEntity, + target: EcsEntity, + _args: String, + _action: &ChatCommand, +) { + match server.state.read_component_cloned::(target) { + Some(pos) => { + let vel = Vec3::new( + rand::thread_rng().gen_range(-2.0, 3.0), + rand::thread_rng().gen_range(-2.0, 3.0), + 10.0, + ); + + let body = comp::Body::Object(comp::object::Body::CampfireLit); + + let mut stats = comp::Stats::new("Campfire".to_string(), body); + + // Level 0 will prevent exp gain from kill + stats.level.set_level(0); + + server + .state + .create_npc(pos, stats, comp::Loadout::default(), body) + .with(comp::Vel(vel)) + .with(comp::MountState::Unmounted) + .build(); + + server.notify_client( + client, + ChatType::CommandInfo.server_msg("Spawned a campfire"), + ); + }, + None => server.notify_client( + client, + ChatType::CommandError.server_msg("You have no position!"), + ), + } +} + fn handle_players( server: &mut Server, client: EcsEntity,