• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IMultiplayerServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GenerateDropEntity

        public void GenerateDropEntity(BlockDescriptor descriptor, IWorld world, IMultiplayerServer server, ItemStack item)
        {
            var entityManager = server.GetEntityManagerForWorld(world);
            var items = new ItemStack[0];
            var type = ToolType.None;
            var material = ToolMaterial.None;
            var held = ItemRepository.GetItemProvider(item.ID);

            if (held is ToolItem)
            {
                var tool = held as ToolItem;
                material = tool.Material;
                type = tool.ToolType;
            }

            if ((EffectiveTools & type) > 0)
            {
                if ((EffectiveToolMaterials & material) > 0)
                    items = GetDrop(descriptor, item);
            }

            foreach (var i in items)
            {
                if (i.Empty) continue;
                var entity = new ItemEntity(new Vector3(descriptor.Coordinates) + new Vector3(0.5), i);
                entityManager.SpawnEntity(entity);
            }
        }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:28,代码来源:BlockProvider.cs


示例2: HydrationCheckEvent

 void HydrationCheckEvent(IMultiplayerServer server, Coordinates3D coords, IWorld world)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     if (MathHelper.Random.Next(3) == 0)
     {
         var meta = world.GetMetadata(coords);
         if (IsHydrated(coords, world) && meta != 15)
             meta++;
         else
         {
             meta--;
             if (meta == 0)
             {
                 world.SetBlockID(coords, BlockID);
                 return;
             }
         }
         world.SetMetadata(coords, meta);
     }
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("farmland", chunk,
         TimeSpan.FromSeconds(UpdateIntervalSeconds),
         _server => HydrationCheckEvent(_server, coords, world));
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:25,代码来源:FarmlandBlock.cs


示例3: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("cactus", chunk,
         TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
         s => TryGrowth(s, coords, world));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:CactusBlock.cs


示例4: BlockUpdate

 public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
 {
     bool upper = ((DoorItem.DoorFlags)descriptor.Metadata & DoorItem.DoorFlags.Upper) == DoorItem.DoorFlags.Upper;
     var other = upper ? Coordinates3D.Down : Coordinates3D.Up;
     if (world.GetBlockID(descriptor.Coordinates + other) != ID)
         world.SetBlockID(descriptor.Coordinates, 0);
 }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:7,代码来源:DoorBlock.cs


示例5: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent(chunk,
         DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
         s => TrySpread(coords, world, server));
 }
开发者ID:zevipa,项目名称:TrueCraft,代码行数:7,代码来源:GrassBlock.cs


示例6: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("farmland", chunk,
         TimeSpan.FromSeconds(UpdateIntervalSeconds),
         s => HydrationCheckEvent(s, coords, world));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:FarmlandBlock.cs


示例7: HandleLoginRequestPacket

        public static void HandleLoginRequestPacket(IPacket packet, IRemoteClient client, IMultiplayerServer server)
        {
            var loginRequestPacket = (LoginRequestPacket)packet;
            var remoteClient = (RemoteClient)client;
            if (loginRequestPacket.ProtocolVersion < server.PacketReader.ProtocolVersion)
                remoteClient.QueuePacket(new DisconnectPacket("Client outdated! Use beta 1.7.3."));
            else if (loginRequestPacket.ProtocolVersion > server.PacketReader.ProtocolVersion)
                remoteClient.QueuePacket(new DisconnectPacket("Server outdated! Use beta 1.7.3."));
            else if (server.Worlds.Count == 0)
                remoteClient.QueuePacket(new DisconnectPacket("Server has no worlds configured."));
            else if (!server.PlayerIsWhitelisted(remoteClient.Username) && server.PlayerIsBlacklisted(remoteClient.Username))
                remoteClient.QueuePacket(new DisconnectPacket("You're banned from this server"));
            else if (server.Clients.Count(c => c.Username == client.Username) > 1)
                remoteClient.QueuePacket(new DisconnectPacket("The player with this username is already logged in"));
            else
            {
                remoteClient.LoggedIn = true;
                remoteClient.Entity = new PlayerEntity(remoteClient.Username);
                remoteClient.World = server.Worlds[0];
                remoteClient.ChunkRadius = 2;

                if (!remoteClient.Load())
                    remoteClient.Entity.Position = remoteClient.World.SpawnPoint;
                // Make sure they don't spawn in the ground
                var collision = new Func<bool>(() =>
                {
                    var feet = client.World.GetBlockID((Coordinates3D)client.Entity.Position);
                    var head = client.World.GetBlockID((Coordinates3D)(client.Entity.Position + Vector3.Up));
                    var feetBox = server.BlockRepository.GetBlockProvider(feet).BoundingBox;
                    var headBox = server.BlockRepository.GetBlockProvider(head).BoundingBox;
                    return feetBox != null || headBox != null;
                });
                while (collision())
                    client.Entity.Position += Vector3.Up;

                // Send setup packets
                remoteClient.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld));
                remoteClient.UpdateChunks();
                remoteClient.QueuePacket(new WindowItemsPacket(0, remoteClient.Inventory.GetSlots()));
                remoteClient.QueuePacket(new SpawnPositionPacket((int)remoteClient.Entity.Position.X,
                        (int)remoteClient.Entity.Position.Y, (int)remoteClient.Entity.Position.Z));
                remoteClient.QueuePacket(new SetPlayerPositionPacket(remoteClient.Entity.Position.X,
                        remoteClient.Entity.Position.Y + 1,
                        remoteClient.Entity.Position.Y + remoteClient.Entity.Size.Height + 1,
                        remoteClient.Entity.Position.Z, remoteClient.Entity.Yaw, remoteClient.Entity.Pitch, true));
                remoteClient.QueuePacket(new TimeUpdatePacket(remoteClient.World.Time));

                // Start housekeeping for this client
                var entityManager = server.GetEntityManagerForWorld(remoteClient.World);
                entityManager.SpawnEntity(remoteClient.Entity);
                entityManager.SendEntitiesToClient(remoteClient);
                server.Scheduler.ScheduleEvent("remote.keepalive", remoteClient, TimeSpan.FromSeconds(10), remoteClient.SendKeepAlive);
                server.Scheduler.ScheduleEvent("remote.chunks", remoteClient, TimeSpan.FromSeconds(1), remoteClient.ExpandChunkRadius);

                if (!string.IsNullOrEmpty(Program.ServerConfiguration.MOTD))
                    remoteClient.SendMessage(Program.ServerConfiguration.MOTD);
                if (!Program.ServerConfiguration.Singleplayer)
                    server.SendMessage(ChatColor.Yellow + "{0} joined the server.", remoteClient.Username);
            }
        }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:60,代码来源:LoginHandlers.cs


