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
//! This crate library implements multiplayer functionality for Digital
//! Extinction via [`MultiplayerPluginGroup`].
//!
//! Before a multiplayer game starts, networking and other systems must be
//! started. To do this send [`StartMultiplayerEvent`].
//!
//! After a multiplayer game ends, the multiplayer functionality should be shut
//! down via [`ShutdownMultiplayerEvent`].

use bevy::{app::PluginGroupBuilder, prelude::*};
use game::GamePlugin;
use lifecycle::LifecyclePlugin;
use messages::MessagesPlugin;
use playermsg::PlayerMsgPlugin;
use stats::StatsPlugin;

pub use crate::{
    config::{ConnectionType, NetGameConf},
    game::{
        GameJoinedEvent, GameOpenedEvent, GameReadinessEvent, PeerJoinedEvent, PeerLeftEvent,
        SetReadinessEvent,
    },
    lifecycle::{MultiplayerShuttingDownEvent, ShutdownMultiplayerEvent, StartMultiplayerEvent},
    messages::{MessagesSet, ToPlayersEvent},
    netstate::NetState,
    playermsg::{
        GameNetSet, NetEntities, NetEntityCommands, NetRecvDespawnActiveEvent, NetRecvHealthEvent,
        NetRecvProjectileEvent, NetRecvSetPathEvent, NetRecvSpawnActiveEvent,
        NetRecvTransformEvent,
    },
};
use crate::{netstate::NetStatePlugin, network::NetworkPlugin};

mod config;
mod game;
mod lifecycle;
mod messages;
mod netstate;
mod network;
mod playermsg;
mod stats;

pub struct MultiplayerPluginGroup;

impl PluginGroup for MultiplayerPluginGroup {
    fn build(self) -> PluginGroupBuilder {
        PluginGroupBuilder::start::<Self>()
            .add(NetStatePlugin)
            .add(LifecyclePlugin)
            .add(NetworkPlugin)
            .add(MessagesPlugin)
            .add(GamePlugin)
            .add(StatsPlugin)
            .add(PlayerMsgPlugin)
    }
}