mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix tethering
This commit is contained in:
parent
51c67d7394
commit
5a3e6316a5
@ -91,4 +91,8 @@ command-unimplemented-teleporter-spawn = Teleporter spawning is not implemented
|
|||||||
command-kit-inventory-unavailable = Could not get inventory
|
command-kit-inventory-unavailable = Could not get inventory
|
||||||
command-inventory-cant-fit-item = Can't fit item to inventory
|
command-inventory-cant-fit-item = Can't fit item to inventory
|
||||||
# Emitted by /disconnect_all when you dont exist (?)
|
# Emitted by /disconnect_all when you dont exist (?)
|
||||||
command-you-dont-exist = You do not exist, so you cannot use this command
|
command-you-dont-exist = You do not exist, so you cannot use this command
|
||||||
|
command-destroyed-tethers = All tethers destroyed! You are now free
|
||||||
|
command-destroyed-no-tethers = You're not connected to any tethers
|
||||||
|
command-dismounted = Dismounted
|
||||||
|
command-no-dismount = You're not riding or being ridden
|
@ -279,6 +279,14 @@ pub struct VolumeRiders {
|
|||||||
riders: HashSet<Vec3<i32>>,
|
riders: HashSet<Vec3<i32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VolumeRiders {
|
||||||
|
pub fn clear(&mut self) -> bool {
|
||||||
|
let res = !self.riders.is_empty();
|
||||||
|
self.riders.clear();
|
||||||
|
res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Component for VolumeRiders {
|
impl Component for VolumeRiders {
|
||||||
type Storage = DenseVecStorage<Self>;
|
type Storage = DenseVecStorage<Self>;
|
||||||
}
|
}
|
||||||
|
@ -4581,22 +4581,36 @@ fn handle_tether(
|
|||||||
|
|
||||||
fn handle_destroy_tethers(
|
fn handle_destroy_tethers(
|
||||||
server: &mut Server,
|
server: &mut Server,
|
||||||
_client: EcsEntity,
|
client: EcsEntity,
|
||||||
target: EcsEntity,
|
target: EcsEntity,
|
||||||
_args: Vec<String>,
|
_args: Vec<String>,
|
||||||
_action: &ServerChatCommand,
|
_action: &ServerChatCommand,
|
||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
server
|
let mut destroyed = false;
|
||||||
|
destroyed |= server
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<Is<common::tether::Leader>>()
|
.write_storage::<Is<common::tether::Leader>>()
|
||||||
.remove(target);
|
.remove(target)
|
||||||
server
|
.is_some();
|
||||||
|
destroyed |= server
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<Is<common::tether::Follower>>()
|
.write_storage::<Is<common::tether::Follower>>()
|
||||||
.remove(target);
|
.remove(target)
|
||||||
Ok(())
|
.is_some();
|
||||||
|
if destroyed {
|
||||||
|
server.notify_client(
|
||||||
|
client,
|
||||||
|
ServerGeneral::server_msg(
|
||||||
|
ChatType::CommandInfo,
|
||||||
|
Content::localized("command-destroyed-tethers"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(Content::localized("command-destroyed-no-tethers"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_mount(
|
fn handle_mount(
|
||||||
@ -4616,7 +4630,7 @@ fn handle_mount(
|
|||||||
server
|
server
|
||||||
.state
|
.state
|
||||||
.link(common::mounting::Mounting { mount, rider })
|
.link(common::mounting::Mounting { mount, rider })
|
||||||
.map_err(|_| "Failed to tether entities".into())
|
.map_err(|_| "Failed to mount entities".into())
|
||||||
} else {
|
} else {
|
||||||
Err("Mount and/or rider doesn't have an Uid component.".into())
|
Err("Mount and/or rider doesn't have an Uid component.".into())
|
||||||
}
|
}
|
||||||
@ -4627,30 +4641,47 @@ fn handle_mount(
|
|||||||
|
|
||||||
fn handle_dismount(
|
fn handle_dismount(
|
||||||
server: &mut Server,
|
server: &mut Server,
|
||||||
_client: EcsEntity,
|
client: EcsEntity,
|
||||||
target: EcsEntity,
|
target: EcsEntity,
|
||||||
_args: Vec<String>,
|
_args: Vec<String>,
|
||||||
_action: &ServerChatCommand,
|
_action: &ServerChatCommand,
|
||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
server
|
let mut destroyed = false;
|
||||||
|
destroyed |= server
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<Is<common::mounting::Rider>>()
|
.write_storage::<Is<common::mounting::Rider>>()
|
||||||
.remove(target);
|
.remove(target)
|
||||||
server
|
.is_some();
|
||||||
|
destroyed |= server
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<Is<common::mounting::VolumeRider>>()
|
.write_storage::<Is<common::mounting::VolumeRider>>()
|
||||||
.remove(target);
|
.remove(target)
|
||||||
server
|
.is_some();
|
||||||
|
destroyed |= server
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<Is<common::mounting::Mount>>()
|
.write_storage::<Is<common::mounting::Mount>>()
|
||||||
.remove(target);
|
.remove(target)
|
||||||
server
|
.is_some();
|
||||||
|
destroyed |= server
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.write_storage::<common::mounting::VolumeRiders>()
|
.write_storage::<common::mounting::VolumeRiders>()
|
||||||
.remove(target);
|
.get_mut(target)
|
||||||
Ok(())
|
.map_or(false, |volume_riders| volume_riders.clear());
|
||||||
|
|
||||||
|
if destroyed {
|
||||||
|
server.notify_client(
|
||||||
|
client,
|
||||||
|
ServerGeneral::server_msg(
|
||||||
|
ChatType::CommandInfo,
|
||||||
|
Content::localized("command-dismounted"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(Content::localized("command-no-dismount"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ use common::{
|
|||||||
resources::{Secs, Time, TimeOfDay},
|
resources::{Secs, Time, TimeOfDay},
|
||||||
rtsim::{Actor, RtSimEntity},
|
rtsim::{Actor, RtSimEntity},
|
||||||
slowjob::SlowJobPool,
|
slowjob::SlowJobPool,
|
||||||
|
tether::Tethered,
|
||||||
uid::{IdMaps, Uid},
|
uid::{IdMaps, Uid},
|
||||||
util::Dir,
|
util::Dir,
|
||||||
LoadoutBuilder, ViewDistances,
|
LoadoutBuilder, ViewDistances,
|
||||||
@ -1164,6 +1165,7 @@ impl StateExt for State {
|
|||||||
|
|
||||||
maintain_link::<Mounting>(self);
|
maintain_link::<Mounting>(self);
|
||||||
maintain_link::<VolumeMounting>(self);
|
maintain_link::<VolumeMounting>(self);
|
||||||
|
maintain_link::<Tethered>(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_entity_recorded(
|
fn delete_entity_recorded(
|
||||||
|
@ -216,7 +216,8 @@ pub fn run_command(
|
|||||||
.ok_or("No player entity")?,
|
.ok_or("No player entity")?,
|
||||||
ident => {
|
ident => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Expected target/selected/viewpoint/mount/rider found {ident}"
|
"Expected target/selected/viewpoint/mount/rider/self after '@' found \
|
||||||
|
{ident}"
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user