/// <summary>
        /// Get the  player info for the peer
        /// </summary>
        /// <param name="Instance">The node this is called from</param>
        /// <param name="PeerId">The peer id</param>
        /// <typeparam name="T">The type of player info you want</typeparam>
        /// <returns>The player info as T</returns>
        public static T GetPlayerInfo <T>(this Node Instance, int PeerId) where T : MDPlayerInfo
        {
            MDGameSession Session    = Instance.GetGameSession();
            MDPlayerInfo  PlayerInfo = Session.GetPlayerInfo(PeerId);

            return(PlayerInfo as T);
        }
        /// <summary>
        /// Spawn a network node
        /// </summary>
        /// <param name="Instance">The Node from where function is called</param>
        /// <param name="Scene">The packed scene to spawn</param>
        /// <param name="NodeName">The name of the new node</param>
        /// <param name="NetworkMaster">The peer that should own this, default is server</param>
        /// <param name="SpawnPos">Where the spawn this node</param>
        public static Node SpawnNetworkedNode(this Node Instance, PackedScene Scene, string NodeName,
                                              int NetworkMaster = -1, Vector3?SpawnPos = null)
        {
            MDGameSession GameSession = Instance.GetGameSession();

            return(GameSession.SpawnNetworkedNode(Scene, Instance, NodeName, NetworkMaster, SpawnPos));
        }
        /// <summary>
        /// Spawn a network node
        /// </summary>
        /// <param name="Instance">The Node from where function is called</param>
        /// <param name="NodeType">The type of node to spawn</param>
        /// <param name="NodeName">The name of the new node</param>
        /// <param name="UseRandomName">If set to true a random number will be added at the end of the node name</param>
        /// <param name="NetworkMaster">The peer that should own this, default is server</param>
        /// <param name="SpawnPos">Where the spawn this node</param>
        public static Node SpawnNetworkedNode(this Node Instance, Type NodeType, string NodeName, bool UseRandomName,
                                              int NetworkMaster = -1, Vector3?SpawnPos = null)
        {
            MDGameSession GameSession = Instance.GetGameSession();

            return(GameSession.SpawnNetworkedNode(NodeType, Instance, NodeName, UseRandomName, NetworkMaster, SpawnPos));
        }
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     MDLog.AddLogCategoryProperties(LOG_CAT, new MDLogProperties(MDLogLevel.Info));
     GameSession = GameInstance.GetGameSession();
     GameSession.OnPlayerJoinedEvent      += OnPlayerJoinedEvent;
     GameSession.OnPlayerInitializedEvent += OnPlayerInitializedEvent;
     GameSession.OnPlayerLeftEvent        += OnPlayerLeftEvent;
     GameSession.OnNetworkNodeAdded       += OnNetworkNodeAdded;
     GameSession.OnNetworkNodeRemoved     += OnNetworkNodeRemoved;
     GameSession.OnSessionStartedEvent    += OnSessionStartedEvent;
     SynchronizationState = SynchronizationStates.SYNCHRONIZING_IN_PROGRESS;
 }
        public MDReplicatedMember(MemberInfo Member, bool Reliable, MDReplicatedType ReplicatedType, WeakRef NodeRef,
                                  MDReplicatedSetting[] Settings)
        {
            MDLog.AddLogCategoryProperties(LOG_CAT, new MDLogProperties(MDLogLevel.Info));
            GameSession      = MDStatics.GetGameSession();
            Replicator       = GameSession.Replicator;
            GameClock        = GameSession.GetGameClock();
            GameSynchronizer = GameSession.GetGameSynchronizer();

            this.Member         = Member;
            this.Reliable       = Reliable;
            this.ReplicatedType = ReplicatedType;
            this.NodeRef        = NodeRef;
            ParseSettings(MDReplicator.ParseParameters(typeof(Settings), Settings));
            CheckIfShouldReplicate();
        }
        /// <summary>
        /// Changes the network master of the node, this only works on the server
        /// </summary>
        /// <param name="NewNetworkMaster">The new network master ID</param>
        public static void ChangeNetworkMaster(this Node Instance, int NewNetworkMaster)
        {
            MDGameSession GameSession = Instance.GetGameSession();

            GameSession.ChangeNetworkMaster(Instance, NewNetworkMaster);
        }