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