mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Smol animals
This commit is contained in:
parent
f140a94dc6
commit
8ff438bb5b
@ -654,6 +654,7 @@ impl ServerChatCommand {
|
|||||||
Enum("entity", ENTITIES.clone(), Required),
|
Enum("entity", ENTITIES.clone(), Required),
|
||||||
Integer("amount", 1, Optional),
|
Integer("amount", 1, Optional),
|
||||||
Boolean("ai", "true".to_string(), Optional),
|
Boolean("ai", "true".to_string(), Optional),
|
||||||
|
Float("ai", 1.0, Optional),
|
||||||
],
|
],
|
||||||
"Spawn a test entity",
|
"Spawn a test entity",
|
||||||
Some(Admin),
|
Some(Admin),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use common::{
|
use common::{
|
||||||
comp::{Body, Controller, InputKind, Ori, Pos, Vel},
|
comp::{Body, Controller, InputKind, Ori, Pos, Vel, Scale},
|
||||||
link::Is,
|
link::Is,
|
||||||
mounting::Mount,
|
mounting::Mount,
|
||||||
uid::UidAllocator,
|
uid::UidAllocator,
|
||||||
@ -24,6 +24,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
WriteStorage<'a, Vel>,
|
WriteStorage<'a, Vel>,
|
||||||
WriteStorage<'a, Ori>,
|
WriteStorage<'a, Ori>,
|
||||||
ReadStorage<'a, Body>,
|
ReadStorage<'a, Body>,
|
||||||
|
ReadStorage<'a, Scale>,
|
||||||
);
|
);
|
||||||
|
|
||||||
const NAME: &'static str = "mount";
|
const NAME: &'static str = "mount";
|
||||||
@ -41,6 +42,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
mut velocities,
|
mut velocities,
|
||||||
mut orientations,
|
mut orientations,
|
||||||
bodies,
|
bodies,
|
||||||
|
scales,
|
||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
// For each mount...
|
// For each mount...
|
||||||
@ -67,8 +69,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
let vel = velocities.get(entity).copied();
|
let vel = velocities.get(entity).copied();
|
||||||
if let (Some(pos), Some(ori), Some(vel)) = (pos, ori, vel) {
|
if let (Some(pos), Some(ori), Some(vel)) = (pos, ori, vel) {
|
||||||
let mounter_body = bodies.get(rider);
|
let mounter_body = bodies.get(rider);
|
||||||
let mounting_offset = body.map_or(Vec3::unit_z(), Body::mount_offset)
|
let mounting_offset = body.map_or(Vec3::unit_z(), Body::mount_offset) * scales.get(entity).map_or(1.0, |s| s.0)
|
||||||
+ mounter_body.map_or(Vec3::zero(), Body::rider_offset);
|
+ mounter_body.map_or(Vec3::zero(), Body::rider_offset) * scales.get(rider).map_or(1.0, |s| s.0);
|
||||||
let _ = positions.insert(rider, Pos(pos.0 + ori.to_quat() * mounting_offset));
|
let _ = positions.insert(rider, Pos(pos.0 + ori.to_quat() * mounting_offset));
|
||||||
let _ = orientations.insert(rider, ori);
|
let _ = orientations.insert(rider, ori);
|
||||||
let _ = velocities.insert(rider, vel);
|
let _ = velocities.insert(rider, vel);
|
||||||
|
@ -1189,8 +1189,8 @@ fn handle_spawn(
|
|||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
action: &ServerChatCommand,
|
action: &ServerChatCommand,
|
||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
match parse_cmd_args!(args, String, npc::NpcBody, u32, bool) {
|
match parse_cmd_args!(args, String, npc::NpcBody, u32, bool, f32) {
|
||||||
(Some(opt_align), Some(npc::NpcBody(id, mut body)), opt_amount, opt_ai) => {
|
(Some(opt_align), Some(npc::NpcBody(id, mut body)), opt_amount, opt_ai, opt_scale) => {
|
||||||
let uid = uid(server, target, "target")?;
|
let uid = uid(server, target, "target")?;
|
||||||
let alignment = parse_alignment(uid, &opt_align)?;
|
let alignment = parse_alignment(uid, &opt_align)?;
|
||||||
let amount = opt_amount.filter(|x| *x > 0).unwrap_or(1).min(50);
|
let amount = opt_amount.filter(|x| *x > 0).unwrap_or(1).min(50);
|
||||||
@ -1227,7 +1227,7 @@ fn handle_spawn(
|
|||||||
body,
|
body,
|
||||||
)
|
)
|
||||||
.with(comp::Vel(vel))
|
.with(comp::Vel(vel))
|
||||||
.with(body.scale())
|
.with(opt_scale.map(comp::Scale).unwrap_or(body.scale()))
|
||||||
.with(alignment);
|
.with(alignment);
|
||||||
|
|
||||||
if ai {
|
if ai {
|
||||||
|
@ -809,7 +809,7 @@ impl FigureMgr {
|
|||||||
const MIN_PERFECT_RATE_DIST: f32 = 100.0;
|
const MIN_PERFECT_RATE_DIST: f32 = 100.0;
|
||||||
|
|
||||||
if (i as u64 + tick)
|
if (i as u64 + tick)
|
||||||
% (((pos.0.distance_squared(focus_pos).powf(0.25) - MIN_PERFECT_RATE_DIST.sqrt())
|
% ((((pos.0.distance_squared(focus_pos) / scale.map_or(1.0, |s| s.0)).powf(0.25) - MIN_PERFECT_RATE_DIST.sqrt())
|
||||||
.max(0.0)
|
.max(0.0)
|
||||||
/ 3.0) as u64)
|
/ 3.0) as u64)
|
||||||
.saturating_add(1)
|
.saturating_add(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user