use crate::ffi::{ExternPointer, IdentifiablePointer, OwnedPtr}; use crate::static_data::{Nature, Statistic}; use std::ptr::drop_in_place; use std::sync::Arc; /// Instantiates a new statistic. #[no_mangle] extern "C" fn nature_new( increase_stat: Statistic, decrease_stat: Statistic, increase_modifier: f32, decrease_modifier: f32, ) -> IdentifiablePointer> { Nature::new(increase_stat, decrease_stat, increase_modifier, decrease_modifier).into() } /// Reduce the reference count for a nature. #[no_mangle] unsafe extern "C" fn nature_drop(ptr: OwnedPtr>) { drop_in_place(ptr) } /// The stat that should receive the increased modifier. #[no_mangle] extern "C" fn nature_increased_stat(ptr: ExternPointer>) -> Statistic { ptr.as_ref().increased_stat() } /// The stat that should receive the decreased modifier. #[no_mangle] extern "C" fn nature_decreased_stat(ptr: ExternPointer>) -> Statistic { ptr.as_ref().decreased_stat() } /// Calculates the modifier for a given stat. If it's the increased stat, returns the increased /// modifier, if it's the decreased stat, returns the decreased modifier. Otherwise returns 1.0 #[no_mangle] extern "C" fn nature_get_stat_modifier(ptr: ExternPointer>, stat: Statistic) -> f32 { ptr.as_ref().get_stat_modifier(stat) }