Ship production navigation authoring workflow

This commit is contained in:
Rbanh committed 2026-07-12 02:53:43 -04:00
1 parent 0798aa5d57
commit b4aa61e394
35 files changed
+3898 -602

No files matched your search

+52 -8
View File
@@ -9,9 +9,9 @@ use egui_phosphor_icons::{icons, Icon};
use shared::{
authoring_component_active,
brush_math::{validate_brush, BrushDiagnosticSeverity},
infer_actor_kind, ActorKind, AnimationControllerDesc, AudioListenerDesc, AudioSourceDesc,
AuthoringComponentStates, AuthoringLightKind, AuthoringRigidBody, BrushDesc, BrushKind,
ColliderDesc, ColliderShapeDesc, ColorDesc, ComponentInstanceId, EditorAssetRef,
infer_actor_kind, ActorId, ActorKind, AnimationControllerDesc, AudioListenerDesc,
AudioSourceDesc, AuthoringComponentStates, AuthoringLightKind, AuthoringRigidBody, BrushDesc,
BrushKind, ColliderDesc, ColliderShapeDesc, ColorDesc, ComponentInstanceId, EditorAssetRef,
InspectorOrder, LevelObject, LightDesc, MaterialDesc, MaterialParameter,
MaterialParameterValue, MaterialRef, MaterialShaderKind, NavigationArea, NavigationBounds,
NavigationLink, NavigationObstacle, ObjectiveMarker, PhysicsBody, PlayerSpawn,
@@ -690,9 +690,13 @@ fn paste_component(world: &mut World, entity: Entity, type_name: &str) {
Some(CopiedComponent::PrefabInstance(value)) if type_name == COMPONENT_PREFAB_INSTANCE => {
insert_direct_component(world, entity, value);
}
Some(CopiedComponent::NavigationBounds(value))
Some(CopiedComponent::NavigationBounds(mut value))
if type_name == COMPONENT_NAVIGATION_BOUNDS =>
{
value.artifact_path = world
.get::<NavigationBounds>(entity)
.map(|bounds| bounds.artifact_path.clone())
.unwrap_or_else(|| navigation_bounds_for_entity(world, entity).artifact_path);
crate::history::set_navigation_with_history(
world,
entity,
@@ -760,6 +764,19 @@ fn reset_component(world: &mut World, entity: Entity, type_name: &str) {
Ok(())
},
);
} else if type_path == COMPONENT_NAVIGATION_BOUNDS {
let bounds = reset_navigation_bounds_for_entity(world, entity);
let _ = crate::history::reflected_component_transaction(
world,
entity,
"Reset Component",
component_id,
type_path,
move |world, entity| {
world.entity_mut(entity).insert(bounds);
Ok(())
},
);
} else {
let _ = crate::history::reflected_component_transaction(
world,
@@ -809,7 +826,7 @@ fn reset_component(world: &mut World, entity: Entity, type_name: &str) {
world,
entity,
crate::history::NavigationComponentState {
bounds: Some(NavigationBounds::default()),
bounds: Some(reset_navigation_bounds_for_entity(world, entity)),
..Default::default()
},
),
@@ -1609,6 +1626,19 @@ fn insert_registered_component(world: &mut World, entity: Entity, type_name: &st
Ok(())
},
);
} else if descriptor.type_name == COMPONENT_NAVIGATION_BOUNDS {
let bounds = navigation_bounds_for_entity(world, entity);
let _ = crate::history::reflected_component_transaction(
world,
entity,
"Add Component",
descriptor.id,
descriptor.type_name,
move |world, entity| {
world.entity_mut(entity).insert(bounds);
Ok(())
},
);
} else {
let _ = crate::history::reflected_component_transaction(
world,
@@ -1689,9 +1719,8 @@ fn insert_registered_component(world: &mut World, entity: Entity, type_name: &st
});
}),
COMPONENT_NAVIGATION_BOUNDS => insert_component(world, entity, |world, e| {
world
.entity_mut(e)
.insert((ActorKind::Navigation, NavigationBounds::default()));
let bounds = navigation_bounds_for_entity(world, e);
world.entity_mut(e).insert((ActorKind::Navigation, bounds));
}),
COMPONENT_NAVIGATION_OBSTACLE => insert_component(world, entity, |world, e| {
world
@@ -1717,6 +1746,21 @@ fn insert_registered_component(world: &mut World, entity: Entity, type_name: &st
}
}
fn navigation_bounds_for_entity(world: &World, entity: Entity) -> NavigationBounds {
world
.get::<ActorId>(entity)
.map(|actor_id| NavigationBounds::for_actor(&actor_id.0))
.unwrap_or_else(|| NavigationBounds::for_actor(&uuid::Uuid::new_v4().to_string()))
}
fn reset_navigation_bounds_for_entity(world: &World, entity: Entity) -> NavigationBounds {
let mut bounds = navigation_bounds_for_entity(world, entity);
if let Some(current) = world.get::<NavigationBounds>(entity) {
bounds.artifact_path.clone_from(&current.artifact_path);
}
bounds
}
fn insert_component(world: &mut World, entity: Entity, insert: impl FnOnce(&mut World, Entity)) {
let before = crate::history::snapshot_entity(world, entity);
let old_kind = before.as_ref().map(|s| s.actor_kind);
File diff suppressed because it is too large. Load diff