mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Allow spawned airships to move
This commit is contained in:
parent
fe4c7a3f6a
commit
a70e569396
BIN
assets/voxygen/voxel/object/Human_Airship.vox
(Stored with Git LFS)
BIN
assets/voxygen/voxel/object/Human_Airship.vox
(Stored with Git LFS)
Binary file not shown.
BIN
assets/voxygen/voxel/object/airship.vox
(Stored with Git LFS)
BIN
assets/voxygen/voxel/object/airship.vox
(Stored with Git LFS)
Binary file not shown.
BIN
assets/voxygen/voxel/object/propeller-l.vox
(Stored with Git LFS)
BIN
assets/voxygen/voxel/object/propeller-l.vox
(Stored with Git LFS)
Binary file not shown.
BIN
assets/voxygen/voxel/object/propeller-r.vox
(Stored with Git LFS)
BIN
assets/voxygen/voxel/object/propeller-r.vox
(Stored with Git LFS)
Binary file not shown.
@ -224,7 +224,7 @@ impl ChatCommand {
|
||||
"Temporarily gives a player admin permissions or removes them",
|
||||
Admin,
|
||||
),
|
||||
ChatCommand::Airship => cmd(vec![], "Spawns an airship", Admin),
|
||||
ChatCommand::Airship => cmd(vec![Boolean("moving", "true".to_string(), Optional)], "Spawns an airship", Admin),
|
||||
ChatCommand::Alias => cmd(vec![Any("name", Required)], "Change your alias", NoAdmin),
|
||||
ChatCommand::Ban => cmd(
|
||||
vec![Any("username", Required), Message(Optional)],
|
||||
|
@ -205,6 +205,15 @@ impl Agent {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_destination() -> Self {
|
||||
Self {
|
||||
can_speak: false,
|
||||
psyche: Psyche { aggro: 1.0 },
|
||||
rtsim_controller: RtSimController::zero(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
patrol_origin: Option<Vec3<f32>>,
|
||||
can_speak: bool,
|
||||
|
@ -46,4 +46,10 @@ impl Default for RtSimController {
|
||||
|
||||
impl RtSimController {
|
||||
pub fn reset(&mut self) { *self = Self::default(); }
|
||||
pub fn zero() -> Self {
|
||||
Self {
|
||||
travel_to: Some((Vec3::new(0.0, 0.0, 500.0), "".to_string())),
|
||||
speed_factor: 0.05,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -962,15 +962,16 @@ fn handle_spawn_airship(
|
||||
server: &mut Server,
|
||||
client: EcsEntity,
|
||||
target: EcsEntity,
|
||||
_args: String,
|
||||
_action: &ChatCommand,
|
||||
args: String,
|
||||
action: &ChatCommand,
|
||||
) {
|
||||
let moving = scan_fmt_some!(&args, &action.arg_fmt(), String).unwrap_or_else(|| "false".to_string()) == "true";
|
||||
match server.state.read_component_copied::<comp::Pos>(target) {
|
||||
Some(mut pos) => {
|
||||
pos.0.z += 50.0;
|
||||
server
|
||||
.state
|
||||
.create_ship(pos, comp::ship::Body::DefaultAirship, 1)
|
||||
.create_ship(pos, comp::ship::Body::DefaultAirship, 1, moving)
|
||||
.with(comp::Scale(11.0 / 0.8))
|
||||
.with(LightEmitter {
|
||||
col: Rgb::new(1.0, 0.65, 0.2),
|
||||
|
@ -28,6 +28,9 @@ impl Entity {
|
||||
pub fn get_body(&self) -> comp::Body {
|
||||
match self.rng(PERM_GENUS).gen::<f32>() {
|
||||
//we want 50% birds, 50% humans for now
|
||||
x if x < 0.05 => {
|
||||
comp::Body::Ship(comp::ship::Body::DefaultAirship)
|
||||
},
|
||||
x if x < 0.50 => {
|
||||
let species = *(&comp::bird_medium::ALL_SPECIES)
|
||||
.choose(&mut self.rng(PERM_SPECIES))
|
||||
@ -53,6 +56,7 @@ impl Entity {
|
||||
comp::Body::BirdSmall(_) => "Warbler".to_string(),
|
||||
comp::Body::Dragon(b) => get_npc_name(&npc_names.dragon, b.species).to_string(),
|
||||
comp::Body::Humanoid(b) => get_npc_name(&npc_names.humanoid, b.species).to_string(),
|
||||
comp::Body::Ship(_) => "Veloren Air".to_string(),
|
||||
//TODO: finish match as necessary
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
@ -131,6 +135,7 @@ impl Entity {
|
||||
.iter()
|
||||
.filter(|s| match self.get_body() {
|
||||
comp::Body::Humanoid(_) => s.1.is_settlement() | s.1.is_castle(),
|
||||
comp::Body::Ship(_) => s.1.is_castle(),
|
||||
_ => s.1.is_dungeon(),
|
||||
})
|
||||
.filter(|_| thread_rng().gen_range(0i32..4) == 0)
|
||||
|
@ -41,7 +41,7 @@ pub trait StateExt {
|
||||
) -> EcsEntityBuilder;
|
||||
/// Build a static object entity
|
||||
fn create_object(&mut self, pos: comp::Pos, object: comp::object::Body) -> EcsEntityBuilder;
|
||||
fn create_ship(&mut self, pos: comp::Pos, object: comp::ship::Body, level: u16) -> EcsEntityBuilder;
|
||||
fn create_ship(&mut self, pos: comp::Pos, ship: comp::ship::Body, level: u16, moving: bool) -> EcsEntityBuilder;
|
||||
/// Build a projectile
|
||||
fn create_projectile(
|
||||
&mut self,
|
||||
@ -203,24 +203,45 @@ impl StateExt for State {
|
||||
.with(comp::Gravity(1.0))
|
||||
}
|
||||
|
||||
fn create_ship(&mut self, pos: comp::Pos, ship: comp::ship::Body, level: u16) -> EcsEntityBuilder {
|
||||
self.ecs_mut()
|
||||
.create_entity_synced()
|
||||
.with(pos)
|
||||
.with(comp::Vel(Vec3::zero()))
|
||||
.with(comp::Ori::default())
|
||||
.with(comp::Mass(50.0))
|
||||
.with(comp::Collider::Voxel { id: ship.manifest_entry().to_string() })
|
||||
.with(comp::Body::Ship(ship))
|
||||
.with(comp::Gravity(1.0))
|
||||
.with(comp::Controller::default())
|
||||
.with(comp::inventory::Inventory::new_empty())
|
||||
.with(comp::CharacterState::default())
|
||||
.with(comp::Energy::new(ship.into(), level))
|
||||
.with(comp::Health::new(ship.into(), level))
|
||||
.with(comp::Stats::new("Airship".to_string()))
|
||||
.with(comp::Buffs::default())
|
||||
.with(comp::Combo::default())
|
||||
fn create_ship(&mut self, pos: comp::Pos, ship: comp::ship::Body, level: u16, moving: bool) -> EcsEntityBuilder {
|
||||
if moving {
|
||||
self.ecs_mut()
|
||||
.create_entity_synced()
|
||||
.with(pos)
|
||||
.with(comp::Vel(Vec3::zero()))
|
||||
.with(comp::Ori::default())
|
||||
.with(comp::Mass(50.0))
|
||||
.with(comp::Collider::Voxel { id: ship.manifest_entry().to_string() })
|
||||
.with(comp::Body::Ship(ship))
|
||||
.with(comp::Gravity(1.0))
|
||||
.with(comp::Controller::default())
|
||||
.with(comp::inventory::Inventory::new_empty())
|
||||
.with(comp::CharacterState::default())
|
||||
.with(comp::Energy::new(ship.into(), level))
|
||||
.with(comp::Health::new(ship.into(), level))
|
||||
.with(comp::Stats::new("Airship".to_string()))
|
||||
.with(comp::Buffs::default())
|
||||
.with(comp::Combo::default())
|
||||
.with(comp::Agent::with_destination())
|
||||
} else {
|
||||
self.ecs_mut()
|
||||
.create_entity_synced()
|
||||
.with(pos)
|
||||
.with(comp::Vel(Vec3::zero()))
|
||||
.with(comp::Ori::default())
|
||||
.with(comp::Mass(50.0))
|
||||
.with(comp::Collider::Voxel { id: ship.manifest_entry().to_string() })
|
||||
.with(comp::Body::Ship(ship))
|
||||
.with(comp::Gravity(1.0))
|
||||
.with(comp::Controller::default())
|
||||
.with(comp::inventory::Inventory::new_empty())
|
||||
.with(comp::CharacterState::default())
|
||||
.with(comp::Energy::new(ship.into(), level))
|
||||
.with(comp::Health::new(ship.into(), level))
|
||||
.with(comp::Stats::new("Airship".to_string()))
|
||||
.with(comp::Buffs::default())
|
||||
.with(comp::Combo::default())
|
||||
}
|
||||
}
|
||||
|
||||
fn create_projectile(
|
||||
|
@ -596,7 +596,7 @@ impl<'a> AgentData<'a> {
|
||||
.ray(
|
||||
self.pos.0 + Vec3::unit_z(),
|
||||
self.pos.0
|
||||
+ bearing.try_normalized().unwrap_or_else(Vec3::unit_y) * 60.0
|
||||
+ bearing.try_normalized().unwrap_or_else(Vec3::unit_y) * 80.0
|
||||
+ Vec3::unit_z(),
|
||||
)
|
||||
.until(Block::is_solid)
|
||||
|
Loading…
Reference in New Issue
Block a user