mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added velorite
This commit is contained in:
parent
deec1e6bca
commit
e22fe81a2f
BIN
assets/voxygen/voxel/sprite/velorite/velorite.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/sprite/velorite/velorite.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -80,6 +80,7 @@ pub enum Consumable {
|
||||
Apple,
|
||||
Potion,
|
||||
Mushroom,
|
||||
Velorite,
|
||||
}
|
||||
|
||||
impl Consumable {
|
||||
@ -88,6 +89,7 @@ impl Consumable {
|
||||
Consumable::Apple => "apple",
|
||||
Consumable::Potion => "potion",
|
||||
Consumable::Mushroom => "mushroom",
|
||||
Consumable::Velorite => "velorite",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,6 +147,7 @@ impl Item {
|
||||
match block.kind() {
|
||||
BlockKind::Apple => Some(Self::apple()),
|
||||
BlockKind::Mushroom => Some(Self::mushroom()),
|
||||
BlockKind::Velorite => Some(Self::velorite()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -164,6 +167,13 @@ impl Item {
|
||||
effect: Effect::Health(10, comp::HealthSource::Item),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn velorite() -> Self {
|
||||
Item::Consumable {
|
||||
kind: Consumable::Mushroom,
|
||||
effect: Effect::Xp(250),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Item {
|
||||
|
22
common/src/comp/location.rs
Normal file
22
common/src/comp/location.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use specs::{Component, FlaggedStorage};
|
||||
use specs_idvs::IDVStorage;
|
||||
use vek::*;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Waypoint {
|
||||
pos: Vec3<f32>,
|
||||
}
|
||||
|
||||
impl Waypoint {
|
||||
pub fn new(pos: Vec3<f32>) -> Self {
|
||||
Self { pos }
|
||||
}
|
||||
|
||||
pub fn get_pos(&self) -> Vec3<f32> {
|
||||
self.pos
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Waypoint {
|
||||
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
||||
}
|
@ -6,6 +6,7 @@ mod controller;
|
||||
mod inputs;
|
||||
mod inventory;
|
||||
mod last;
|
||||
mod location;
|
||||
mod phys;
|
||||
mod player;
|
||||
mod stats;
|
||||
@ -20,7 +21,8 @@ pub use controller::{ControlEvent, Controller, MountState, Mounting};
|
||||
pub use inputs::CanBuild;
|
||||
pub use inventory::{item, Inventory, InventoryUpdate, Item};
|
||||
pub use last::Last;
|
||||
pub use phys::{ForceUpdate, Ori, PhysicsState, Pos, Scale, Vel};
|
||||
pub use location::Waypoint;
|
||||
pub use phys::{ForceUpdate, Mass, Ori, PhysicsState, Pos, Scale, Vel};
|
||||
pub use player::Player;
|
||||
pub use stats::{Equipment, Exp, HealthSource, Level, Stats};
|
||||
pub use visual::LightEmitter;
|
||||
|
@ -34,6 +34,14 @@ impl Component for Scale {
|
||||
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
||||
}
|
||||
|
||||
// Mass
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Mass(pub f32);
|
||||
|
||||
impl Component for Mass {
|
||||
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
||||
}
|
||||
|
||||
// PhysicsState
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PhysicsState {
|
||||
|
@ -29,6 +29,7 @@ sphynx::sum_type! {
|
||||
Scale(comp::Scale),
|
||||
MountState(comp::MountState),
|
||||
Mounting(comp::Mounting),
|
||||
Mass(comp::Mass),
|
||||
}
|
||||
}
|
||||
// Automatically derive From<T> for EcsCompPhantom
|
||||
@ -48,6 +49,7 @@ sphynx::sum_type! {
|
||||
Scale(PhantomData<comp::Scale>),
|
||||
MountState(PhantomData<comp::MountState>),
|
||||
Mounting(PhantomData<comp::Mounting>),
|
||||
Mass(PhantomData<comp::Mass>),
|
||||
}
|
||||
}
|
||||
impl sphynx::CompPacket for EcsCompPacket {
|
||||
|
@ -131,6 +131,7 @@ impl State {
|
||||
ecs.register_synced::<comp::Scale>();
|
||||
ecs.register_synced::<comp::Mounting>();
|
||||
ecs.register_synced::<comp::MountState>();
|
||||
ecs.register_synced::<comp::Mass>();
|
||||
|
||||
// Register components send from clients -> server
|
||||
ecs.register::<comp::Controller>();
|
||||
@ -155,6 +156,7 @@ impl State {
|
||||
ecs.register::<comp::InventoryUpdate>();
|
||||
ecs.register::<comp::Inventory>();
|
||||
ecs.register::<comp::Admin>();
|
||||
ecs.register::<comp::Waypoint>();
|
||||
|
||||
// Register synced resources used by the ECS.
|
||||
ecs.insert_synced(TimeOfDay(0.0));
|
||||
|
@ -1,6 +1,6 @@
|
||||
use {
|
||||
crate::{
|
||||
comp::{Body, Mounting, Ori, PhysicsState, Pos, Scale, Vel},
|
||||
comp::{Body, Mass, Mounting, Ori, PhysicsState, Pos, Scale, Vel},
|
||||
event::{EventBus, LocalEvent},
|
||||
state::DeltaTime,
|
||||
terrain::{Block, TerrainGrid},
|
||||
@ -45,6 +45,7 @@ impl<'a> System<'a> for Sys {
|
||||
Read<'a, DeltaTime>,
|
||||
Read<'a, EventBus<LocalEvent>>,
|
||||
ReadStorage<'a, Scale>,
|
||||
ReadStorage<'a, Mass>,
|
||||
ReadStorage<'a, Body>,
|
||||
WriteStorage<'a, PhysicsState>,
|
||||
WriteStorage<'a, Pos>,
|
||||
@ -61,6 +62,7 @@ impl<'a> System<'a> for Sys {
|
||||
dt,
|
||||
event_bus,
|
||||
scales,
|
||||
masses,
|
||||
bodies,
|
||||
mut physics_states,
|
||||
mut positions,
|
||||
@ -320,9 +322,10 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
|
||||
// Apply pushback
|
||||
for (pos, scale, vel, _, _) in (
|
||||
for (pos, scale, mass, vel, _, _) in (
|
||||
&positions,
|
||||
scales.maybe(),
|
||||
masses.maybe(),
|
||||
&mut velocities,
|
||||
&bodies,
|
||||
!&mountings,
|
||||
@ -330,10 +333,18 @@ impl<'a> System<'a> for Sys {
|
||||
.join()
|
||||
{
|
||||
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
||||
for (pos_other, scale_other, _, _) in
|
||||
(&positions, scales.maybe(), &bodies, !&mountings).join()
|
||||
let mass = mass.map(|m| m.0).unwrap_or(scale);
|
||||
for (pos_other, scale_other, mass_other, _, _) in (
|
||||
&positions,
|
||||
scales.maybe(),
|
||||
masses.maybe(),
|
||||
&bodies,
|
||||
!&mountings,
|
||||
)
|
||||
.join()
|
||||
{
|
||||
let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0);
|
||||
let mass_other = mass_other.map(|m| m.0).unwrap_or(scale_other);
|
||||
let diff = Vec2::<f32>::from(pos.0 - pos_other.0);
|
||||
|
||||
let collision_dist = 0.95 * (scale + scale_other);
|
||||
@ -343,8 +354,9 @@ impl<'a> System<'a> for Sys {
|
||||
&& pos.0.z + 1.6 * scale > pos_other.0.z
|
||||
&& pos.0.z < pos_other.0.z + 1.6 * scale_other
|
||||
{
|
||||
vel.0 +=
|
||||
Vec3::from(diff.normalized()) * (collision_dist - diff.magnitude()) * 1.0;
|
||||
let force = (collision_dist - diff.magnitude()) * 2.0 * mass_other
|
||||
/ (mass + mass_other);
|
||||
vel.0 += Vec3::from(diff.normalized()) * force;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ pub enum BlockKind {
|
||||
Apple,
|
||||
Mushroom,
|
||||
Liana,
|
||||
Velorite,
|
||||
}
|
||||
|
||||
impl BlockKind {
|
||||
@ -61,6 +62,7 @@ impl BlockKind {
|
||||
BlockKind::Apple => true,
|
||||
BlockKind::Mushroom => true,
|
||||
BlockKind::Liana => true,
|
||||
BlockKind::Velorite => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -95,6 +97,7 @@ impl BlockKind {
|
||||
BlockKind::Apple => false,
|
||||
BlockKind::Mushroom => false,
|
||||
BlockKind::Liana => false,
|
||||
BlockKind::Velorite => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
@ -189,14 +189,21 @@ lazy_static! {
|
||||
"explosion",
|
||||
"{}",
|
||||
"/explosion <radius> : Explodes the ground around you",
|
||||
false,
|
||||
true,
|
||||
handle_explosion,
|
||||
),
|
||||
ChatCommand::new(
|
||||
"waypoint",
|
||||
"{}",
|
||||
"/waypoint : Set your waypoint to your current position",
|
||||
true,
|
||||
handle_waypoint,
|
||||
),
|
||||
ChatCommand::new(
|
||||
"adminify",
|
||||
"{}",
|
||||
"/adminify <playername> : Temporarily gives a player admin permissions or removes them",
|
||||
true,
|
||||
false, // TODO: NO
|
||||
handle_adminify,
|
||||
),
|
||||
ChatCommand::new(
|
||||
@ -757,6 +764,25 @@ fn handle_explosion(server: &mut Server, entity: EcsEntity, args: String, action
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_waypoint(server: &mut Server, entity: EcsEntity, _args: String, _action: &ChatCommand) {
|
||||
match server.state.read_component_cloned::<comp::Pos>(entity) {
|
||||
Some(pos) => {
|
||||
let _ = server
|
||||
.state
|
||||
.ecs()
|
||||
.write_storage::<comp::Waypoint>()
|
||||
.insert(entity, comp::Waypoint::new(pos.0));
|
||||
server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::private(String::from("Waypoint set!")));
|
||||
}
|
||||
None => server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::private(String::from("You have no position!")),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_adminify(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) {
|
||||
if let Ok(alias) = scan_fmt!(&args, action.arg_fmt, String) {
|
||||
let ecs = server.state.ecs();
|
||||
|
@ -356,6 +356,11 @@ impl Server {
|
||||
ServerEvent::Respawn(entity) => {
|
||||
// Only clients can respawn
|
||||
if let Some(client) = clients.get_mut(&entity) {
|
||||
let respawn_point = state
|
||||
.read_component_cloned::<comp::Waypoint>(entity)
|
||||
.map(|wp| wp.get_pos())
|
||||
.unwrap_or(state.ecs().read_resource::<SpawnPoint>().0);
|
||||
|
||||
client.allow_state(ClientState::Character);
|
||||
state
|
||||
.ecs_mut()
|
||||
@ -366,7 +371,7 @@ impl Server {
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::Pos>()
|
||||
.get_mut(entity)
|
||||
.map(|pos| pos.0.z += 20.0);
|
||||
.map(|pos| pos.0 = respawn_point);
|
||||
let _ = state
|
||||
.ecs_mut()
|
||||
.write_storage()
|
||||
|
@ -108,7 +108,7 @@ impl FigureMgr {
|
||||
.and_then(|stats| stats.health.last_change)
|
||||
.map(|(_, time, _)| {
|
||||
Rgba::broadcast(1.0)
|
||||
+ Rgba::new(1.0, 1.0, 1.0, 0.0)
|
||||
+ Rgba::new(2.0, 2.0, 2.0, 0.0)
|
||||
.map(|c| (c / (1.0 + DAMAGE_FADE_COEFFICIENT * time)) as f32)
|
||||
})
|
||||
.unwrap_or(Rgba::broadcast(1.0));
|
||||
|
@ -131,6 +131,10 @@ fn sprite_config_for(kind: BlockKind) -> Option<SpriteConfig> {
|
||||
variations: 2,
|
||||
wind_sway: 0.05,
|
||||
}),
|
||||
BlockKind::Velorite => Some(SpriteConfig {
|
||||
variations: 1,
|
||||
wind_sway: 0.0,
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -596,6 +600,13 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
Vec3::new(-1.0, -0.5, -55.0),
|
||||
),
|
||||
),
|
||||
(
|
||||
(BlockKind::Velorite, 0),
|
||||
make_model(
|
||||
"voxygen.voxel.sprite.velorite.velorite",
|
||||
Vec3::new(-5.0, -5.0, -0.0),
|
||||
),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
|
@ -315,6 +315,14 @@ impl<'a> BlockGen<'a> {
|
||||
},
|
||||
Rgb::broadcast(0),
|
||||
))
|
||||
} else if (wposf.z as f32) < height + 0.9
|
||||
&& chaos > 0.6
|
||||
&& (wposf.z as f32 > water_height + 3.0)
|
||||
&& marble > 0.75
|
||||
&& marble_small > 0.5
|
||||
&& (marble * 7323.07).fract() < 0.75
|
||||
{
|
||||
Some(Block::new(BlockKind::Velorite, Rgb::broadcast(0)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user