FFI for dynamic libraries

This commit is contained in:
2022-10-14 10:33:19 +02:00
parent 41b40ef98e
commit a840605bf7
15 changed files with 192 additions and 16 deletions

View File

@@ -3,12 +3,12 @@ use std::sync::Arc;
use crate::dynamic_data::{ItemScript, Script, ScriptOwnerData};
use crate::static_data::Item;
use crate::{PkmnResult, StringKey};
use crate::{PkmnResult, StringKey, ValueIdentifiable, ValueIdentifier};
/// A script resolver deals with the resolving of scripts. These scripts are non-hardcoded
/// implementations of different effects in Pokemon. This allows for things such as generational
/// differences, and custom implementations.
pub trait ScriptResolver: Debug {
pub trait ScriptResolver: Debug + ValueIdentifiable {
/// Loads a standard script with a given unique combination of category and key. If no script
/// can be created with this combination, returns None.
fn load_script(
@@ -55,7 +55,16 @@ pub enum ScriptCategory {
/// A basic empty script resolver, that always returns None.
#[derive(Debug)]
pub struct EmptyScriptResolver {}
pub struct EmptyScriptResolver {
/// A unique identifier so we know what value this is.
pub identifier: ValueIdentifier,
}
impl ValueIdentifiable for EmptyScriptResolver {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}
impl ScriptResolver for EmptyScriptResolver {
fn load_script(