mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
place rtsim on sprite controllers
This commit is contained in:
parent
57551c479c
commit
b6c7316de9
@ -9,16 +9,18 @@ use common::{
|
|||||||
aura::{Aura, AuraKind, AuraTarget},
|
aura::{Aura, AuraKind, AuraTarget},
|
||||||
beam,
|
beam,
|
||||||
buff::{BuffCategory, BuffData, BuffKind, BuffSource},
|
buff::{BuffCategory, BuffData, BuffKind, BuffSource},
|
||||||
|
ship::figuredata::VOXEL_COLLIDER_MANIFEST,
|
||||||
shockwave, Alignment, BehaviorCapability, Body, ItemDrops, LightEmitter, Object, Ori, Pos,
|
shockwave, Alignment, BehaviorCapability, Body, ItemDrops, LightEmitter, Object, Ori, Pos,
|
||||||
Projectile, TradingBehavior, Vel, WaypointArea,
|
Projectile, TradingBehavior, Vel, WaypointArea,
|
||||||
},
|
},
|
||||||
event::{EventBus, NpcBuilder, UpdateCharacterMetadata},
|
event::{EventBus, NpcBuilder, UpdateCharacterMetadata},
|
||||||
mounting::Mounting,
|
mounting::{Mounting, Volume, VolumeMounting, VolumePos},
|
||||||
outcome::Outcome,
|
outcome::Outcome,
|
||||||
resources::{Secs, Time},
|
resources::{Secs, Time},
|
||||||
rtsim::RtSimVehicle,
|
rtsim::RtSimVehicle,
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
util::Dir,
|
util::Dir,
|
||||||
|
vol::IntoFullVolIterator,
|
||||||
ViewDistances,
|
ViewDistances,
|
||||||
};
|
};
|
||||||
use common_net::{msg::ServerGeneral, sync::WorldSyncExt};
|
use common_net::{msg::ServerGeneral, sync::WorldSyncExt};
|
||||||
@ -200,9 +202,29 @@ pub fn handle_create_ship(
|
|||||||
driver: Option<NpcBuilder>,
|
driver: Option<NpcBuilder>,
|
||||||
passengers: Vec<NpcBuilder>,
|
passengers: Vec<NpcBuilder>,
|
||||||
) {
|
) {
|
||||||
let mut entity = server
|
let collider = ship.make_collider();
|
||||||
.state
|
let voxel_colliders_manifest = VOXEL_COLLIDER_MANIFEST.read();
|
||||||
.create_ship(pos, ori, ship, |ship| ship.make_collider());
|
|
||||||
|
// TODO: find better solution for this.
|
||||||
|
let (mut steering, mut seats) = {
|
||||||
|
let mut steering = Vec::new();
|
||||||
|
let mut seats = Vec::new();
|
||||||
|
|
||||||
|
for (pos, block) in collider
|
||||||
|
.get_vol(&voxel_colliders_manifest)
|
||||||
|
.iter()
|
||||||
|
.flat_map(|voxel_collider| voxel_collider.volume().full_vol_iter())
|
||||||
|
{
|
||||||
|
match (block.is_controller(), block.is_mountable()) {
|
||||||
|
(true, true) => steering.push((pos, *block)),
|
||||||
|
(false, true) => seats.push((pos, *block)),
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(steering.into_iter(), seats.into_iter())
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut entity = server.state.create_ship(pos, ori, ship, |_| collider);
|
||||||
/*
|
/*
|
||||||
if let Some(mut agent) = agent {
|
if let Some(mut agent) = agent {
|
||||||
let (kp, ki, kd) = pid_coefficients(&Body::Ship(ship));
|
let (kp, ki, kd) = pid_coefficients(&Body::Ship(ship));
|
||||||
@ -221,10 +243,26 @@ pub fn handle_create_ship(
|
|||||||
let npc_entity = handle_create_npc(server, pos, driver);
|
let npc_entity = handle_create_npc(server, pos, driver);
|
||||||
|
|
||||||
let uids = server.state.ecs().read_storage::<Uid>();
|
let uids = server.state.ecs().read_storage::<Uid>();
|
||||||
if let (Some(rider_uid), Some(mount_uid)) =
|
let (rider_uid, mount_uid) = uids
|
||||||
(uids.get(npc_entity).copied(), uids.get(entity).copied())
|
.get(npc_entity)
|
||||||
{
|
.copied()
|
||||||
drop(uids);
|
.zip(uids.get(entity).copied())
|
||||||
|
.expect("Couldn't get Uid from newly created ship and npc");
|
||||||
|
drop(uids);
|
||||||
|
|
||||||
|
if let Some((steering_pos, steering_block)) = steering.next() {
|
||||||
|
server
|
||||||
|
.state
|
||||||
|
.link(VolumeMounting {
|
||||||
|
pos: VolumePos {
|
||||||
|
kind: Volume::Entity(mount_uid),
|
||||||
|
pos: steering_pos,
|
||||||
|
},
|
||||||
|
block: steering_block,
|
||||||
|
rider: rider_uid,
|
||||||
|
})
|
||||||
|
.expect("Failed to link driver to ship");
|
||||||
|
} else {
|
||||||
server
|
server
|
||||||
.state
|
.state
|
||||||
.link(Mounting {
|
.link(Mounting {
|
||||||
@ -232,13 +270,32 @@ pub fn handle_create_ship(
|
|||||||
rider: rider_uid,
|
rider: rider_uid,
|
||||||
})
|
})
|
||||||
.expect("Failed to link driver to ship");
|
.expect("Failed to link driver to ship");
|
||||||
} else {
|
|
||||||
panic!("Couldn't get Uid from newly created ship and npc");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for passenger in passengers {
|
for passenger in passengers {
|
||||||
handle_create_npc(server, Pos(pos.0 + Vec3::unit_z() * 5.0), passenger);
|
let npc_entity = handle_create_npc(server, Pos(pos.0 + Vec3::unit_z() * 5.0), passenger);
|
||||||
|
if let Some((rider_pos, rider_block)) = seats.next() {
|
||||||
|
let uids = server.state.ecs().read_storage::<Uid>();
|
||||||
|
let (rider_uid, mount_uid) = uids
|
||||||
|
.get(npc_entity)
|
||||||
|
.copied()
|
||||||
|
.zip(uids.get(entity).copied())
|
||||||
|
.expect("Couldn't get Uid from newly created ship and npc");
|
||||||
|
drop(uids);
|
||||||
|
|
||||||
|
server
|
||||||
|
.state
|
||||||
|
.link(VolumeMounting {
|
||||||
|
pos: VolumePos {
|
||||||
|
kind: Volume::Entity(mount_uid),
|
||||||
|
pos: rider_pos,
|
||||||
|
},
|
||||||
|
block: rider_block,
|
||||||
|
rider: rider_uid,
|
||||||
|
})
|
||||||
|
.expect("Failed to link passanger to ship");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user