pub struct LookDirection { /* private fields */ }
Expand description
A component that contains the direction an entity is looking, in degrees.
To avoid flagging anticheats, consider using Self::update
when updating
the values of this struct.
Implementations§
Source§impl LookDirection
impl LookDirection
Sourcepub fn new(y_rot: f32, x_rot: f32) -> Self
pub fn new(y_rot: f32, x_rot: f32) -> Self
Create a new look direction and clamp the x_rot
to the allowed values.
Sourcepub fn y_rot(&self) -> f32
pub fn y_rot(&self) -> f32
Returns yaw (left and right) in degrees.
Minecraft allows this to go outside of ±360°, so it won’t necessarily be in any range.
Sourcepub fn update(&mut self, new: LookDirection)
pub fn update(&mut self, new: LookDirection)
Update this look direction to the new value, while handling relative rotations correctly and with the default Minecraft sensitivity to avoid triggering anticheats.
Sourcepub fn update_y_rot(&mut self, new_y_rot: f32)
pub fn update_y_rot(&mut self, new_y_rot: f32)
Update the y_rot
to the given value, in degrees.
This is a shortcut for Self::update
while keeping the x_rot
the
same.
Sourcepub fn update_x_rot(&mut self, new_x_rot: f32)
pub fn update_x_rot(&mut self, new_x_rot: f32)
Update the x_rot
to the given value, in degrees.
This is a shortcut for Self::update
while keeping the y_rot
the
same.
Sourcepub fn update_with_sensitivity(&mut self, new: LookDirection, sensitivity: f32)
pub fn update_with_sensitivity(&mut self, new: LookDirection, sensitivity: f32)
Update this look direction to the new value, using the given sensitivity value.
Consider using Self::update
instead, which uses 1.0 as the
sensitivity (equivalent to 100% sensitivity in Minecraft).
Trait Implementations§
Source§impl AzaleaRead for LookDirection
impl AzaleaRead for LookDirection
Source§impl AzaleaWrite for LookDirection
impl AzaleaWrite for LookDirection
Source§impl Clone for LookDirection
impl Clone for LookDirection
Source§fn clone(&self) -> LookDirection
fn clone(&self) -> LookDirection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Component for LookDirection
impl Component for LookDirection
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>
],
while immutable components will instead have [Component<Mutability = Immutable>
]. Read moreSource§fn register_required_components(
requiree: ComponentId,
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
inheritance_depth: u16,
recursion_check_stack: &mut Vec<ComponentId>,
)
fn register_required_components( requiree: ComponentId, components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, inheritance_depth: u16, recursion_check_stack: &mut Vec<ComponentId>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
Component::on_add
, etc.)ComponentHooks
].§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_add
[ComponentHook
] for this [Component
] if one is defined.§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_insert
[ComponentHook
] for this [Component
] if one is defined.§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_replace
[ComponentHook
] for this [Component
] if one is defined.§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_remove
[ComponentHook
] for this [Component
] if one is defined.§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
on_despawn
[ComponentHook
] for this [Component
] if one is defined.§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper
]. This is used to remap entities in contexts like scenes and entity cloning.
When deriving [Component
], this is populated by annotating fields containing entities with #[entities]
Read moreSource§impl Debug for LookDirection
impl Debug for LookDirection
Source§impl Default for LookDirection
impl Default for LookDirection
Source§fn default() -> LookDirection
fn default() -> LookDirection
Source§impl From<LookDirection> for (f32, f32)
impl From<LookDirection> for (f32, f32)
Source§fn from(value: LookDirection) -> Self
fn from(value: LookDirection) -> Self
Source§impl Hash for LookDirection
impl Hash for LookDirection
Source§impl PartialEq for LookDirection
impl PartialEq for LookDirection
impl Copy for LookDirection
impl Eq for LookDirection
impl StructuralPartialEq for LookDirection
Auto Trait Implementations§
impl Freeze for LookDirection
impl RefUnwindSafe for LookDirection
impl Send for LookDirection
impl Sync for LookDirection
impl Unpin for LookDirection
impl UnwindSafe for LookDirection
Blanket Implementations§
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
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )
§fn register_required_components(
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
)
fn register_required_components( components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, )
Bundle
].§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Bundle
]’s component ids. This will be None
if the component has not been registered.§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DynEq for T
impl<T> DynEq for T
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.