CommandPayload

Enum CommandPayload 

Source
pub enum CommandPayload {
    Move {
        entity_id: u64,
        target_coord: Coord,
    },
    Spawn {
        coord: Coord,
        field_values: Vec<(FieldId, f32)>,
    },
    Despawn {
        entity_id: u64,
    },
    SetField {
        coord: Coord,
        field_id: FieldId,
        value: f32,
    },
    Custom {
        type_id: u32,
        data: Vec<u8>,
    },
    SetParameter {
        key: ParameterKey,
        value: f64,
    },
    SetParameterBatch {
        params: Vec<(ParameterKey, f64)>,
    },
}
Expand description

All command payloads.

WorldEvent variants affect per-cell state; GlobalParameter variants affect simulation-wide scalar parameters.

§Examples

use murk_core::{CommandPayload, FieldId, ParameterKey};

// Set a single field value at a coordinate.
let coord: murk_core::Coord = vec![3i32, 7].into();
let payload = CommandPayload::SetField {
    coord,
    field_id: FieldId(0),
    value: 42.0,
};

// Batch-set multiple global parameters atomically.
let batch = CommandPayload::SetParameterBatch {
    params: vec![(ParameterKey(0), 1.0), (ParameterKey(1), 0.5)],
};

assert!(matches!(payload, CommandPayload::SetField { .. }));
assert!(matches!(batch, CommandPayload::SetParameterBatch { .. }));

Variants§

§

Move

Move an entity to a target coordinate.

Rejected if entity_id is unknown or target_coord is out of bounds.

Fields

§entity_id: u64

The entity to move.

§target_coord: Coord

The destination coordinate.

§

Spawn

Spawn a new entity at a coordinate with initial field values.

Fields

§coord: Coord

The spawn location.

§field_values: Vec<(FieldId, f32)>

Initial field values for the new entity.

§

Despawn

Remove an entity. Associated field values are cleared at the next tick.

Fields

§entity_id: u64

The entity to remove.

§

SetField

Set a single field value at a coordinate. Primarily for Sparse fields.

Fields

§coord: Coord

The target cell coordinate.

§field_id: FieldId

The field to modify.

§value: f32

The new value.

§

Custom

Extension point for domain-specific commands.

Fields

§type_id: u32

User-registered type identifier.

§data: Vec<u8>

Opaque payload data.

§

SetParameter

Set a single global parameter. Takes effect at the next tick boundary.

Fields

§key: ParameterKey

The parameter to set.

§value: f64

The new value.

§

SetParameterBatch

Batch-set multiple parameters atomically.

Fields

§params: Vec<(ParameterKey, f64)>

The parameters to set.

Trait Implementations§

Source§

impl Clone for CommandPayload

Source§

fn clone(&self) -> CommandPayload

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommandPayload

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CommandPayload

Source§

fn eq(&self, other: &CommandPayload) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CommandPayload

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.