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
use std::hash::Hash;

use naia_shared::{ChannelIndex, Protocolize};

use super::{server::Server, user::UserKey};

pub struct UserScopeMut<'s, P: Protocolize, E: Copy + Eq + Hash + Send + Sync, C: ChannelIndex> {
    server: &'s mut Server<P, E, C>,
    key: UserKey,
}

impl<'s, P: Protocolize, E: Copy + Eq + Hash + Send + Sync, C: ChannelIndex>
    UserScopeMut<'s, P, E, C>
{
    pub fn new(server: &'s mut Server<P, E, C>, key: &UserKey) -> Self {
        UserScopeMut { server, key: *key }
    }

    pub fn include(&mut self, entity: &E) -> &mut Self {
        self.server.user_scope_set_entity(&self.key, entity, true);

        self
    }

    pub fn exclude(&mut self, entity: &E) -> &mut Self {
        self.server.user_scope_set_entity(&self.key, entity, false);

        self
    }
}