Compare commits
8 commits
2e7a505179
...
16a2a0710a
Author | SHA1 | Date | |
---|---|---|---|
16a2a0710a | |||
a03d25c3c4 | |||
680abd15cb | |||
e2eb7e8722 | |||
adda066782 | |||
aa367514d6 | |||
e5fc772288 | |||
1087e66617 |
14 changed files with 46 additions and 50 deletions
|
@ -13,8 +13,8 @@ rayon = "1.10.0"
|
|||
chrono = { version = "0.4.35", features = ["serde"] }
|
||||
anyhow = { version = "1.0.86", features = ["backtrace"] }
|
||||
indexmap = { version = "2.2.6", features = ["rayon"] }
|
||||
shaderc = { version = "0.8.3", features = ["build-from-source"] }
|
||||
rusqlite = { version = "0.33.0", features = ["bundled"] }
|
||||
shaderc = { version = "0.9.0", features = ["build-from-source"] }
|
||||
rusqlite = { version = "0.34.0", features = ["bundled"] }
|
||||
cgmath = "0.18.0"
|
||||
http = "1.1.0"
|
||||
iterchunks = "0.5.0"
|
||||
|
|
|
@ -6,7 +6,6 @@ edition = "2024"
|
|||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
paste = { workspace = true }
|
||||
destructure_traitobject = { workspace = true }
|
||||
downcast-rs = { workspace = true }
|
||||
|
||||
engine = { workspace = true }
|
||||
|
|
|
@ -106,7 +106,7 @@ impl<A: Ability + 'static> AbilityPageRightSide<A> {
|
|||
menu.add_tooltip("active_ability", gui);
|
||||
}
|
||||
} else {
|
||||
menu.remove_tooltip("active_ability");
|
||||
menu.remove_tooltip(world, "active_ability")?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ impl<A: Ability + 'static> ContentUpdate for Content<A, AbilityAddon> {
|
|||
} else {
|
||||
let window = reference.upgrade().unwrap();
|
||||
|
||||
window.remove_tooltip(format!("addon_{index}"));
|
||||
window.remove_tooltip(world, format!("addon_{index}"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -275,8 +275,8 @@ impl<A: Ability + 'static> ContentUpdate for Content<A, AbilityBook<A>> {
|
|||
} else {
|
||||
let window = reference.upgrade().unwrap();
|
||||
|
||||
window.remove_tooltip(format!("book_{index}"));
|
||||
window.remove_tooltip("active_book");
|
||||
window.remove_tooltip(world, format!("book_{index}"))?;
|
||||
window.remove_tooltip(world, "active_book")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -217,8 +217,8 @@ impl<A: Ability + 'static> ContentUpdate for Content<A, Item> {
|
|||
} else {
|
||||
let window = reference.upgrade().unwrap();
|
||||
|
||||
window.remove_tooltip(format!("item_{index}"));
|
||||
window.remove_tooltip("equip");
|
||||
window.remove_tooltip(world, format!("item_{index}"))?;
|
||||
window.remove_tooltip(world, "equip")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -337,7 +337,7 @@ impl<A: Ability + 'static> ContentUpdate for Content<A, Jewel> {
|
|||
} else {
|
||||
let window = reference.upgrade().unwrap();
|
||||
|
||||
window.remove_tooltip(format!("jewel_{index}"));
|
||||
window.remove_tooltip(world, format!("jewel_{index}"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -211,11 +211,11 @@ mod macros {
|
|||
reference.upgrade().unwrap().add_tooltip("equip", gui);
|
||||
}
|
||||
None => {
|
||||
reference.upgrade().unwrap().remove_tooltip("equip");
|
||||
reference.upgrade().unwrap().remove_tooltip(world, "equip")?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reference.upgrade().unwrap().remove_tooltip("equip");
|
||||
reference.upgrade().unwrap().remove_tooltip(world, "equip")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -346,11 +346,11 @@ mod macros {
|
|||
reference.upgrade().unwrap().add_tooltip("equip", gui);
|
||||
}
|
||||
None => {
|
||||
reference.upgrade().unwrap().remove_tooltip("equip");
|
||||
reference.upgrade().unwrap().remove_tooltip(world, "equip")?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reference.upgrade().unwrap().remove_tooltip("equip");
|
||||
reference.upgrade().unwrap().remove_tooltip(world, "equip")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -120,7 +120,7 @@ impl JewelRightSide {
|
|||
menu.add_tooltip("upper", tooltip);
|
||||
}
|
||||
} else {
|
||||
menu.remove_tooltip("upper");
|
||||
menu.remove_tooltip(world, "upper")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -163,7 +163,7 @@ impl JewelRightSide {
|
|||
menu.add_tooltip(format!("lower_{index}",), tooltip);
|
||||
}
|
||||
} else {
|
||||
menu.remove_tooltip(format!("lower_{index}"));
|
||||
menu.remove_tooltip(world, format!("lower_{index}"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -234,8 +234,12 @@ impl CharacterWindow {
|
|||
.insert(name.to_string(), gui.into());
|
||||
}
|
||||
|
||||
pub fn remove_tooltip(&self, name: impl ToString) {
|
||||
self.tooltips.lock().unwrap().remove(&name.to_string());
|
||||
pub fn remove_tooltip(&self, world: &mut World, name: impl ToString) -> Result<()> {
|
||||
if let Some(tooltip) = self.tooltips.lock().unwrap().remove(&name.to_string()) {
|
||||
tooltip.disable(world)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn salvage_from_inventory<A, F, S>(world: &mut World, hero: Entity, f: F) -> Result<()>
|
||||
|
|
|
@ -7,7 +7,4 @@ edition = "2024"
|
|||
anyhow = { workspace = true }
|
||||
rusqlite = { workspace = true }
|
||||
assetpath = { workspace = true }
|
||||
destructure_traitobject = { workspace = true }
|
||||
|
||||
engine = { workspace = true }
|
||||
ecs = { workspace = true }
|
||||
|
|
|
@ -326,8 +326,8 @@ impl Map {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn disable_spawns(&self, world: &mut World) -> Result<()> {
|
||||
self.data.write().unwrap().disable_spawns(world)
|
||||
pub fn disable_spawns(&self, world: &mut World) {
|
||||
self.data.write().unwrap().disable_spawns(world);
|
||||
}
|
||||
|
||||
pub fn set_leave_location(
|
||||
|
@ -996,37 +996,35 @@ impl Map {
|
|||
Ok(self.data.read().unwrap().leave_markers())
|
||||
}
|
||||
|
||||
pub fn disable(&self, world: &mut World) -> Result<()> {
|
||||
pub fn disable(&self, world: &mut World) {
|
||||
let data = self.data.read().unwrap();
|
||||
|
||||
// clear tiles
|
||||
for chunk in data.chunk_handles.values() {
|
||||
world.remove_entity(*chunk)?;
|
||||
world.remove_entity(*chunk);
|
||||
}
|
||||
|
||||
// clear entities
|
||||
for entity in data.entities.values() {
|
||||
world.remove_entity(*entity)?;
|
||||
world.remove_entity(*entity);
|
||||
}
|
||||
|
||||
// clear spawns
|
||||
for (spawn, _) in data.spawn_locations.values() {
|
||||
world.remove_entity(*spawn)?;
|
||||
world.remove_entity(*spawn);
|
||||
}
|
||||
|
||||
// clear exits
|
||||
for leave in data.leave_locations.values() {
|
||||
world.remove_entity(*leave)?;
|
||||
world.remove_entity(*leave);
|
||||
}
|
||||
|
||||
// clear npc spawns
|
||||
for (_, marker) in data.npc_spawn_areas.iter() {
|
||||
if let Some(marker) = marker {
|
||||
marker.remove(world)?;
|
||||
marker.remove(world);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,11 +193,9 @@ impl AlterEntities for HashMap<Coordinate, (Entity, Vector3<f32>)> {
|
|||
}
|
||||
|
||||
impl SpawnMarker {
|
||||
pub fn remove(&self, world: &mut World) -> Result<()> {
|
||||
world.remove_entity(self.flag)?;
|
||||
world.remove_entity(self.area)?;
|
||||
|
||||
Ok(())
|
||||
pub fn remove(&self, world: &mut World) {
|
||||
world.remove_entity(self.flag);
|
||||
world.remove_entity(self.area);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -590,16 +588,14 @@ impl MapData {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn disable_spawns(&mut self, world: &mut World) -> Result<()> {
|
||||
pub fn disable_spawns(&mut self, world: &mut World) {
|
||||
if self.show_spawn_locations {
|
||||
self.show_spawn_locations = false;
|
||||
|
||||
for (spawn_entity, _) in self.spawn_locations.values() {
|
||||
world.remove_entity(*spawn_entity)?;
|
||||
world.remove_entity(*spawn_entity);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn spawn_locations(&self) -> Vec<Vector3<f32>> {
|
||||
|
@ -673,7 +669,7 @@ impl MapData {
|
|||
if self.show_npc_spawns {
|
||||
// marker.add(scene)?;
|
||||
} else {
|
||||
marker.remove(world)?;
|
||||
marker.remove(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +707,7 @@ impl MapData {
|
|||
if self.show_npc_spawns {
|
||||
// marker.add(scene)?;
|
||||
} else {
|
||||
world.remove_entity(marker)?;
|
||||
world.remove_entity(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -789,7 +785,7 @@ impl MapData {
|
|||
async_db.add(move |sql| sql.remove_npc_spawn((coordinate.x, coordinate.y)))?;
|
||||
|
||||
if let Some(marker) = marker {
|
||||
marker.remove(world)?;
|
||||
marker.remove(world);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -858,7 +854,7 @@ impl MapData {
|
|||
async_db.add(move |sql| sql.remove_boss_spawn((coordinate.x, coordinate.y)))?;
|
||||
|
||||
if let Some(marker) = marker {
|
||||
world.remove_entity(marker)?;
|
||||
world.remove_entity(marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -929,7 +925,7 @@ impl MapData {
|
|||
sql.remove_entity(table_name, (coordinate.x, coordinate.y))
|
||||
})?;
|
||||
|
||||
world.remove_entity(entity)?;
|
||||
world.remove_entity(entity);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ impl SaveGame {
|
|||
pub fn to_entity_object<A: Ability + 'static>(
|
||||
self,
|
||||
world: &mut World,
|
||||
) -> Result<(Entity, String)> {
|
||||
) -> Result<(EntityObject, String)> {
|
||||
let mut entity_object = AssetHandler::create(world).empty_entity();
|
||||
|
||||
entity_object.insert_component(Draw::new(Vec::new()));
|
||||
|
@ -397,6 +397,6 @@ impl SaveGame {
|
|||
entity_object.insert_component(statistics);
|
||||
entity_object.insert_component(current_status);
|
||||
|
||||
Ok((world.add_entity(entity_object)?, self.general.name))
|
||||
Ok((entity_object, self.general.name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use super::{
|
|||
};
|
||||
|
||||
pub trait Ability: Send + Sync + Clone + Default {
|
||||
fn create(context: &Context, asset_path: impl Into<AssetPath>) -> Result<Self>;
|
||||
fn create(world: &mut World, asset_path: impl Into<AssetPath>) -> Result<Self>;
|
||||
|
||||
fn name(&self) -> &str;
|
||||
fn icon_path(&self) -> &AssetPath;
|
||||
|
|
|
@ -53,7 +53,7 @@ pub struct ItemSystem<A: Ability> {
|
|||
|
||||
impl<A: Ability> ItemSystem<A> {
|
||||
pub fn new(
|
||||
context: &Context,
|
||||
world: &mut World,
|
||||
item_settings: &ItemSettings,
|
||||
ability_settings: &AbilitySettings,
|
||||
attribute_settings: &AttributeSettings,
|
||||
|
@ -64,9 +64,11 @@ impl<A: Ability> ItemSystem<A> {
|
|||
|
||||
let abilities = search_dir_recursively(&ability_directory.full_path(), ".abil")?
|
||||
.into_iter()
|
||||
.map(|path| A::create(context, path))
|
||||
.map(|path| A::create(world, path))
|
||||
.collect::<Result<Vec<A>>>()?;
|
||||
|
||||
let context = world.resources.get::<Context>();
|
||||
|
||||
let (
|
||||
item_icon_combinations,
|
||||
ability_icon_combinations,
|
||||
|
|
Loading…
Reference in a new issue