mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'static_entities' into 'master'
Spawn objects by name, more assets See merge request veloren/veloren!359
This commit is contained in:
commit
b5e4b701e1
BIN
assets/voxygen/voxel/object/anvil.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/anvil.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/bed_blue.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/bed_blue.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/bench.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/bench.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/carpet1.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/carpet1.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/cauldron.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/cauldron.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/chair.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/chair.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/door_spooky.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/door_spooky.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/drawer.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/drawer.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/gravestone1.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/gravestone1.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/gravestone2.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/gravestone2.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/lantern_ground.vox
(Stored with Git LFS)
BIN
assets/voxygen/voxel/object/lantern_ground.vox
(Stored with Git LFS)
Binary file not shown.
BIN
assets/voxygen/voxel/object/table.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/table.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/tent.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/tent.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/object/window_spooky.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/object/window_spooky.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -4,6 +4,7 @@ use rand::{seq::SliceRandom, thread_rng};
|
||||
pub enum Body {
|
||||
Bomb,
|
||||
Scarecrow,
|
||||
Cauldron,
|
||||
ChestVines,
|
||||
Chest,
|
||||
ChestDark,
|
||||
@ -26,6 +27,18 @@ pub enum Body {
|
||||
PotionGreen,
|
||||
PotionRed,
|
||||
Crate,
|
||||
Tent,
|
||||
WindowSpooky,
|
||||
DoorSpooky,
|
||||
Anvil,
|
||||
Gravestone1,
|
||||
Gravestone2,
|
||||
Bench,
|
||||
Chair,
|
||||
Table,
|
||||
Drawer,
|
||||
BedBlue,
|
||||
Carpet1,
|
||||
}
|
||||
|
||||
impl Body {
|
||||
@ -35,9 +48,10 @@ impl Body {
|
||||
}
|
||||
}
|
||||
|
||||
const ALL_OBJECTS: [Body; 24] = [
|
||||
const ALL_OBJECTS: [Body; 37] = [
|
||||
Body::Bomb,
|
||||
Body::Scarecrow,
|
||||
Body::Cauldron,
|
||||
Body::ChestVines,
|
||||
Body::Chest,
|
||||
Body::ChestDark,
|
||||
@ -60,4 +74,16 @@ const ALL_OBJECTS: [Body; 24] = [
|
||||
Body::PotionBlue,
|
||||
Body::PotionGreen,
|
||||
Body::Crate,
|
||||
Body::Tent,
|
||||
Body::WindowSpooky,
|
||||
Body::DoorSpooky,
|
||||
Body::Anvil,
|
||||
Body::Gravestone1,
|
||||
Body::Gravestone2,
|
||||
Body::Bench,
|
||||
Body::Chair,
|
||||
Body::Table,
|
||||
Body::Drawer,
|
||||
Body::BedBlue,
|
||||
Body::Carpet1,
|
||||
];
|
||||
|
@ -3,6 +3,7 @@
|
||||
//! and provide a handler function.
|
||||
|
||||
use crate::Server;
|
||||
use common::comp::object::Body;
|
||||
use common::{
|
||||
comp,
|
||||
msg::ServerMsg,
|
||||
@ -134,7 +135,7 @@ lazy_static! {
|
||||
ChatCommand::new(
|
||||
"object",
|
||||
"{}",
|
||||
"/object : Spawn a random object",
|
||||
"/object [Name]: Spawn an object",
|
||||
handle_object,
|
||||
),
|
||||
];
|
||||
@ -312,7 +313,7 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
||||
let (opt_align, opt_id, opt_amount) = scan_fmt!(&args, action.arg_fmt, String, NpcKind, String);
|
||||
// This should be just an enum handled with scan_fmt!
|
||||
let opt_agent = alignment_to_agent(&opt_align.unwrap_or(String::new()), entity);
|
||||
|
||||
let _objtype = scan_fmt!(&args, action.arg_fmt, String);
|
||||
// Make sure the amount is either not provided or a valid value
|
||||
let opt_amount = opt_amount
|
||||
.map_or(Some(1), |a| a.parse().ok())
|
||||
@ -450,7 +451,8 @@ fn handle_killnpcs(server: &mut Server, entity: EcsEntity, _args: String, _actio
|
||||
server.clients.notify(entity, ServerMsg::Chat(text));
|
||||
}
|
||||
|
||||
fn handle_object(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) {
|
||||
fn handle_object(server: &mut Server, entity: EcsEntity, args: String, _action: &ChatCommand) {
|
||||
let obj_type = scan_fmt!(&args, _action.arg_fmt, String);
|
||||
let pos = server
|
||||
.state
|
||||
.ecs()
|
||||
@ -458,9 +460,50 @@ fn handle_object(server: &mut Server, entity: EcsEntity, _args: String, _action:
|
||||
.get(entity)
|
||||
.copied();
|
||||
if let Some(pos) = pos {
|
||||
server
|
||||
.create_object(pos, comp::object::Body::random())
|
||||
.build();
|
||||
let obj_type = match obj_type.as_ref().map(String::as_str) {
|
||||
Some("Scarecrow") => comp::object::Body::Scarecrow,
|
||||
Some("Cauldron") => comp::object::Body::Cauldron,
|
||||
Some("Chest_Vines") => comp::object::Body::ChestVines,
|
||||
Some("Chest") => comp::object::Body::Chest,
|
||||
Some("Chest_Dark") => comp::object::Body::ChestDark,
|
||||
Some("Chest_Demon") => comp::object::Body::ChestDemon,
|
||||
Some("Chest_Gold") => comp::object::Body::ChestGold,
|
||||
Some("Chest_Light") => comp::object::Body::ChestLight,
|
||||
Some("Chest_Open") => comp::object::Body::ChestOpen,
|
||||
Some("Chest_Skull") => comp::object::Body::ChestSkull,
|
||||
Some("Pumpkin_1") => comp::object::Body::Pumpkin1,
|
||||
Some("Pumpkin_2") => comp::object::Body::Pumpkin2,
|
||||
Some("Pumpkin_3") => comp::object::Body::Pumpkin3,
|
||||
Some("Pumpkin_4") => comp::object::Body::Pumpkin4,
|
||||
Some("Pumpkin_5") => comp::object::Body::Pumpkin5,
|
||||
Some("Campfire") => comp::object::Body::Campfire,
|
||||
Some("Lantern_Ground") => comp::object::Body::LanternGround,
|
||||
Some("Lantern_Ground_Open") => comp::object::Body::LanternGroundOpen,
|
||||
Some("Lantern_Standing_2") => comp::object::Body::LanternStanding2,
|
||||
Some("Lantern_Standing") => comp::object::Body::LanternStanding,
|
||||
Some("Potion_Blue") => comp::object::Body::PotionBlue,
|
||||
Some("Potion_Green") => comp::object::Body::PotionGreen,
|
||||
Some("Potion_Red") => comp::object::Body::PotionRed,
|
||||
Some("Crate") => comp::object::Body::Crate,
|
||||
Some("Tent") => comp::object::Body::Tent,
|
||||
Some("Bomb") => comp::object::Body::Bomb,
|
||||
Some("Window_Spooky") => comp::object::Body::WindowSpooky,
|
||||
Some("Carpet_1") => comp::object::Body::Carpet1,
|
||||
Some("Table") => comp::object::Body::Table,
|
||||
Some("Drawer") => comp::object::Body::Drawer,
|
||||
Some("Bed_Blue") => comp::object::Body::BedBlue,
|
||||
Some("Anvil") => comp::object::Body::Anvil,
|
||||
Some("Gravestone_1") => comp::object::Body::Gravestone1,
|
||||
Some("Gravestone_2") => comp::object::Body::Gravestone2,
|
||||
Some("Chair") => comp::object::Body::Chair,
|
||||
Some("Bench") => comp::object::Body::Bench,
|
||||
_ => {
|
||||
return server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(String::from("Object not found!")));
|
||||
}
|
||||
};
|
||||
server.create_object(pos, obj_type).build();
|
||||
server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(format!("Spawned object.")));
|
||||
|
@ -516,6 +516,7 @@ impl FigureModelCache {
|
||||
let (name, offset) = match obj {
|
||||
object::Body::Bomb => ("object/bomb.vox", Vec3::new(-5.5, -5.5, 0.0)),
|
||||
object::Body::Scarecrow => ("object/scarecrow.vox", Vec3::new(-9.5, -4.0, 0.0)),
|
||||
object::Body::Cauldron => ("object/cauldron.vox", Vec3::new(-10.0, -10.0, 0.0)),
|
||||
object::Body::ChestVines => ("object/chest_vines.vox", Vec3::new(-7.5, -6.0, 0.0)),
|
||||
object::Body::Chest => ("object/chest.vox", Vec3::new(-7.5, -6.0, 0.0)),
|
||||
object::Body::ChestDark => ("object/chest_dark.vox", Vec3::new(-7.5, -6.0, 0.0)),
|
||||
@ -546,6 +547,20 @@ impl FigureModelCache {
|
||||
object::Body::PotionBlue => ("object/potion_blue.vox", Vec3::new(-2.0, -2.0, 0.0)),
|
||||
object::Body::PotionGreen => ("object/potion_green.vox", Vec3::new(-2.0, -2.0, 0.0)),
|
||||
object::Body::Crate => ("object/crate.vox", Vec3::new(-7.0, -7.0, 0.0)),
|
||||
object::Body::Tent => ("object/tent.vox", Vec3::new(-18.5, -19.5, 0.0)),
|
||||
object::Body::WindowSpooky => {
|
||||
("object/window_spooky.vox", Vec3::new(-15.0, -1.5, -1.0))
|
||||
}
|
||||
object::Body::DoorSpooky => ("object/door_spooky.vox", Vec3::new(-15.0, -4.5, 0.0)),
|
||||
object::Body::Table => ("object/table.vox", Vec3::new(-12.0, -6.0, 0.0)),
|
||||
object::Body::Drawer => ("object/drawer.vox", Vec3::new(-6.5, -6.5, 0.0)),
|
||||
object::Body::BedBlue => ("object/bed_blue.vox", Vec3::new(-8.5, -5.0, 0.0)),
|
||||
object::Body::Anvil => ("object/anvil.vox", Vec3::new(-3.0, -7.0, 0.0)),
|
||||
object::Body::Gravestone1 => ("object/gravestone1.vox", Vec3::new(-5.0, -2.0, 0.0)),
|
||||
object::Body::Gravestone2 => ("object/gravestone2.vox", Vec3::new(-8.5, -3.0, 0.0)),
|
||||
object::Body::Chair => ("object/chair.vox", Vec3::new(-3.5, -4.0, 0.0)),
|
||||
object::Body::Bench => ("object/bench.vox", Vec3::new(-8.8, -5.0, 0.0)),
|
||||
object::Body::Carpet1 => ("object/carpet1.vox", Vec3::new(-14.0, -14.0, -0.5)),
|
||||
};
|
||||
Self::load_mesh(name, offset)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user