Skip to content

Instantly share code, notes, and snippets.

View Multirious's full-sized avatar

Multirious Multirious

View GitHub Profile
@Multirious
Multirious / pipe_or_break.rs
Last active February 22, 2024 02:57
Bevy PipeOrBreak
pub struct PipeOrBreak<COut>(PhantomData<COut>);
impl<ACOut, A, B> Combine<A, B> for PipeOrBreak<ACOut>
where
A: System<Out = ControlFlow<(), ACOut>>,
B: System<In = ACOut>,
{
type In = A::In;
type Out = ();
@Multirious
Multirious / clone_entity_tree.rs
Last active February 18, 2024 17:18
bevy clone entity tree
use std::sync::Arc;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EntityTreeNode {
pub source: Entity,
pub destination: Entity,
pub children: Vec<EntityTreeNode>,
}
impl EntityTreeNode {
@Multirious
Multirious / clone_entity.rs
Last active May 12, 2024 11:02
bevy_clone_entity_recursive
// Bevy version: 0.10
use bevy::{prelude::*, ecs::system::Command};
// Copy all components from an entity to another.
// Using an entity with no components as the destination creates a copy of the source entity.
// panics if
// - the components are not registered in the type registry,
// - the world does not have a type registry
// - the source or destination entity do not exist
pub fn clone_entity_components(
@Multirious
Multirious / windows_mouse_move_to.rs
Created August 6, 2023 08:15
Windows mouse move to
// Cargo.toml:
//
// [dependencies.windows]
// version = "0.48.0"
// features = [
// "Win32_UI_WindowsAndMessaging",
// "Win32_UI_Input",
// "Win32_UI_Input_KeyboardAndMouse",
// "Win32_Foundation",
// "Win32_System_Threading",