Large amounts of work on Rune
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2024-05-08 15:46:09 +02:00
parent 4bc76b0ee4
commit 4ec07ca049
43 changed files with 979 additions and 397 deletions

View File

@@ -0,0 +1,34 @@
use crate::script_implementations::rune::wrappers::{impl_rune_wrapper, RuneStringKey, RuneWrapper};
use crate::static_data::Ability;
use rune::runtime::{AnyObj, Shared};
use rune::Any;
use std::sync::Arc;
pub fn register(module: &mut rune::Module) -> anyhow::Result<()> {
module.ty::<RuneAbility>()?;
module.function_meta(RuneAbility::name)?;
module.function_meta(RuneAbility::effect)?;
module.function_meta(RuneAbility::get_parameter)?;
Ok(())
}
#[derive(Debug, Any)]
pub struct RuneAbility(Arc<dyn Ability>);
impl_rune_wrapper!(&Arc<dyn Ability>, RuneAbility);
impl RuneAbility {
#[rune::function]
fn name(&self) -> Shared<AnyObj> { self.0.name().wrap() }
#[rune::function]
fn effect(&self) -> Shared<AnyObj> { self.0.effect().wrap() }
#[rune::function(vm_result)]
fn get_parameter(&self, key: RuneStringKey) -> Option<Shared<AnyObj>> {
match self.0.parameters().get(&key.0) {
None => None,
Some(p) => Some(p.wrap()),
}
}
}