DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 02d92df7ca80e1922af99eb5b0dc2e9865946c2c deck-builder/client/src/plugins/game/card/mod.rs -rw-r--r-- 1.8 KiB
02d92df7Jonni Liljamo feat(client): add CardPlugin in GamePlugin 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * This file is part of laurelin_client
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

use crate::game_status::Card;

pub struct CardPlugin;

impl Plugin for CardPlugin {
    fn build(&self, app: &mut App) {
        
    }
}

// NOTE: kind of like using enum variants
pub mod visual_card_kind {
    use bevy::prelude::*;

    #[derive(Component)]
    pub struct Normal;
    #[derive(Component)]
    pub struct Supply(pub usize);
}

#[derive(Component)]
pub struct VisualCard {
    pub card: Card,
}

impl VisualCard {
    pub const WIDTH: f32 = 0.35;
}

impl Default for VisualCard {
    fn default() -> Self {
        Self {
            card: Card {
                name: "".to_string(),
                short_details: vec![],
                long_details: vec![],
                cost: 0,
                actions: vec![]
            }
        }
    }
}

#[derive(Bundle)]
pub struct VisualCardBundle {
    pub visual_card: VisualCard,
    pub transform: Transform,
    pub global_transform: GlobalTransform,
    pub collider: Collider,
    pub rigid_body: RigidBody,
}

impl Default for VisualCardBundle {
    fn default() -> Self {
        Self {
            visual_card: VisualCard::default(),
            transform: Transform {
                translation: Vec3 { x: 0., y: 0., z: 0. },
                /// defaults to being rotated 90 degress on X, so flat on the
                /// table.
                rotation: Quat::from_euler(EulerRot::XYZ, -1.571, 0., 0.),
                ..Default::default()
            },
            global_transform: GlobalTransform::default(),
            collider: Collider::cuboid(VisualCard::WIDTH, VisualCard::WIDTH * 1.75, 0.01),
            rigid_body: RigidBody::Dynamic,
        }
    }
}