示例8: HandleHandshakePacket

 public static void HandleHandshakePacket(IPacket packet, IRemoteClient client, IMultiplayerServer server)
 {
     var handshakePacket = (HandshakePacket) packet;
     var remoteClient = (RemoteClient)client;
     remoteClient.Username = handshakePacket.Username;
     remoteClient.QueuePacket(new HandshakeResponsePacket("-")); // TODO: Implement some form of authentication
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:LoginHandlers.cs


示例9: TryGrowth

 private void TryGrowth(IMultiplayerServer server, Coordinates3D coords, IWorld world)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     // Find current height of stalk
     int height = 0;
     for (int y = -MaxGrowHeight; y <= MaxGrowHeight; y++)
     {
         if (world.GetBlockID(coords + (Coordinates3D.Down * y)) == BlockID)
             height++;
     }
     if (height < MaxGrowHeight)
     {
         var meta = world.GetMetadata(coords);
         meta++;
         world.SetMetadata(coords, meta);
         var chunk = world.FindChunk(coords);
         if (meta == 15)
         {
             if (world.GetBlockID(coords + Coordinates3D.Up) == 0)
             {
                 world.SetBlockID(coords + Coordinates3D.Up, BlockID);
                 server.Scheduler.ScheduleEvent("cactus", chunk,
                     TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                     (_server) => TryGrowth(_server, coords + Coordinates3D.Up, world));
             }
         }
         else
         {
             server.Scheduler.ScheduleEvent("cactus", chunk,
                 TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                 (_server) => TryGrowth(_server, coords, world));
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:35,代码来源:CactusBlock.cs


示例10: DoSpread

        public void DoSpread(IMultiplayerServer server, IWorld world, BlockDescriptor descriptor)
        {
            foreach (var coord in SpreadableBlocks)
            {
                var check = descriptor.Coordinates + coord;
                if (world.GetBlockID(check) == AirBlock.BlockID)
                {
                    // Check if this is adjacent to a flammable block
                    foreach (var adj in AdjacentBlocks)
                    {
                        var provider = BlockRepository.GetBlockProvider(
                           world.GetBlockID(check + adj));
                        if (provider.Flammable)
                        {
                            if (provider.Hardness == 0)
                                check = check + adj;

                            // Spread to this block
                            world.SetBlockID(check, FireBlock.BlockID);
                            ScheduleUpdate(server, world, world.GetBlockData(check));
                            break;
                        }
                    }
                }
            }
        }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:26,代码来源:FireBlock.cs


示例11: DestroyCactus

        public void DestroyCactus(BlockDescriptor descriptor, IMultiplayerServer server, IWorld world)
        {
            var toDrop = 0;

            // Search upwards
            for (int y = descriptor.Coordinates.Y; y < 127; y++)
            {
                var coordinates = new Coordinates3D(descriptor.Coordinates.X, y, descriptor.Coordinates.Z);
                if (world.GetBlockID(coordinates) == CactusBlock.BlockID)
                {
                    world.SetBlockID(coordinates, AirBlock.BlockID);
                    toDrop++;
                }
            }

            // Search downwards.
            for (int y = descriptor.Coordinates.Y - 1; y > 0; y--)
            {
                var coordinates = new Coordinates3D(descriptor.Coordinates.X, y, descriptor.Coordinates.Z);
                if (world.GetBlockID(coordinates) == CactusBlock.BlockID)
                {
                    world.SetBlockID(coordinates, AirBlock.BlockID);
                    toDrop++;
                }
            }

            var manager = server.GetEntityManagerForWorld(world);
            manager.SpawnEntity(
                new ItemEntity(descriptor.Coordinates + Coordinates3D.Up,
                    new ItemStack(CactusBlock.BlockID, (sbyte)toDrop)));
        }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:31,代码来源:CactusBlock.cs


示例12: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("crops", chunk,
         TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
         (s) => GrowBlock(s, world, coords));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:CropsBlock.cs


示例13: EventScheduler

 public EventScheduler(IMultiplayerServer server)
 {
     Events = new List<ScheduledEvent>();
     Server = server;
     Subjects = new HashSet<IEventSubject>();
     Stopwatch = new Stopwatch();
     Stopwatch.Start();
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:8,代码来源:EventScheduler.cs


示例14: BlockUpdate

 public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
 {
     if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) == AirBlock.BlockID)
     {
         world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
         server.GetEntityManagerForWorld(world).SpawnEntity(new FallingGravelEntity(descriptor.Coordinates));
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:8,代码来源:GravelBlock.cs


示例15: BlockUpdate

 public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
 {
     if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) != FarmlandBlock.BlockID)
     {
         GenerateDropEntity(descriptor, world, server);
         world.SetBlockID(descriptor.Coordinates, 0);
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:8,代码来源:CropsBlock.cs


示例16: ScheduleNextEvent

 public void ScheduleNextEvent(Coordinates3D coords, IWorld world, IMultiplayerServer server)
 {
     if (world.GetBlockID(coords) == StillID)
         return;
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("fluid", chunk,
         TimeSpan.FromSeconds(SecondsBetweenUpdates), (_server) =>
         AutomataUpdate(_server, world, coords));
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:9,代码来源:FluidBlock.cs


示例17: HandleChangeHeldItem

 public static void HandleChangeHeldItem(IPacket _packet, IRemoteClient _client, IMultiplayerServer server)
 {
     var packet = (ChangeHeldItemPacket)_packet;
     var client = (RemoteClient)_client;
     client.SelectedSlot = (short)(packet.Slot + InventoryWindow.HotbarIndex);
     var notified = server.GetEntityManagerForWorld(client.World).ClientsForEntity(client.Entity);
     foreach (var c in notified)
         c.QueuePacket(new EntityEquipmentPacket(client.Entity.EntityID, 0, client.SelectedItem.ID, client.SelectedItem.Metadata));
 }
开发者ID:const586,项目名称:TrueCraft,代码行数:9,代码来源:InteractionHandlers.cs


示例18: HandleChatMessage

 internal static void HandleChatMessage(IPacket _packet, IRemoteClient _client, IMultiplayerServer _server)
 {
     // TODO: Abstract this to support things like commands
     // TODO: Sanitize messages
     var packet = (ChatMessagePacket)_packet;
     var server = (MultiplayerServer)_server;
     var args = new ChatMessageEventArgs(_client, packet.Message);
     server.OnChatMessageReceived(args);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:9,代码来源:PacketHandlers.cs


示例19: EntityManager

 public EntityManager(IMultiplayerServer server, IWorld world)
 {
     Server = server;
     World = world;
     PhysicsEngine = new PhysicsEngine(world, (BlockRepository)server.BlockRepository);
     PendingDespawns = new ConcurrentBag<IEntity>();
     Entities = new List<IEntity>();
     // TODO: Handle loading worlds that already have entities
     // Note: probably not the concern of EntityManager. The server could manually set this?
     NextEntityID = 1;
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:11,代码来源:EntityManager.cs


示例20: IsSupported

 public virtual bool IsSupported(BlockDescriptor descriptor, IMultiplayerServer server, IWorld world)
 {
     var support = GetSupportDirection(descriptor);
     if (support != Coordinates3D.Zero)
     {
         var supportingBlock = server.BlockRepository.GetBlockProvider(world.GetBlockID(descriptor.Coordinates + support));
         if (!supportingBlock.Opaque)
             return false;
     }
     return true;
 }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:11,代码来源:BlockProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMvxBundle类代码示例发布时间:2022-05-24
下一篇:
C# IMultiPolygon类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap