Struct memory_management::world::Generator

source ·
pub struct Generator { /* private fields */ }
Expand description

A struct representing a terrain generator.

The Generator struct uses a seed to generate terrain heights based on a seed

Implementations§

source§

impl Generator

source

pub fn get_height(&self, x: i64, z: i64) -> i64

Calculates the height of the terrain at the specified coordinates (x, z).

This function uses sinusoidal functions to simulate terrain height.

§Arguments
  • x - The x-coordinate.
  • z - The z-coordinate.
§Returns
  • The height of the terrain at the specified coordinates.
§Example
use memory_management::world::Generator;

let generator = Generator::new();
let height = generator.get_height(10, 20);
println!("Height at (10, 20): {}", height);
source

pub fn new() -> Self

Creates a new Generator instance with a seed based on the current time.

The seed is derived from the current time in nanoseconds since the UNIX epoch.

§Returns
  • A new instance of Generator.
§Example
use memory_management::world::Generator;

let generator = Generator::new();
assert!(matches!(generator, Generator { .. }));
source

pub fn get_seed(&self) -> i64

Returns the seed used by the generator.

§Returns
  • The seed of the generator.
§Example
use memory_management::world::Generator;

let generator = Generator::new();
let seed = generator.get_seed();
println!("Generator seed: {}", seed);

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.