예제 #1
0
        private void OnCreateRemotePlayer(ref CreateRemotePlayer p)
        {
            byte index = p.Index;

            if (remotePlayers[index] != null)
            {
                //throw new InvalidOperationException();
                return;
            }

            PlayerType type = p.Type;
            Vector3    pos  = p.Pos;

            Root.DispatchToMainThread(delegate {
                RemotePlayer player = new RemotePlayer();

                if (Interlocked.CompareExchange(ref remotePlayers[index], player, null) != null)
                {
                    return;
                }

                player.OnActivated(new ActorActivationDetails {
                    Api    = Api,
                    Pos    = pos,
                    Params = new ushort[] { (ushort)type, (ushort)index }
                });

                //AddObject(player);
                AddActor(player);
            });
        }
예제 #2
0
        private void OnCreateRemotePlayer(ref CreateRemotePlayer p)
        {
            int index = p.Index;

            if (remotePlayers.ContainsKey(index))
            {
                throw new InvalidOperationException();
            }

            PlayerType type = p.Type;
            Vector3    pos  = p.Pos;

            Root.DispatchToMainThread(delegate {
                RemotePlayer player = new RemotePlayer();
                player.OnAttach(new ActorInstantiationDetails {
                    Api    = Api,
                    Pos    = pos,
                    Params = new ushort[] { (ushort)type, (ushort)index }
                });
                remotePlayers[index] = player;

                AddObject(player);
            });

            Console.WriteLine(" | RemotePlayer spawned: " + index);
        }