当前位置: 首页>>代码示例>>C#>>正文


C# Client.NetworkClient类代码示例

本文整理汇总了C#中Hypercube.Client.NetworkClient的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient类的具体用法?C# NetworkClient怎么用?C# NetworkClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetworkClient类属于Hypercube.Client命名空间,在下文中一共展示了NetworkClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

 public void Write(NetworkClient client)
 {
     client.WSock.WriteByte(Id);
         client.WSock.WriteByte(EntityId);
         client.WSock.WriteString(ModelName);
         client.WSock.Purge();
 }
开发者ID:umby24,项目名称:Hypercube,代码行数:7,代码来源:Packets.cs

示例2: BoxHandler

        static void BoxHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            if (mode != 1)
                return;

            switch (client.CS.MyEntity.BuildState) {
                case 0:
                    client.CS.MyEntity.ClientState.SetCoord(location, 0);
                    client.CS.MyEntity.BuildState = 1;
                    break;
                case 1:
                    var coord1 = client.CS.MyEntity.ClientState.GetCoord(0);
                    var blocks = Math.Abs(location.X - coord1.X)*Math.Abs(location.Y - coord1.Y)*
                                 Math.Abs(location.Z - coord1.Z);
                    var replaceBlock = client.CS.MyEntity.ClientState.GetString(0);

                    if (blocks < 50000) {
                        map.BuildBox(client, coord1.X, coord1.Y, coord1.Z, location.X, location.Y, location.Z, block,
                            String.IsNullOrEmpty(replaceBlock)
                                ? ServerCore.Blockholder.UnknownBlock
                                : ServerCore.Blockholder.GetBlock(replaceBlock), false, 1, true, false);

                        Chat.SendClientChat(client, "§SBox created.");
                    }
                    else
                        Chat.SendClientChat(client, "§EBox too large.");

                    client.CS.MyEntity.SetBuildmode("");
                    break;
            }
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:31,代码来源:Buildmodes.cs

