mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fmt
Former-commit-id: 4fd53e02969d9d044367d81640a2975043c6953a
This commit is contained in:
parent
761c6e9cf8
commit
216819ca92
@ -137,10 +137,7 @@ pub enum Body {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
pub enum Actor {
|
pub enum Actor {
|
||||||
Character {
|
Character { name: String, body: Body },
|
||||||
name: String,
|
|
||||||
body: Body,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Actor {
|
impl Component for Actor {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
pub mod agent;
|
|
||||||
pub mod actor;
|
pub mod actor;
|
||||||
|
pub mod agent;
|
||||||
pub mod phys;
|
pub mod phys;
|
||||||
pub mod player;
|
pub mod player;
|
||||||
|
|
||||||
// Reexports
|
// Reexports
|
||||||
pub use agent::{Agent, Control};
|
pub use actor::Actor;
|
||||||
pub use actor::Animation;
|
pub use actor::Animation;
|
||||||
pub use actor::AnimationHistory;
|
pub use actor::AnimationHistory;
|
||||||
pub use actor::HumanoidBody;
|
|
||||||
pub use actor::Body;
|
pub use actor::Body;
|
||||||
pub use actor::Actor;
|
pub use actor::HumanoidBody;
|
||||||
|
pub use agent::{Agent, Control};
|
||||||
pub use player::Player;
|
pub use player::Player;
|
||||||
|
@ -191,14 +191,25 @@ fn handle_pet(server: &mut Server, entity: EcsEntity, args: String, action: &Cha
|
|||||||
.read_component_cloned::<comp::phys::Pos>(entity)
|
.read_component_cloned::<comp::phys::Pos>(entity)
|
||||||
{
|
{
|
||||||
Some(pos) => {
|
Some(pos) => {
|
||||||
server.create_npc("Bungo".to_owned(), comp::Body::Humanoid(comp::HumanoidBody::random()))
|
server
|
||||||
|
.create_npc(
|
||||||
|
"Bungo".to_owned(),
|
||||||
|
comp::Body::Humanoid(comp::HumanoidBody::random()),
|
||||||
|
)
|
||||||
.with(comp::Control::default())
|
.with(comp::Control::default())
|
||||||
.with(comp::Agent::Pet{ target: entity, offset: Vec2::zero() })
|
.with(comp::Agent::Pet {
|
||||||
|
target: entity,
|
||||||
|
offset: Vec2::zero(),
|
||||||
|
})
|
||||||
.with(pos)
|
.with(pos)
|
||||||
.build();
|
.build();
|
||||||
server.clients.notify(entity, ServerMsg::Chat("Spawned pet!".to_owned()));
|
server
|
||||||
},
|
.clients
|
||||||
None => server.clients.notify(entity, ServerMsg::Chat("You have no position!".to_owned())),
|
.notify(entity, ServerMsg::Chat("Spawned pet!".to_owned()));
|
||||||
|
}
|
||||||
|
None => server
|
||||||
|
.clients
|
||||||
|
.notify(entity, ServerMsg::Chat("You have no position!".to_owned())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,10 @@ impl Server {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
this.create_npc("Tobermory".to_owned(), comp::Body::Humanoid(comp::HumanoidBody::random()))
|
this.create_npc(
|
||||||
|
"Tobermory".to_owned(),
|
||||||
|
comp::Body::Humanoid(comp::HumanoidBody::random()),
|
||||||
|
)
|
||||||
.with(comp::Control::default())
|
.with(comp::Control::default())
|
||||||
.with(comp::Agent::Wanderer(Vec2::zero()))
|
.with(comp::Agent::Wanderer(Vec2::zero()))
|
||||||
.build();
|
.build();
|
||||||
@ -121,10 +124,7 @@ impl Server {
|
|||||||
.with(comp::phys::Vel(Vec3::zero()))
|
.with(comp::phys::Vel(Vec3::zero()))
|
||||||
.with(comp::phys::Dir(Vec3::unit_y()))
|
.with(comp::phys::Dir(Vec3::unit_y()))
|
||||||
.with(comp::AnimationHistory::new(comp::Animation::Idle))
|
.with(comp::AnimationHistory::new(comp::Animation::Idle))
|
||||||
.with(comp::Actor::Character {
|
.with(comp::Actor::Character { name, body })
|
||||||
name,
|
|
||||||
body,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_player_character(
|
pub fn create_player_character(
|
||||||
@ -134,10 +134,13 @@ impl Server {
|
|||||||
name: String,
|
name: String,
|
||||||
body: comp::HumanoidBody,
|
body: comp::HumanoidBody,
|
||||||
) {
|
) {
|
||||||
state.write_component(entity, comp::Actor::Character {
|
state.write_component(
|
||||||
|
entity,
|
||||||
|
comp::Actor::Character {
|
||||||
name,
|
name,
|
||||||
body: comp::Body::Humanoid(body),
|
body: comp::Body::Humanoid(body),
|
||||||
});
|
},
|
||||||
|
);
|
||||||
state.write_component(entity, comp::phys::Pos(Vec3::new(0.0, 0.0, 64.0)));
|
state.write_component(entity, comp::phys::Pos(Vec3::new(0.0, 0.0, 64.0)));
|
||||||
state.write_component(entity, comp::phys::Vel(Vec3::zero()));
|
state.write_component(entity, comp::phys::Vel(Vec3::zero()));
|
||||||
state.write_component(entity, comp::phys::Dir(Vec3::unit_y()));
|
state.write_component(entity, comp::phys::Dir(Vec3::unit_y()));
|
||||||
@ -145,10 +148,7 @@ impl Server {
|
|||||||
state.write_component(entity, comp::phys::ForceUpdate);
|
state.write_component(entity, comp::phys::ForceUpdate);
|
||||||
|
|
||||||
// Set initial animation
|
// Set initial animation
|
||||||
state.write_component(
|
state.write_component(entity, comp::AnimationHistory::new(comp::Animation::Idle));
|
||||||
entity,
|
|
||||||
comp::AnimationHistory::new(comp::Animation::Idle),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Tell the client his request was successful
|
// Tell the client his request was successful
|
||||||
client.notify(ServerMsg::StateAnswer(Ok(ClientState::Character)));
|
client.notify(ServerMsg::StateAnswer(Ok(ClientState::Character)));
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
use vek::*;
|
|
||||||
use client::Client;
|
|
||||||
use common::{
|
|
||||||
comp::HumanoidBody,
|
|
||||||
figure::Segment,
|
|
||||||
};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
anim::{
|
anim::{
|
||||||
character::{CharacterSkeleton, IdleAnimation},
|
character::{CharacterSkeleton, IdleAnimation},
|
||||||
@ -18,6 +12,9 @@ use crate::{
|
|||||||
figure::{FigureModelCache, FigureState},
|
figure::{FigureModelCache, FigureState},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use client::Client;
|
||||||
|
use common::{comp::HumanoidBody, figure::Segment};
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
struct Skybox {
|
struct Skybox {
|
||||||
model: Model<SkyboxPipeline>,
|
model: Model<SkyboxPipeline>,
|
||||||
|
@ -8,10 +8,8 @@ use crate::{
|
|||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
use common::comp::{
|
use common::comp::{
|
||||||
|
actor::{Belt, BodyType, Chest, Foot, Hand, Head, Pants, Race, Weapon},
|
||||||
HumanoidBody,
|
HumanoidBody,
|
||||||
actor::{
|
|
||||||
Belt, Chest, Foot, BodyType, Hand, Head, Pants, Race, Weapon,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
|
@ -14,9 +14,8 @@ use common::{
|
|||||||
assets,
|
assets,
|
||||||
comp::{
|
comp::{
|
||||||
self,
|
self,
|
||||||
Body,
|
|
||||||
HumanoidBody,
|
|
||||||
actor::{Belt, Chest, Foot, Hand, Head, Pants, Weapon},
|
actor::{Belt, Chest, Foot, Hand, Head, Pants, Weapon},
|
||||||
|
Body, HumanoidBody,
|
||||||
},
|
},
|
||||||
figure::Segment,
|
figure::Segment,
|
||||||
msg,
|
msg,
|
||||||
@ -252,10 +251,9 @@ impl FigureMgr {
|
|||||||
match actor {
|
match actor {
|
||||||
comp::Actor::Character { body, .. } => match body {
|
comp::Actor::Character { body, .. } => match body {
|
||||||
Body::Humanoid(body) => {
|
Body::Humanoid(body) => {
|
||||||
let state = self
|
let state = self.states.entry(entity).or_insert_with(|| {
|
||||||
.states
|
FigureState::new(renderer, CharacterSkeleton::new())
|
||||||
.entry(entity)
|
});
|
||||||
.or_insert_with(|| FigureState::new(renderer, CharacterSkeleton::new()));
|
|
||||||
|
|
||||||
let target_skeleton = match animation_history.current {
|
let target_skeleton = match animation_history.current {
|
||||||
comp::Animation::Idle => IdleAnimation::update_skeleton(
|
comp::Animation::Idle => IdleAnimation::update_skeleton(
|
||||||
@ -278,7 +276,7 @@ impl FigureMgr {
|
|||||||
state.skeleton.interpolate(&target_skeleton);
|
state.skeleton.interpolate(&target_skeleton);
|
||||||
|
|
||||||
state.update(renderer, pos.0, dir.0);
|
state.update(renderer, pos.0, dir.0);
|
||||||
},
|
}
|
||||||
// TODO: Non-humanoid bodies
|
// TODO: Non-humanoid bodies
|
||||||
},
|
},
|
||||||
// TODO: Non-character actors
|
// TODO: Non-character actors
|
||||||
@ -298,14 +296,20 @@ impl FigureMgr {
|
|||||||
let tick = client.get_tick();
|
let tick = client.get_tick();
|
||||||
let ecs = client.state().ecs();
|
let ecs = client.state().ecs();
|
||||||
|
|
||||||
for (entity, actor) in (&ecs.entities(), &ecs.read_storage::<comp::Actor>()).join()
|
for (entity, actor) in (&ecs.entities(), &ecs.read_storage::<comp::Actor>()).join() {
|
||||||
{
|
|
||||||
match actor {
|
match actor {
|
||||||
comp::Actor::Character { body, .. } => match body {
|
comp::Actor::Character { body, .. } => match body {
|
||||||
Body::Humanoid(body) => if let Some(state) = self.states.get(&entity) {
|
Body::Humanoid(body) => {
|
||||||
|
if let Some(state) = self.states.get(&entity) {
|
||||||
let model = self.model_cache.get_or_create_model(renderer, *body, tick);
|
let model = self.model_cache.get_or_create_model(renderer, *body, tick);
|
||||||
renderer.render_figure(model, globals, &state.locals(), state.bone_consts());
|
renderer.render_figure(
|
||||||
},
|
model,
|
||||||
|
globals,
|
||||||
|
&state.locals(),
|
||||||
|
state.bone_consts(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: Non-humanoid bodies
|
// TODO: Non-humanoid bodies
|
||||||
},
|
},
|
||||||
// TODO: Non-character actors
|
// TODO: Non-character actors
|
||||||
|
Loading…
Reference in New Issue
Block a user