feat: stabilize OpenSim interactions and landmarks
This commit is contained in:
@@ -1012,7 +1012,7 @@ fn communication_commands() -> [CommandEntry; 6] {
|
||||
),
|
||||
(
|
||||
"im",
|
||||
"Instant message someone. Usage: im [firstname] [lastname] [message]",
|
||||
"Instant message someone. Usage: im [firstname] [lastname] [message] | im [avatar-uuid] [message]",
|
||||
CommandCategory::Communication,
|
||||
CommandHandler::Im,
|
||||
),
|
||||
@@ -1878,15 +1878,28 @@ async fn execute_communication_command(
|
||||
}
|
||||
}
|
||||
CommandHandler::Im => {
|
||||
if args.len() < 3 {
|
||||
return "Usage: im [firstname] [lastname] [message]".into();
|
||||
if args.is_empty() {
|
||||
return "Usage: im [firstname] [lastname] [message] | im [avatar-uuid] [message]"
|
||||
.into();
|
||||
}
|
||||
let name = format!("{} {}", args[0], args[1]);
|
||||
let message = bounded_message(&args[2..].join(" "));
|
||||
let target = match client.backend.resolve_avatar(&name, cancellation).await {
|
||||
Ok(Some(target)) => target,
|
||||
Ok(None) => return format!("Name lookup for {name} failed"),
|
||||
Err(error) => return format!("Name lookup for {name} failed: {error}"),
|
||||
let (target, message) = if let Ok(target) = UUID::new_with_string(args[0].clone()) {
|
||||
if args.len() < 2 {
|
||||
return "Usage: im [firstname] [lastname] [message] | im [avatar-uuid] [message]"
|
||||
.into();
|
||||
}
|
||||
(target, bounded_message(&args[1..].join(" ")))
|
||||
} else {
|
||||
if args.len() < 3 {
|
||||
return "Usage: im [firstname] [lastname] [message] | im [avatar-uuid] [message]"
|
||||
.into();
|
||||
}
|
||||
let name = format!("{} {}", args[0], args[1]);
|
||||
let target = match client.backend.resolve_avatar(&name, cancellation).await {
|
||||
Ok(Some(target)) => target,
|
||||
Ok(None) => return format!("Name lookup for {name} failed"),
|
||||
Err(error) => return format!("Name lookup for {name} failed: {error}"),
|
||||
};
|
||||
(target, bounded_message(&args[2..].join(" ")))
|
||||
};
|
||||
match client.backend.instant_message(target, &message) {
|
||||
Ok(()) => format!("Instant Messaged {target} with message: {message}"),
|
||||
|
||||
@@ -452,6 +452,7 @@ enum Movement {
|
||||
Follow(Option<(UUID, Vector3)>),
|
||||
GoHome,
|
||||
TeleportRegion(String, Vector3),
|
||||
TeleportRegionHandle(u64, Vector3),
|
||||
TeleportLandmark(UUID),
|
||||
Jump,
|
||||
AutoPilot { local: Vector3, global: [f64; 3] },
|
||||
@@ -904,11 +905,12 @@ async fn goto<B: Backend + ?Sized>(
|
||||
.collect::<Vec<_>>(),
|
||||
"Usage: goto sim/x/y/z --confirm",
|
||||
)?;
|
||||
let movement = parts[0].parse::<u64>().map_or_else(
|
||||
|_| Movement::TeleportRegion(parts[0].into(), position),
|
||||
|handle| Movement::TeleportRegionHandle(handle, position),
|
||||
);
|
||||
backend
|
||||
.world_mutate(
|
||||
Mutation::Movement(Movement::TeleportRegion(parts[0].into(), position)),
|
||||
cancellation,
|
||||
)
|
||||
.world_mutate(Mutation::Movement(movement), cancellation)
|
||||
.await?;
|
||||
Ok(format!("Teleported to {}", parts[0]))
|
||||
}
|
||||
@@ -2210,6 +2212,12 @@ fn apply_fake_movement(
|
||||
backend.record(format!("CALL teleport-region {name} {position:?}"));
|
||||
"Teleport complete".into()
|
||||
}
|
||||
Movement::TeleportRegionHandle(handle, position) => {
|
||||
state.fake.region_handle = handle;
|
||||
state.fake.position = position;
|
||||
backend.record(format!("CALL teleport-region-handle {handle} {position:?}"));
|
||||
"Teleport complete".into()
|
||||
}
|
||||
Movement::TeleportLandmark(id) => {
|
||||
backend.record(format!("CALL teleport-landmark {id}"));
|
||||
"Teleport complete".into()
|
||||
@@ -3188,6 +3196,22 @@ async fn live_movement(
|
||||
Err(format!("Teleport failed: {}", agent.teleport_message()))
|
||||
}
|
||||
}
|
||||
Movement::TeleportRegionHandle(handle, position) => {
|
||||
let agent = live_agent(backend)?;
|
||||
let success = agent
|
||||
.teleport_with_u_int64_vector3_cancellation_token(
|
||||
handle,
|
||||
position,
|
||||
Some(cancellation),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| "Teleport failed")?;
|
||||
if success {
|
||||
Ok("Teleport complete".into())
|
||||
} else {
|
||||
Err(format!("Teleport failed: {}", agent.teleport_message()))
|
||||
}
|
||||
}
|
||||
Movement::TeleportLandmark(id) => {
|
||||
let agent = live_agent(backend)?;
|
||||
if agent
|
||||
|
||||
Reference in New Issue
Block a user