示例3: CPEHandshake

        /// <summary>
        /// Sends all server supported extensions to the client.
        /// </summary>
        /// <param name="client"></param>
        public static void CPEHandshake(NetworkClient client)
        {
            var cExtInfo = new ExtInfo {AppName = "Hypercube Server", ExtensionCount = SupportedExtensions};
            client.SendQueue.Enqueue(cExtInfo);

            var cExtEntry = new ExtEntry {ExtName = "CustomBlocks", Version = CustomBlocksVersion};
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EmoteFix";
            cExtEntry.Version = EmoteFixVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "HeldBlock";
            cExtEntry.Version = HeldBlockVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "ClickDistance";
            cExtEntry.Version = ClickDistanceVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "ChangeModel";
            cExtEntry.Version = ChangeModelVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "ExtPlayerList";
            cExtEntry.Version = ExtPlayerListVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EnvWeatherType";
            cExtEntry.Version = EnvWeatherTypeVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EnvMapAppearance";
            cExtEntry.Version = EnvMapAppearanceVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "MessageTypes";
            cExtEntry.Version = MessageTypesVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "BlockPermissions";
            cExtEntry.Version = BlockPermissionsVersion;
            client.SendQueue.Enqueue(cExtEntry);

            //CExtEntry.ExtName = "TextHotKey";
            //CExtEntry.Version = TextHotKeyVersion;
            //CExtEntry.Write(Client);

            //CExtEntry.ExtName = "HackControl";
            //CExtEntry.Version = HackControlVersion;
            //CExtEntry.Write(Client);

            cExtEntry.ExtName = "SelectionCuboid";
            cExtEntry.Version = SelectionCuboidVersion;
            client.SendQueue.Enqueue(cExtEntry);

            cExtEntry.ExtName = "EnvColors";
            cExtEntry.Version = EnvColorsVersion;
            client.SendQueue.Enqueue(cExtEntry);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:64,代码来源:CPE.cs

示例4: Call

        public void Call(NetworkClient client, string[] args, string text1, string text2)
        {
            if (!CanBeCalled(client)) {
                Chat.SendClientChat(client, "§EYou do not have permission to use this command.");
                return;
            }

            if (!string.IsNullOrEmpty(Plugin))
                ServerCore.Luahandler.RunFunction(Plugin, client, args, text1, text2); // -- Run lua plugin for this command.
            else
                Handler(client, args, text1, text2);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:12,代码来源:CommandHandler.cs

示例5: CreateTPHandler

        static void CreateTPHandler(NetworkClient client, HypercubeMap map, Vector3S location, byte mode, Block block)
        {
            if (mode != 1)
                return;

            var state = client.CS.MyEntity.BuildState;

            switch (state) {
                case 0:
                    client.CS.MyEntity.ClientState.SetCoord(location.X, location.Y, location.Z, 1);
                    client.CS.MyEntity.BuildState = 1;
                    return;
                case 1:
                    var destCoord = client.CS.MyEntity.ClientState.GetCoord(0);
                    var destRot = client.CS.MyEntity.ClientState.GetInt(0);
                    var destLook = client.CS.MyEntity.ClientState.GetInt(1);
                    var startCoord = client.CS.MyEntity.ClientState.GetCoord(1);
                    var endCoord = new Vector3S { X = location.X, Y = location.Y, Z = location.Z };
                    var teleName = client.CS.MyEntity.ClientState.GetString(0);
                    var destMap = HypercubeMap.GetMap(client.CS.MyEntity.ClientState.GetString(1));

                    // -- Move things around so the smaller is the start, the larger being the end.
                    if (startCoord.X > location.X) {
                        endCoord.X = startCoord.X;
                        startCoord.X = location.X;
                    }

                    if (startCoord.Y > location.Y) {
                        endCoord.Y = startCoord.Y;
                        startCoord.Y = location.Y;
                    }

                    if (startCoord.Z > location.Z) {
                        endCoord.Z = startCoord.Z;
                        startCoord.Z = location.Z;
                    }

                    client.CS.CurrentMap.Teleporters.CreateTeleporter(teleName, startCoord, endCoord, destCoord, (byte)destLook, (byte)destRot, destMap);
                    Chat.SendClientChat(client, "§STeleporter created.");
                    client.CS.MyEntity.SetBuildmode("");
                    break;
            }
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:43,代码来源:Buildmodes.cs

示例6: HandleDisconnect

        /// <summary>
        /// Handles a client that is disconnecting
        /// </summary>
        /// <param name="client">The client that has disconnected.</param>
        public void HandleDisconnect(NetworkClient client)
        {
            lock (ClientLock) {
                Clients.Remove(client);
            }

            try {
                client.BaseSocket.Close();
            } catch (IOException) {
            }

            if (!client.CS.LoggedIn)
                return;

            client.CS.LoggedIn = false;

            lock (client.CS.CurrentMap.ClientLock) {
                client.CS.CurrentMap.Clients.Remove(client.CS.Id);
                client.CS.CurrentMap.CreateClientList();
            }

            if (client.CS.MyEntity != null) {
                client.CS.CurrentMap.DeleteEntity(ref client.CS.MyEntity);
                ServerCore.FreeEids.Push((short)client.CS.MyEntity.Id);
            }

            ServerCore.OnlinePlayers -= 1;
            ServerCore.FreeIds.Push(client.CS.NameId);
            LoggedClients.Remove(client.CS.LoginName);
            IntLoggedClients.Remove(client.CS.Id);
            CreateLists();

            var remove = new ExtRemovePlayerName {NameId = client.CS.NameId};

            foreach (var c in ClientList) {
                if (c.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                    c.SendQueue.Enqueue(remove);
            }

            ServerCore.Logger.Log("Network", "Player " + client.CS.LoginName + " has disconnected.", LogType.Info); // -- Notify of their disconnection.
            ServerCore.Luahandler.RunFunction("E_PlayerDisconnect", client.CS.LoginName);
            Chat.SendGlobalChat(ServerCore.TextFormats.SystemMessage + "Player " + client.CS.FormattedName + ServerCore.TextFormats.SystemMessage + " left.");
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:47,代码来源:NetworkHandler.cs

示例7: RulesHandler

        static void RulesHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            Chat.SendClientChat(client, "&6Server Rules:");

            for (var i = 0; i < ServerCore.Rules.Count; i++)
                Chat.SendClientChat(client, "&6" + (i + 1) + ": " + ServerCore.Rules[i]);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:7,代码来源:GeneralCommands.cs

示例8: PlayersHandler

        static void PlayersHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            var onlineString = "§SOnline Players: " + ServerCore.Nh.Clients.Count + "<br>";

            foreach (var hm in ServerCore.Maps.Values) {
                onlineString += "§S" + hm.CWMap.MapName + "&f: ";

                foreach(var c in hm.ClientsList)
                    onlineString += c.CS.FormattedName + " §D ";

                onlineString += "<br>";
            }

            Chat.SendClientChat(client, onlineString);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:15,代码来源:GeneralCommands.cs

示例9: MapsHandler

        static void MapsHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            var mapString = "§SMaps:<br>";

            foreach (var m in ServerCore.Maps.Values) {
                if (client.HasAllPermissions(m.Showperms.Values.ToList()))
                    mapString += "§S" + m.CWMap.MapName + " §D ";
            }

            Chat.SendClientChat(client, mapString);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:11,代码来源:GeneralCommands.cs

示例10: InfoHandler

 static void InfoHandler(NetworkClient client, string[] args, string text1, string text2)
 {
     Chat.SendClientChat(client, "§SServer Info:");
     Chat.SendClientChat(client, "§SThis server runs the &8Hypercube §SSoftware, by Umby24.");
     Chat.SendClientChat(client, "§SServer Version: " + Assembly.GetExecutingAssembly().GetName().Version + " on .NET " + Environment.Version + " (" + Environment.OSVersion + ")");
     Chat.SendClientChat(client, "§SUptime: " + (DateTime.UtcNow - ServerCore.Uptime).ToString("hh"));
 }
开发者ID:umby24,项目名称:Hypercube,代码行数:7,代码来源:GeneralCommands.cs

示例11: Getrankhandler

        static void Getrankhandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length != 1) {
                Chat.SendClientChat(client, "§EIncorrect usage. See /cmdhelp getrank.");
                return;
            }

            args[0] = ServerCore.DB.GetPlayerName(args[0]);

            if (args[0] == "") {
                Chat.SendClientChat(client, "§ECould not find the player.");
                return;
            }

            var playerRanks = RankContainer.SplitRanks(ServerCore.DB.GetDatabaseString(args[0], "PlayerDB", "Rank"));
            var playerSteps = RankContainer.SplitSteps(ServerCore.DB.GetDatabaseString(args[0], "PlayerDB", "RankStep"));
            var playerInfo = "§SRank(s) for " + args[0] + ": ";

            foreach (var r in playerRanks)
                playerInfo += r.Prefix + r.Name + r.Suffix + "(" + playerSteps[playerRanks.IndexOf(r)] + "), ";

            playerInfo = playerInfo.Substring(0, playerInfo.Length - 1); // -- Remove the final comma.
            playerInfo += "<br>";

            Chat.SendClientChat(client, playerInfo);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:26,代码来源:GeneralCommands.cs

示例12: CmdhelpHandler

        static void CmdhelpHandler(NetworkClient client, string[] args, string text1, string text2)
        {
            if (args.Length == 0) {
                Chat.SendClientChat(client, "§E&fUsage of this command: /cmdhelp [command].");
                return;
            }

            if (ServerCore.Commandholder.CommandDict.ContainsKey("/" + args[0].ToLower()) == false) {
                Chat.SendClientChat(client, "§E&fCommand not found.");
                return;
            }

            if (!ServerCore.Commandholder.CommandDict["/" + args[0]].CanBeSeen(client)) {
                Chat.SendClientChat(client, "§E&fCommand not found.");
                return;
            }

            var thisCommand = ServerCore.Commandholder.CommandDict["/" + args[0].ToLower()];
            Chat.SendClientChat(client, "§S/" + args[0]);
            Chat.SendClientChat(client, thisCommand.Help);
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:21,代码来源:GeneralCommands.cs

示例13: UpdateExtPlayerList

        /// <summary>
        /// Updates a client on everyone's ExtPlayerList (Ex. Client changed maps.)
        /// </summary>
        /// <param name="client">Client that has moved maps.</param>
        public static void UpdateExtPlayerList(NetworkClient client)
        {
            var toUpdate = new ExtAddPlayerName
            {
                NameId = client.CS.NameId,
                ListName = client.CS.FormattedName,
                PlayerName = client.CS.LoginName,
                GroupName = ServerCore.TextFormats.ExtPlayerList + client.CS.CurrentMap.CWMap.MapName,
                GroupRank = 0
            };

            lock (ServerCore.Nh.ClientLock) {
                foreach (var c in ServerCore.Nh.Clients) {
                    if (c.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                        c.SendQueue.Enqueue(toUpdate);
                }
            }
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:22,代码来源:CPE.cs

示例14: SetupExtPlayerList

        /// <summary>
        /// Does initial setup of ExtPlayerList for a player that is logging in.
        /// </summary>
        /// <param name="client">Client logging in</param>
        public static void SetupExtPlayerList(NetworkClient client)
        {
            var extPlayerListPacket = new ExtAddPlayerName {GroupRank = 0};

            lock (ServerCore.Nh.ClientLock) {
                foreach (var c in ServerCore.Nh.Clients) {
                    if (c != client) {
                        if (c.CS.CPEExtensions.ContainsKey("ExtPlayerList")) {
                            extPlayerListPacket.NameId = client.CS.NameId;
                            extPlayerListPacket.ListName = client.CS.FormattedName;
                            extPlayerListPacket.PlayerName = client.CS.LoginName;
                            extPlayerListPacket.GroupName = ServerCore.TextFormats.ExtPlayerList +
                                                            client.CS.CurrentMap.CWMap.MapName;

                            c.SendQueue.Enqueue(extPlayerListPacket);
                        }

                        if (!client.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                            continue;

                        extPlayerListPacket.NameId = c.CS.NameId;
                        extPlayerListPacket.ListName = c.CS.FormattedName;
                        extPlayerListPacket.PlayerName = c.CS.LoginName;
                        extPlayerListPacket.GroupName = ServerCore.TextFormats.ExtPlayerList + c.CS.CurrentMap.CWMap.MapName;
                        client.SendQueue.Enqueue(extPlayerListPacket);
                    } else {
                        if (!client.CS.CPEExtensions.ContainsKey("ExtPlayerList"))
                            continue;

                        extPlayerListPacket.NameId = client.CS.NameId;
                        extPlayerListPacket.ListName = client.CS.FormattedName;
                        extPlayerListPacket.PlayerName = client.CS.LoginName;
                        extPlayerListPacket.GroupName = ServerCore.TextFormats.ExtPlayerList +
                                                        client.CS.CurrentMap.CWMap.MapName;
                        client.SendQueue.Enqueue(extPlayerListPacket);
                    }
                }
            }
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:43,代码来源:CPE.cs

示例15: PostMapActions

        /// <summary>
        /// Sends additional packets to clients after sending the map to the client.
        /// </summary>
        /// <param name="client"></param>
        public static void PostMapActions(NetworkClient client)
        {
            int mapAppearance, blockPerms, weatherVer, colorVer;

            // -- EnvMapAppearance
            if (client.CS.CPEExtensions.TryGetValue("EnvMapAppearance", out mapAppearance) &&
                mapAppearance == EnvMapAppearanceVersion) {

                var cpeData = client.CS.CurrentMap.CPESettings;

                var mapApprPacket = new EnvSetMapAppearance {
                    EdgeBlock = cpeData.EdgeBlock,
                    SideBlock = cpeData.SideBlock,
                    SideLevel = cpeData.SideLevel,
                    TextureUrl = cpeData.TextureUrl
                };

                // -- Customblocks compatibility check
                if (mapApprPacket.EdgeBlock > 49) {
                    var mBlock = ServerCore.Blockholder.GetBlock(mapApprPacket.EdgeBlock);

                    if (mBlock.CPELevel > client.CS.CustomBlocksLevel)
                        mapApprPacket.EdgeBlock = (byte)mBlock.CPEReplace;
                }

                if (mapApprPacket.SideBlock > 49) {
                    var mBlock = ServerCore.Blockholder.GetBlock(mapApprPacket.SideBlock);

                    if (mBlock.CPELevel > client.CS.CustomBlocksLevel)
                        mapApprPacket.SideBlock = (byte)mBlock.CPEReplace;
                }

                client.SendQueue.Enqueue(mapApprPacket);
            }

            // -- BlockPermissions

            if (client.CS.CPEExtensions.TryGetValue("BlockPermissions", out blockPerms) &&
                blockPerms == BlockPermissionsVersion) {

                foreach (var block in ServerCore.Blockholder.NumberList) { // -- For every block
                    if (block.CPELevel > client.CS.CustomBlocksLevel) // -- If its within this player's CustomBlock support
                        continue;

                    if (block.Name == "Unknown") // -- If its not an unknown block
                        continue;

                    if (block.Special) // -- If it's not a custom block.
                        continue;

                    var disallowPlace = new SetBlockPermissions { // -- THen set the permissions for the block
                        AllowDeletion = 1,
                        AllowPlacement = 1,
                        BlockType = block.OnClient,
                    };

                    if (!client.HasAllPermissions(block.PlacePermissions)) {
                        disallowPlace.AllowPlacement = 0;
                    }

                    if (!client.HasAllPermissions(block.DeletePermissions))
                        disallowPlace.AllowDeletion = 0;

                    if (disallowPlace.AllowDeletion != 1 || disallowPlace.AllowPlacement != 1) // -- Only send if we're changing permissions though
                        client.SendQueue.Enqueue(disallowPlace);
                }
            }

            // -- EnvWeatherType
            if (client.CS.CPEExtensions.TryGetValue("EnvWeatherType", out weatherVer) &&
                weatherVer == EnvWeatherTypeVersion) {

                var weather = new EnvSetWeatherType {
                    WeatherType = client.CS.CurrentMap.CPESettings.Weather,
                };

                client.SendQueue.Enqueue(weather);
            }

            // -- EnvColors
            if (client.CS.CPEExtensions.TryGetValue("EnvColors", out colorVer) &&
                colorVer == EnvColorsVersion) {

                // -- if envcolors is enabled on the map
                if (client.CS.CurrentMap.CPESettings.EnvColorsVersion > 0) {
                    var skyColor = new EnvSetColor {
                        ColorType = (byte) EnvSetColor.ColorTypes.SkyColor,
                        Red = client.CS.CurrentMap.CPESettings.SkyColor[0],
                        Green = client.CS.CurrentMap.CPESettings.SkyColor[1],
                        Blue = client.CS.CurrentMap.CPESettings.SkyColor[2],
                    };

                    var cloudColor = new EnvSetColor {
                        ColorType = (byte)EnvSetColor.ColorTypes.CloudColor,
                        Red = client.CS.CurrentMap.CPESettings.CloudColor[0],
                        Green = client.CS.CurrentMap.CPESettings.CloudColor[1],
//.........这里部分代码省略.........
开发者ID:umby24,项目名称:Hypercube,代码行数:101,代码来源:CPE.cs


注:本文中的Hypercube.Client.NetworkClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。