Struct veloren_common::generation::EntityConfig
source · pub struct EntityConfig {
name: NameKind,
pub body: BodyBuilder,
pub alignment: AlignmentMark,
pub agent: AgentConfig,
pub loot: LootSpec<String>,
pub inventory: InventorySpec,
pub pets: Vec<(String, RangeInclusive<usize>)>,
pub death_effects: Vec<DeathEffect>,
pub meta: Vec<Meta>,
}
Expand description
Struct for EntityInfo manifest.
Intended to use with .ron files as base definition or in rare cases as extension manifest. Pure data struct, doesn’t do anything until evaluated with EntityInfo.
Check assets/common/entity/template.ron or other examples.
§Example
use vek::Vec3;
use veloren_common::generation::EntityInfo;
// create new EntityInfo at dummy position
// and fill it with template config
let dummy_position = Vec3::new(0.0, 0.0, 0.0);
// rng is required because some elements may be randomly generated
let mut dummy_rng = rand::thread_rng();
let entity = EntityInfo::at(dummy_position).with_asset_expect(
"common.entity.template",
&mut dummy_rng,
None,
);
Fields§
§name: NameKind
Name of Entity Can be Name(String) with given name or Automatic which will call automatic name depend on Body or Uninit (means it should be specified somewhere in code)
body: BodyBuilder
Body Can be Exact (Body with all fields e.g BodyType, Species, Hair color and such) or RandomWith (will generate random body or species) or Uninit (means it should be specified somewhere in code)
alignment: AlignmentMark
Alignment, can be Uninit
agent: AgentConfig
Parameterises agent behaviour
loot: LootSpec<String>
Loot See LootSpec in lottery
inventory: InventorySpec
Loadout & Inventory
Check docs for InventorySpec
struct in this file.
pets: Vec<(String, RangeInclusive<usize>)>
Pets to spawn with this entity (specified as a list of asset paths). The range represents how many pets will be spawned.
death_effects: Vec<DeathEffect>
§meta: Vec<Meta>
Meta Info for optional fields Possible fields: SkillSetAsset(String) with asset_specifier for skillset
Implementations§
source§impl EntityConfig
impl EntityConfig
pub fn from_asset_expect_owned(asset_specifier: &str) -> Self
pub fn with_body(self, body: BodyBuilder) -> Self
Trait Implementations§
source§impl Asset for EntityConfig
impl Asset for EntityConfig
source§const EXTENSION: &'static str = "ron"
const EXTENSION: &'static str = "ron"
§const EXTENSIONS: &'static [&'static str] = _
const EXTENSIONS: &'static [&'static str] = _
§fn default_value(
id: &SharedString,
error: Box<dyn Error + Send + Sync>,
) -> Result<Self, Box<dyn Error + Send + Sync>>
fn default_value( id: &SharedString, error: Box<dyn Error + Send + Sync>, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Ok
, the returned value is used as an asset. In
particular, if this method always returns Ok
, AssetCache::load
is
guaranteed not to fail. Read more§const HOT_RELOADED: bool = true
const HOT_RELOADED: bool = true
false
, disable hot-reloading for assets of this type (true
by
default). This avoids having to lock the asset to read it (ie it makes
[Handle::read
] a noop)source§impl Clone for EntityConfig
impl Clone for EntityConfig
source§fn clone(&self) -> EntityConfig
fn clone(&self) -> EntityConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EntityConfig
impl Debug for EntityConfig
source§impl<'de> Deserialize<'de> for EntityConfig
impl<'de> Deserialize<'de> for EntityConfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EntityConfig
impl RefUnwindSafe for EntityConfig
impl Send for EntityConfig
impl Sync for EntityConfig
impl Unpin for EntityConfig
impl UnwindSafe for EntityConfig
Blanket Implementations§
source§impl<T> AssetExt for Twhere
T: Compound,
impl<T> AssetExt for Twhere
T: Compound,
source§fn load(specifier: &str) -> Result<&'static Handle<T>, Error>
fn load(specifier: &str) -> Result<&'static Handle<T>, Error>
fn load_owned(specifier: &str) -> Result<T, Error>
fn get_or_insert(specifier: &str, default: T) -> &'static Handle<T>
source§fn load_cloned(specifier: &str) -> Result<Self, Error>where
Self: Clone,
fn load_cloned(specifier: &str) -> Result<Self, Error>where
Self: Clone,
fn load_or_insert_with( specifier: &str, default: impl FnOnce(Error) -> Self, ) -> &'static Handle<Self>
source§fn load_expect(specifier: &str) -> &'static Handle<Self>
fn load_expect(specifier: &str) -> &'static Handle<Self>
source§fn load_expect_cloned(specifier: &str) -> Selfwhere
Self: Clone,
fn load_expect_cloned(specifier: &str) -> Selfwhere
Self: Clone,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Compound for Twhere
T: Asset,
impl<T> Compound for Twhere
T: Asset,
§fn load(
cache: AnyCache<'_>,
id: &SharedString,
) -> Result<T, Box<dyn Error + Send + Sync>>
fn load( cache: AnyCache<'_>, id: &SharedString, ) -> Result<T, Box<dyn Error + Send + Sync>>
§const HOT_RELOADED: bool = Self::HOT_RELOADED
const HOT_RELOADED: bool = Self::HOT_RELOADED
false
, disable hot-reloading for assets of this type (true
by
default). This avoids having to lock the asset to read it (ie it makes
[Handle::read
] a noop)§impl<T> DirLoadable for Twhere
T: Asset,
impl<T> DirLoadable for Twhere
T: Asset,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more