From 28233c678b8fe0b9a7c94aba0e453ce5846ebb62 Mon Sep 17 00:00:00 2001 From: Rendo Date: Sun, 16 Feb 2025 17:23:13 +0500 Subject: [PATCH] Finally proper property ecosystem --- src/main.rs | 3 +- src/properties/mod.rs | 90 +++++++--------------------------------- src/properties/plugin.rs | 19 +++++++++ 3 files changed, 35 insertions(+), 77 deletions(-) create mode 100644 src/properties/plugin.rs diff --git a/src/main.rs b/src/main.rs index d216c17..98948e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ use bevy::prelude::*; +use evolution_rs::properties::plugin::BasePropertiesPlugin; fn main() { App::new() - .add_plugins(DefaultPlugins) + .add_plugins((DefaultPlugins,BasePropertiesPlugin)) .run(); } diff --git a/src/properties/mod.rs b/src/properties/mod.rs index a596854..92654ee 100644 --- a/src/properties/mod.rs +++ b/src/properties/mod.rs @@ -1,89 +1,27 @@ +pub mod plugin; + +use bevy_trait_query; +use bevy::prelude::Component; // Базовый трейт для свойства животного // Интересно, будет ли участвовать в моддинге + +#[bevy_trait_query::queryable] pub trait Property: Sync + Send { fn check_condition(self : &Self) -> bool; fn trigger(self : &Self); } -pub enum BaseProperties +#[derive(Component)] +pub struct TestProperty; + +impl Property for TestProperty { - Swimmings, - Running, - Mimicry, - HBW, - Grazing, - Poisonous, - TailLoss, - Communication, - Hibernation, - Scavenger, - Symbiosis, - Piracy, - Cooperation, - Burrowing, - Camouflage, - SharpVision, - Parasite -} - -//Блок основных имплементаций - -impl Property for BaseProperties { - fn check_condition(self : &Self) -> bool { - match self - { - BaseProperties::Swimmings => todo!(), - BaseProperties::Running => todo!(), - BaseProperties::Mimicry => todo!(), - BaseProperties::HBW => todo!(), - BaseProperties::Grazing => todo!(), - BaseProperties::Poisonous => todo!(), - BaseProperties::TailLoss => todo!(), - BaseProperties::Communication => todo!(), - BaseProperties::Hibernation => todo!(), - BaseProperties::Scavenger => todo!(), - BaseProperties::Symbiosis => todo!(), - BaseProperties::Piracy => todo!(), - BaseProperties::Cooperation => todo!(), - BaseProperties::Burrowing => todo!(), - BaseProperties::Camouflage => todo!(), - BaseProperties::SharpVision => todo!(), - BaseProperties::Parasite => todo!(), - } + fn check_condition(self: &Self) -> bool { + false } - fn trigger(self : &Self) { - match self - { - BaseProperties::Swimmings => todo!(), - BaseProperties::Running => todo!(), - BaseProperties::Mimicry => todo!(), - BaseProperties::HBW => todo!(), - BaseProperties::Grazing => todo!(), - BaseProperties::Poisonous => todo!(), - BaseProperties::TailLoss => todo!(), - BaseProperties::Communication => todo!(), - BaseProperties::Hibernation => todo!(), - BaseProperties::Scavenger => todo!(), - BaseProperties::Symbiosis => todo!(), - BaseProperties::Piracy => todo!(), - BaseProperties::Cooperation => todo!(), - BaseProperties::Burrowing => todo!(), - BaseProperties::Camouflage => todo!(), - BaseProperties::SharpVision => todo!(), - BaseProperties::Parasite => todo!(), - } + fn trigger(self: &Self) { + println!("Testing property!"); } -} - -// Блок необходимых имплементаций -unsafe impl Sync for BaseProperties -{ - -} - -unsafe impl Send for BaseProperties -{ - } \ No newline at end of file diff --git a/src/properties/plugin.rs b/src/properties/plugin.rs new file mode 100644 index 0000000..8852f14 --- /dev/null +++ b/src/properties/plugin.rs @@ -0,0 +1,19 @@ +use bevy::prelude::{App,Plugin}; + +use crate::properties::{Property, TestProperty}; + +pub struct BasePropertiesPlugin; + +impl Plugin for BasePropertiesPlugin +{ + fn build(&self, app: &mut App) { + // Моды должны будут делать кастомный плагин и подгружать его при загрузке мода + + use bevy_trait_query::RegisterExt; + + app + .register_component_as::(); + //.add_systems(schedule, <ЗДЕСЬ ДОЛЖНА БЫТЬ СИСТЕМА ДЛЯ УСЛОВИЯ>) + //.add_systems(schedule, <ЗДЕСЬ ДОЛЖНА БЫТЬ СИСТЕМА ДЛЯ ТРИГГЕРА); + } +} \ No newline at end of file