mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix warnings in rtsim
This commit is contained in:
parent
adb2e1ba85
commit
7ac6c6b453
@ -747,9 +747,14 @@ impl ServerChatCommand {
|
||||
ServerChatCommand::Lightning => {
|
||||
cmd(vec![], "Lightning strike at current position", Some(Admin))
|
||||
},
|
||||
ServerChatCommand::Scale => {
|
||||
cmd(vec![Float("factor", 1.0, Required), Boolean("reset_mass", true.to_string(), Optional)], "Scale your character", Some(Admin))
|
||||
},
|
||||
ServerChatCommand::Scale => cmd(
|
||||
vec![
|
||||
Float("factor", 1.0, Required),
|
||||
Boolean("reset_mass", true.to_string(), Optional),
|
||||
],
|
||||
"Scale your character",
|
||||
Some(Admin),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,38 +81,47 @@ impl NpcBuilder {
|
||||
self.health = health.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_poise(mut self, poise: comp::Poise) -> Self {
|
||||
self.poise = poise;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_agent(mut self, agent: impl Into<Option<comp::Agent>>) -> Self {
|
||||
self.agent = agent.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_anchor(mut self, anchor: comp::Anchor) -> Self {
|
||||
self.anchor = Some(anchor);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_rtsim(mut self, rtsim: RtSimEntity) -> Self {
|
||||
self.rtsim_entity = Some(rtsim);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_projectile(mut self, projectile: impl Into<Option<comp::Projectile>>) -> Self {
|
||||
self.projectile = projectile.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_scale(mut self, scale: comp::Scale) -> Self {
|
||||
self.scale = scale;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_inventory(mut self, inventory: comp::Inventory) -> Self {
|
||||
self.inventory = inventory;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_skill_set(mut self, skill_set: comp::SkillSet) -> Self {
|
||||
self.skill_set = skill_set;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_loot(mut self, loot: LootSpec<String>) -> Self {
|
||||
self.loot = loot;
|
||||
self
|
||||
|
@ -7,8 +7,8 @@ use crate::{
|
||||
},
|
||||
lottery::LootSpec,
|
||||
npc::{self, NPC_NAMES},
|
||||
trade::SiteInformation,
|
||||
rtsim,
|
||||
trade::SiteInformation,
|
||||
};
|
||||
use enum_map::EnumMap;
|
||||
use serde::Deserialize;
|
||||
|
@ -3,8 +3,8 @@
|
||||
// `Agent`). When possible, this should be moved to the `rtsim`
|
||||
// module in `server`.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specs::Component;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use vek::*;
|
||||
|
||||
use crate::comp::dialogue::MoodState;
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
skillset::skills,
|
||||
Behavior, BehaviorCapability, CharacterState, Projectile, StateUpdate,
|
||||
},
|
||||
event::{LocalEvent, ServerEvent, NpcBuilder},
|
||||
event::{LocalEvent, NpcBuilder, ServerEvent},
|
||||
outcome::Outcome,
|
||||
skillset_builder::{self, SkillSetBuilder},
|
||||
states::{
|
||||
@ -181,15 +181,15 @@ impl CharacterBehavior for Data {
|
||||
.with_agent(
|
||||
comp::Agent::from_body(&body)
|
||||
.with_behavior(Behavior::from(BehaviorCapability::SPEAK))
|
||||
.with_no_flee_if(true)
|
||||
.with_no_flee_if(true),
|
||||
)
|
||||
.with_scale(
|
||||
self
|
||||
.static_data
|
||||
.summon_info
|
||||
.scale
|
||||
.unwrap_or(comp::Scale(1.0))
|
||||
).with_projectile(projectile)
|
||||
self.static_data
|
||||
.summon_info
|
||||
.scale
|
||||
.unwrap_or(comp::Scale(1.0)),
|
||||
)
|
||||
.with_projectile(projectile),
|
||||
});
|
||||
|
||||
// Send local event used for frontend shenanigans
|
||||
|
@ -5,8 +5,8 @@ use crate::{
|
||||
item::{tool::AbilityMap, MaterialStatManifest},
|
||||
ActiveAbilities, Beam, Body, CharacterState, Combo, ControlAction, Controller,
|
||||
ControllerInputs, Density, Energy, Health, InputAttr, InputKind, Inventory,
|
||||
InventoryAction, Mass, Melee, Ori, PhysicsState, Pos, SkillSet, Stance, StateUpdate, Stats,
|
||||
Vel, Scale,
|
||||
InventoryAction, Mass, Melee, Ori, PhysicsState, Pos, Scale, SkillSet, Stance, StateUpdate, Stats,
|
||||
Vel,
|
||||
},
|
||||
link::Is,
|
||||
mounting::Rider,
|
||||
|
@ -76,7 +76,8 @@ impl CharacterBehavior for Data {
|
||||
// They've climbed atop something, give them a boost
|
||||
output_events.emit_local(LocalEvent::Jump(
|
||||
data.entity,
|
||||
CLIMB_BOOST_JUMP_FACTOR * impulse / data.mass.0 * data.scale.map_or(1.0, |s| s.0.powf(13.0).powf(0.25)),
|
||||
CLIMB_BOOST_JUMP_FACTOR * impulse / data.mass.0
|
||||
* data.scale.map_or(1.0, |s| s.0.powf(13.0).powf(0.25)),
|
||||
));
|
||||
};
|
||||
update.character = CharacterState::Idle(idle::Data::default());
|
||||
@ -122,10 +123,14 @@ impl CharacterBehavior for Data {
|
||||
// Apply Vertical Climbing Movement
|
||||
match climb {
|
||||
Climb::Down => {
|
||||
update.vel.0.z += data.dt.0 * (GRAVITY - self.static_data.movement_speed.powi(2) * data.scale.map_or(1.0, |s| s.0))
|
||||
update.vel.0.z += data.dt.0
|
||||
* (GRAVITY
|
||||
- self.static_data.movement_speed.powi(2) * data.scale.map_or(1.0, |s| s.0))
|
||||
},
|
||||
Climb::Up => {
|
||||
update.vel.0.z += data.dt.0 * (GRAVITY + self.static_data.movement_speed.powi(2) * data.scale.map_or(1.0, |s| s.0))
|
||||
update.vel.0.z += data.dt.0
|
||||
* (GRAVITY
|
||||
+ self.static_data.movement_speed.powi(2) * data.scale.map_or(1.0, |s| s.0))
|
||||
},
|
||||
Climb::Hold => update.vel.0.z += data.dt.0 * GRAVITY,
|
||||
}
|
||||
|
@ -388,7 +388,8 @@ fn basic_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) {
|
||||
data.body.base_accel()
|
||||
* data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* block.get_traction()
|
||||
* block.get_friction() / FRIC_GROUND
|
||||
* block.get_friction()
|
||||
/ FRIC_GROUND
|
||||
} else {
|
||||
data.body.air_accel()
|
||||
} * efficiency;
|
||||
@ -437,8 +438,11 @@ pub fn handle_forced_movement(
|
||||
// FRIC_GROUND temporarily used to normalize things around expected values
|
||||
data.body.base_accel() * block.get_traction() * block.get_friction() / FRIC_GROUND
|
||||
}) {
|
||||
update.vel.0 +=
|
||||
Vec2::broadcast(data.dt.0) * accel * data.scale.map_or(1.0, |s| s.0.sqrt()) * Vec2::from(*data.ori) * strength;
|
||||
update.vel.0 += Vec2::broadcast(data.dt.0)
|
||||
* accel
|
||||
* data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* Vec2::from(*data.ori)
|
||||
* strength;
|
||||
}
|
||||
},
|
||||
ForcedMovement::Reverse(strength) => {
|
||||
@ -447,8 +451,11 @@ pub fn handle_forced_movement(
|
||||
// FRIC_GROUND temporarily used to normalize things around expected values
|
||||
data.body.base_accel() * block.get_traction() * block.get_friction() / FRIC_GROUND
|
||||
}) {
|
||||
update.vel.0 +=
|
||||
Vec2::broadcast(data.dt.0) * accel * data.scale.map_or(1.0, |s| s.0.sqrt()) * -Vec2::from(*data.ori) * strength;
|
||||
update.vel.0 += Vec2::broadcast(data.dt.0)
|
||||
* accel
|
||||
* data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* -Vec2::from(*data.ori)
|
||||
* strength;
|
||||
}
|
||||
},
|
||||
ForcedMovement::Sideways(strength) => {
|
||||
@ -470,7 +477,11 @@ pub fn handle_forced_movement(
|
||||
}
|
||||
};
|
||||
|
||||
update.vel.0 += Vec2::broadcast(data.dt.0) * accel * data.scale.map_or(1.0, |s| s.0.sqrt()) * direction * strength;
|
||||
update.vel.0 += Vec2::broadcast(data.dt.0)
|
||||
* accel
|
||||
* data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* direction
|
||||
* strength;
|
||||
}
|
||||
},
|
||||
ForcedMovement::DirectedReverse(strength) => {
|
||||
@ -532,9 +543,10 @@ pub fn handle_forced_movement(
|
||||
* (1.0 - data.inputs.look_dir.z.abs());
|
||||
},
|
||||
ForcedMovement::Hover { move_input } => {
|
||||
update.vel.0 = Vec3::new(data.vel.0.x, data.vel.0.y, 0.0) + move_input
|
||||
* data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* data.inputs.move_dir.try_normalized().unwrap_or_default();
|
||||
update.vel.0 = Vec3::new(data.vel.0.x, data.vel.0.y, 0.0)
|
||||
+ move_input
|
||||
* data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* data.inputs.move_dir.try_normalized().unwrap_or_default();
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -574,8 +586,7 @@ pub fn handle_orientation(
|
||||
.map_or_else(|| to_horizontal_fast(data.ori), |dir| dir.into())
|
||||
};
|
||||
// unit is multiples of 180°
|
||||
let half_turns_per_tick = data.body.base_ori_rate()
|
||||
/ data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
let half_turns_per_tick = data.body.base_ori_rate() / data.scale.map_or(1.0, |s| s.0.sqrt())
|
||||
* efficiency
|
||||
* if data.physics.on_ground.is_some() {
|
||||
1.0
|
||||
|
@ -3,8 +3,7 @@ use crate::{
|
||||
comp::{fluid_dynamics::LiquidKind, tool::ToolKind},
|
||||
consts::FRIC_GROUND,
|
||||
lottery::LootSpec,
|
||||
make_case_elim,
|
||||
rtsim,
|
||||
make_case_elim, rtsim,
|
||||
};
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
@ -196,7 +195,9 @@ impl Block {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the rtsim resource, if any, that this block corresponds to. If you want the scarcity of a block to change with rtsim's resource depletion tracking, you can do so by editing this function.
|
||||
/// Returns the rtsim resource, if any, that this block corresponds to. If
|
||||
/// you want the scarcity of a block to change with rtsim's resource
|
||||
/// depletion tracking, you can do so by editing this function.
|
||||
#[inline]
|
||||
pub fn get_rtsim_resource(&self) -> Option<rtsim::ChunkResource> {
|
||||
match self.get_sprite()? {
|
||||
|
@ -240,7 +240,7 @@ impl<R: Send + Sync + 'static, F: FnMut(&mut NpcCtx) -> A + Send + Sync + 'stati
|
||||
Action<R> for Now<F, A>
|
||||
{
|
||||
// TODO: This doesn't compare?!
|
||||
fn is_same(&self, other: &Self) -> bool { true }
|
||||
fn is_same(&self, _other: &Self) -> bool { true }
|
||||
|
||||
fn dyn_is_same(&self, other: &dyn Action<R>) -> bool { self.dyn_is_same_sized(other) }
|
||||
|
||||
@ -293,7 +293,7 @@ impl<
|
||||
> Action<()> for Until<F, A, R>
|
||||
{
|
||||
// TODO: This doesn't compare?!
|
||||
fn is_same(&self, other: &Self) -> bool { true }
|
||||
fn is_same(&self, _other: &Self) -> bool { true }
|
||||
|
||||
fn dyn_is_same(&self, other: &dyn Action<()>) -> bool { self.dyn_is_same_sized(other) }
|
||||
|
||||
@ -345,11 +345,11 @@ pub struct Just<F, R = ()>(F, PhantomData<R>);
|
||||
impl<R: Send + Sync + 'static, F: FnMut(&mut NpcCtx) -> R + Send + Sync + 'static> Action<R>
|
||||
for Just<F, R>
|
||||
{
|
||||
fn is_same(&self, other: &Self) -> bool { true }
|
||||
fn is_same(&self, _other: &Self) -> bool { true }
|
||||
|
||||
fn dyn_is_same(&self, other: &dyn Action<R>) -> bool { self.dyn_is_same_sized(other) }
|
||||
|
||||
fn backtrace(&self, bt: &mut Vec<String>) {}
|
||||
fn backtrace(&self, _bt: &mut Vec<String>) {}
|
||||
|
||||
// TODO: Reset closure?
|
||||
fn reset(&mut self) {}
|
||||
@ -369,7 +369,7 @@ impl<R: Send + Sync + 'static, F: FnMut(&mut NpcCtx) -> R + Send + Sync + 'stati
|
||||
/// // Make the current NPC say 'Hello, world!' exactly once
|
||||
/// just(|ctx| ctx.controller.say("Hello, world!"))
|
||||
/// ```
|
||||
pub fn just<F, R: Send + Sync + 'static>(mut f: F) -> Just<F, R>
|
||||
pub fn just<F, R: Send + Sync + 'static>(f: F) -> Just<F, R>
|
||||
where
|
||||
F: FnMut(&mut NpcCtx) -> R + Send + Sync + 'static,
|
||||
{
|
||||
@ -383,15 +383,15 @@ where
|
||||
pub struct Finish;
|
||||
|
||||
impl Action<()> for Finish {
|
||||
fn is_same(&self, other: &Self) -> bool { true }
|
||||
fn is_same(&self, _other: &Self) -> bool { true }
|
||||
|
||||
fn dyn_is_same(&self, other: &dyn Action<()>) -> bool { self.dyn_is_same_sized(other) }
|
||||
|
||||
fn backtrace(&self, bt: &mut Vec<String>) {}
|
||||
fn backtrace(&self, _bt: &mut Vec<String>) {}
|
||||
|
||||
fn reset(&mut self) {}
|
||||
|
||||
fn tick(&mut self, ctx: &mut NpcCtx) -> ControlFlow<()> { ControlFlow::Break(()) }
|
||||
fn tick(&mut self, _ctx: &mut NpcCtx) -> ControlFlow<()> { ControlFlow::Break(()) }
|
||||
}
|
||||
|
||||
/// An action that immediately finishes without doing anything.
|
||||
@ -443,7 +443,7 @@ pub struct Tree<F, R> {
|
||||
impl<F: FnMut(&mut NpcCtx) -> Node<R> + Send + Sync + 'static, R: 'static> Action<R>
|
||||
for Tree<F, R>
|
||||
{
|
||||
fn is_same(&self, other: &Self) -> bool { true }
|
||||
fn is_same(&self, _other: &Self) -> bool { true }
|
||||
|
||||
fn dyn_is_same(&self, other: &dyn Action<R>) -> bool { self.dyn_is_same_sized(other) }
|
||||
|
||||
@ -626,7 +626,7 @@ pub struct Sequence<I, A, R = ()>(I, I, Option<A>, PhantomData<R>);
|
||||
impl<R: Send + Sync + 'static, I: Iterator<Item = A> + Clone + Send + Sync + 'static, A: Action<R>>
|
||||
Action<()> for Sequence<I, A, R>
|
||||
{
|
||||
fn is_same(&self, other: &Self) -> bool { true }
|
||||
fn is_same(&self, _other: &Self) -> bool { true }
|
||||
|
||||
fn dyn_is_same(&self, other: &dyn Action<()>) -> bool { self.dyn_is_same_sized(other) }
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
use super::Actor;
|
||||
pub use common::rtsim::FactionId;
|
||||
use common::{store::Id, uid::Uid};
|
||||
use hashbrown::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slotmap::HopSlotMap;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
@ -12,10 +12,7 @@ pub use self::{
|
||||
|
||||
use common::resources::TimeOfDay;
|
||||
use enum_map::{enum_map, EnumArray, EnumMap};
|
||||
use serde::{
|
||||
de::{self, Error as _},
|
||||
ser, Deserialize, Serialize,
|
||||
};
|
||||
use serde::{de, ser, Deserialize, Serialize};
|
||||
use std::{
|
||||
cmp::PartialEq,
|
||||
fmt,
|
||||
@ -81,7 +78,7 @@ fn rugged_ser_enum_map<
|
||||
) -> Result<S::Ok, S::Error> {
|
||||
ser.collect_map(
|
||||
map.iter()
|
||||
.filter(|(k, v)| v != &&V::from(DEFAULT))
|
||||
.filter(|(_, v)| v != &&V::from(DEFAULT))
|
||||
.map(|(k, v)| (k, v)),
|
||||
)
|
||||
}
|
||||
@ -93,7 +90,7 @@ fn rugged_de_enum_map<
|
||||
D: de::Deserializer<'a>,
|
||||
const DEFAULT: i16,
|
||||
>(
|
||||
mut de: D,
|
||||
de: D,
|
||||
) -> Result<EnumMap<K, V>, D::Error> {
|
||||
struct Visitor<K, V, const DEFAULT: i16>(PhantomData<(K, V)>);
|
||||
|
||||
|
@ -18,7 +18,7 @@ pub struct Nature {
|
||||
impl Nature {
|
||||
pub fn generate(world: &World) -> Self {
|
||||
Self {
|
||||
chunks: Grid::populate_from(world.sim().get_size().map(|e| e as i32), |pos| Chunk {
|
||||
chunks: Grid::populate_from(world.sim().get_size().map(|e| e as i32), |_| Chunk {
|
||||
res: EnumMap::<_, f32>::default().map(|_, _| 1.0),
|
||||
}),
|
||||
}
|
||||
|
@ -1,25 +1,18 @@
|
||||
use crate::ai::{Action, NpcCtx};
|
||||
use crate::ai::Action;
|
||||
pub use common::rtsim::{NpcId, Profession};
|
||||
use common::{
|
||||
comp,
|
||||
grid::Grid,
|
||||
rtsim::{FactionId, RtSimController, SiteId, VehicleId},
|
||||
rtsim::{FactionId, SiteId, VehicleId},
|
||||
store::Id,
|
||||
uid::Uid,
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use rand::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slotmap::HopSlotMap;
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
ops::{Deref, DerefMut, Generator, GeneratorState},
|
||||
pin::Pin,
|
||||
sync::{
|
||||
atomic::{AtomicPtr, Ordering},
|
||||
Arc,
|
||||
},
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
use vek::*;
|
||||
use world::{
|
||||
|
@ -2,7 +2,6 @@ pub use common::rtsim::SiteId;
|
||||
use common::{
|
||||
rtsim::{FactionId, NpcId},
|
||||
store::Id,
|
||||
uid::Uid,
|
||||
};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,10 +1,9 @@
|
||||
use crate::data::Faction;
|
||||
use rand::prelude::*;
|
||||
use vek::*;
|
||||
use world::{IndexRef, World};
|
||||
|
||||
impl Faction {
|
||||
pub fn generate(world: &World, index: IndexRef, rng: &mut impl Rng) -> Self {
|
||||
pub fn generate(_world: &World, _index: IndexRef, rng: &mut impl Rng) -> Self {
|
||||
Self {
|
||||
leader: None,
|
||||
good_or_evil: rng.gen(),
|
||||
|
@ -3,7 +3,7 @@ pub mod site;
|
||||
|
||||
use crate::data::{
|
||||
faction::{Faction, Factions},
|
||||
npc::{Npc, Npcs, Profession, Vehicle, VehicleKind},
|
||||
npc::{Npc, Npcs, Profession, Vehicle},
|
||||
site::{Site, Sites},
|
||||
Data, Nature,
|
||||
};
|
||||
@ -15,7 +15,6 @@ use common::{
|
||||
terrain::TerrainChunkSize,
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use rand::prelude::*;
|
||||
use tracing::info;
|
||||
use vek::*;
|
||||
|
@ -10,7 +10,7 @@ use world::{
|
||||
impl Site {
|
||||
pub fn generate(
|
||||
world_site_id: Id<WorldSite>,
|
||||
world: &World,
|
||||
_world: &World,
|
||||
index: IndexRef,
|
||||
nearby_factions: &[(Vec2<i32>, FactionId)],
|
||||
factions: &Factions,
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![feature(
|
||||
generic_associated_types,
|
||||
never_type,
|
||||
try_blocks,
|
||||
generator_trait,
|
||||
@ -91,7 +90,7 @@ impl RtState {
|
||||
|
||||
pub fn bind<R: Rule, E: Event>(
|
||||
&mut self,
|
||||
mut f: impl FnMut(EventCtx<R, E>) + Send + Sync + 'static,
|
||||
f: impl FnMut(EventCtx<R, E>) + Send + Sync + 'static,
|
||||
) {
|
||||
let f = AtomicRefCell::new(f);
|
||||
self.event_handlers
|
||||
|
@ -1,13 +1,13 @@
|
||||
use std::{collections::VecDeque, hash::BuildHasherDefault};
|
||||
use std::hash::BuildHasherDefault;
|
||||
|
||||
use crate::{
|
||||
ai::{casual, choose, finish, important, just, now, seq, until, urgent, watch, Action, NpcCtx},
|
||||
ai::{casual, choose, finish, important, just, now, seq, until, urgent, Action, NpcCtx},
|
||||
data::{
|
||||
npc::{Brain, Controller, Npc, NpcId, PathData, PathingMemory, VehicleKind},
|
||||
npc::{Brain, Controller, PathData},
|
||||
Sites,
|
||||
},
|
||||
event::OnTick,
|
||||
EventCtx, RtState, Rule, RuleError,
|
||||
RtState, Rule, RuleError,
|
||||
};
|
||||
use common::{
|
||||
astar::{Astar, PathResult},
|
||||
@ -22,11 +22,6 @@ use fxhash::FxHasher64;
|
||||
use itertools::Itertools;
|
||||
use rand::prelude::*;
|
||||
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
marker::PhantomData,
|
||||
ops::ControlFlow,
|
||||
};
|
||||
use vek::*;
|
||||
use world::{
|
||||
civ::{self, Track},
|
||||
@ -212,11 +207,9 @@ fn path_towns(
|
||||
}
|
||||
}
|
||||
|
||||
const MAX_STEP: f32 = 32.0;
|
||||
|
||||
impl Rule for NpcAi {
|
||||
fn start(rtstate: &mut RtState) -> Result<Self, RuleError> {
|
||||
rtstate.bind::<Self, OnTick>(|mut ctx| {
|
||||
rtstate.bind::<Self, OnTick>(|ctx| {
|
||||
let mut npc_data = {
|
||||
let mut data = ctx.state.data_mut();
|
||||
data.npcs
|
||||
@ -351,8 +344,6 @@ fn goto(wpos: Vec3<f32>, speed_factor: f32, goal_dist: f32) -> impl Action {
|
||||
/// Try to walk toward a 2D position on the terrain without caring for
|
||||
/// obstacles.
|
||||
fn goto_2d(wpos2d: Vec2<f32>, speed_factor: f32, goal_dist: f32) -> impl Action {
|
||||
const MIN_DIST: f32 = 2.0;
|
||||
|
||||
now(move |ctx| {
|
||||
let wpos = wpos2d.with_z(ctx.world.sim().get_alt_approx(wpos2d.as_()).unwrap_or(0.0));
|
||||
goto(wpos, speed_factor, goal_dist)
|
||||
@ -421,7 +412,6 @@ fn travel_to_site(tgt_site: SiteId) -> impl Action {
|
||||
if let Some(current_site) = ctx.npc.current_site
|
||||
&& let Some(tracks) = path_towns(current_site, tgt_site, sites, ctx.world)
|
||||
{
|
||||
let track_count = tracks.path.len();
|
||||
|
||||
let mut nodes = tracks.path
|
||||
.into_iter()
|
||||
@ -625,6 +615,7 @@ fn villager(visiting_site: SiteId) -> impl Action {
|
||||
.debug(move || format!("villager at site {:?}", visiting_site))
|
||||
}
|
||||
|
||||
/*
|
||||
fn follow(npc: NpcId, distance: f32) -> impl Action {
|
||||
const STEP_DIST: f32 = 1.0;
|
||||
now(move |ctx| {
|
||||
@ -643,6 +634,7 @@ fn follow(npc: NpcId, distance: f32) -> impl Action {
|
||||
.debug(move || format!("Following npc({npc:?})"))
|
||||
.map(|_| {})
|
||||
}
|
||||
*/
|
||||
|
||||
fn chunk_path(
|
||||
from: Vec2<i32>,
|
||||
@ -794,7 +786,7 @@ fn bird_large() -> impl Action {
|
||||
if let Some(home) = ctx.npc.home {
|
||||
let is_home = ctx.npc.current_site.map_or(false, |site| home == site);
|
||||
if is_home {
|
||||
if let Some((id, site)) = data
|
||||
if let Some((_, site)) = data
|
||||
.sites
|
||||
.iter()
|
||||
.filter(|(id, site)| {
|
||||
|
@ -1,8 +1,5 @@
|
||||
use crate::{event::OnTick, RtState, Rule, RuleError};
|
||||
use common::{terrain::TerrainChunkSize, vol::RectVolSize};
|
||||
use rand::prelude::*;
|
||||
use tracing::info;
|
||||
use vek::*;
|
||||
|
||||
pub struct ReplenishResources;
|
||||
|
||||
|
@ -113,7 +113,9 @@ impl Rule for SimulateNpcs {
|
||||
Npc::new(
|
||||
rng.gen(),
|
||||
rand_wpos(&mut rng),
|
||||
Body::BirdLarge(comp::body::bird_large::Body::random_with(&mut rng, species)),
|
||||
Body::BirdLarge(comp::body::bird_large::Body::random_with(
|
||||
&mut rng, species,
|
||||
)),
|
||||
)
|
||||
.with_home(site_id),
|
||||
);
|
||||
|
@ -2003,13 +2003,10 @@ fn handle_kill_npcs(
|
||||
.get(entity)
|
||||
.copied()
|
||||
{
|
||||
ecs
|
||||
.write_resource::<crate::rtsim2::RtSim>()
|
||||
ecs.write_resource::<crate::rtsim2::RtSim>()
|
||||
.hook_rtsim_entity_delete(
|
||||
&ecs.read_resource::<Arc<world::World>>(),
|
||||
ecs
|
||||
.read_resource::<world::IndexOwned>()
|
||||
.as_index_ref(),
|
||||
ecs.read_resource::<world::IndexOwned>().as_index_ref(),
|
||||
rtsim_entity,
|
||||
);
|
||||
}
|
||||
|
@ -13,13 +13,12 @@ use common::{
|
||||
},
|
||||
event::{EventBus, ServerEvent},
|
||||
path::TraversalConfig,
|
||||
rtsim::RtSimEvent,
|
||||
};
|
||||
use common_base::prof_span;
|
||||
use common_ecs::{Job, Origin, ParMode, Phase, System};
|
||||
use rand::thread_rng;
|
||||
use rayon::iter::ParallelIterator;
|
||||
use specs::{saveload::MarkerAllocator, Join, ParJoin, Read, WriteExpect, WriteStorage};
|
||||
use specs::{saveload::MarkerAllocator, Join, ParJoin, Read, WriteStorage};
|
||||
|
||||
/// This system will allow NPCs to modify their controller
|
||||
#[derive(Default)]
|
||||
|
Loading…
Reference in New Issue
Block a user