示例#1
0
文件: Packets.cs 项目: QWdev/FlaxNet
        private static void PlayerData(Connection client, NetworkMessage msg)
        {
            Prefab  prefab   = protocol.playerPrefab;
            uint    id       = msg.ReadUInt();
            Vector3 position = msg.ReadVector3();

            Actor actor = PrefabManager.SpawnPrefab(prefab, position);

            actor.Name = $"Player[{id}]";
            Protocol.players.TryAdd(id, actor.GetScript <Player>());

            if (client.GetId() == id)
            {
                protocol.ExecuteAction(() =>
                {
                    var inputManager   = actor.AddScript <InputManager>();
                    inputManager.owner = actor.GetScript <Player>();
                });
            }
        }