forked from 2ndbeam/evolution-rs
Finally proper property ecosystem
This commit is contained in:
parent
ec7a55a060
commit
28233c678b
3 changed files with 35 additions and 77 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use evolution_rs::properties::plugin::BasePropertiesPlugin;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins((DefaultPlugins,BasePropertiesPlugin))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,89 +1,27 @@
|
||||||
|
pub mod plugin;
|
||||||
|
|
||||||
|
use bevy_trait_query;
|
||||||
|
use bevy::prelude::Component;
|
||||||
|
|
||||||
// Базовый трейт для свойства животного
|
// Базовый трейт для свойства животного
|
||||||
// Интересно, будет ли участвовать в моддинге
|
// Интересно, будет ли участвовать в моддинге
|
||||||
|
|
||||||
|
#[bevy_trait_query::queryable]
|
||||||
pub trait Property: Sync + Send {
|
pub trait Property: Sync + Send {
|
||||||
fn check_condition(self : &Self) -> bool;
|
fn check_condition(self : &Self) -> bool;
|
||||||
fn trigger(self : &Self);
|
fn trigger(self : &Self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum BaseProperties
|
#[derive(Component)]
|
||||||
|
pub struct TestProperty;
|
||||||
|
|
||||||
|
impl Property for TestProperty
|
||||||
{
|
{
|
||||||
Swimmings,
|
fn check_condition(self: &Self) -> bool {
|
||||||
Running,
|
false
|
||||||
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 trigger(self : &Self) {
|
fn trigger(self: &Self) {
|
||||||
match self
|
println!("Testing property!");
|
||||||
{
|
|
||||||
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!(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Блок необходимых имплементаций
|
|
||||||
unsafe impl Sync for BaseProperties
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl Send for BaseProperties
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
19
src/properties/plugin.rs
Normal file
19
src/properties/plugin.rs
Normal file
|
|
@ -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::<dyn Property, TestProperty>();
|
||||||
|
//.add_systems(schedule, <ЗДЕСЬ ДОЛЖНА БЫТЬ СИСТЕМА ДЛЯ УСЛОВИЯ>)
|
||||||
|
//.add_systems(schedule, <ЗДЕСЬ ДОЛЖНА БЫТЬ СИСТЕМА ДЛЯ ТРИГГЕРА);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue