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


C# Multiplayer.MySyncGrid类代码示例

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


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

示例1: OnThrustTorqueReceived

        private static void OnThrustTorqueReceived(MySyncGrid sync, ref ThrustAndTorqueMsg msg, MyNetworkClient sender)
        {
            sender.ClientFrameId = msg.ClientFrameId;

            //if (false)
            {
                sync.Entity.GridSystems.ThrustSystem.ControlThrust = msg.Thrust;
                sync.Entity.GridSystems.GyroSystem.ControlTorque = msg.Torque;
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:10,代码来源:MySyncGrid.cs

示例2: OnColorBlocksRequest

        private static void OnColorBlocksRequest(MySyncGrid sync, ref ColorBlocksMsg msg, MyNetworkClient sender)
        {
            var handler = sync.BlocksColored;
            if (handler != null) handler(msg.Min, msg.Max, ColorExtensions.UnpackHSVFromUint(msg.HSV), msg.PlaySound);

            if (Sync.IsServer)
            {
                // Broadcast to clients, use result collection
                Sync.Layer.SendMessageToAll(ref msg);
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:11,代码来源:MySyncGrid.cs

示例3: OnBonesReceived

        private static void OnBonesReceived(MySyncGrid sync, ref BonesMsg msg, MyNetworkClient sender)
        {
            sync.Entity.Skeleton.DeserializePart(msg.MinBone, msg.MaxBone, sync.Entity.GridSize, msg.Bones);

            Vector3I minCube = Vector3I.Zero;
            Vector3I maxCube = Vector3I.Zero;

            // To hit incident cubes
            Vector3I min = msg.MinBone;// -Vector3I.One;
            Vector3I max = msg.MaxBone;// +Vector3I.One;

            sync.Entity.Skeleton.Wrap(ref minCube, ref min);
            sync.Entity.Skeleton.Wrap(ref maxCube, ref max);

            minCube -= Vector3I.One;
            maxCube += Vector3I.One;

            Vector3I pos;
            for (pos.X = minCube.X; pos.X <= maxCube.X; pos.X++)
            {
                for (pos.Y = minCube.Y; pos.Y <= maxCube.Y; pos.Y++)
                {
                    for (pos.Z = minCube.Z; pos.Z <= maxCube.Z; pos.Z++)
                    {
                        sync.Entity.SetCubeDirty(pos);
                    }
                }
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:29,代码来源:MySyncGrid.cs

示例4: OnBuildBlocksAreaSuccess

        private static void OnBuildBlocksAreaSuccess(MySyncGrid sync, ref BuildBlocksAreaSuccessMsg successMsg, MyNetworkClient sender)
        {
            Debug.Assert(sync.BlocksBuiltAreaSuccess != null, "Handler should not be null, build messages will be ignored!");

            var handler = sync.BlocksBuiltAreaSuccess;
            if (handler != null) handler(ref successMsg.Area, successMsg.EntityIdSeed, successMsg.FailList, successMsg.OwnerId);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:MySyncGrid.cs

示例5: OnRazeBlocksAreaSuccess

        private static void OnRazeBlocksAreaSuccess(MySyncGrid sync, ref RazeBlocksAreaSuccessMsg successMsg, MyNetworkClient sender)
        {
            Debug.Assert(sync.BlocksRazeAreaSuccess != null, "Handler should not be null, Raze messages will be ignored!");

            var handler = sync.BlocksRazeAreaSuccess;
            if (handler != null) handler(ref successMsg.Pos, ref successMsg.Size, successMsg.FailList);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:MySyncGrid.cs

示例6: OnRemoveSplit

        private static void OnRemoveSplit(MySyncGrid grid, ref RemoveSplitMsg msg, MyNetworkClient sender)
        {
            MyCubeGrid m_grid;
            if (MyEntities.TryGetEntityById(msg.GridEntityId, out m_grid))
            {
                m_tmpBlockListReceive.Clear();
                foreach (var position in msg.RemovedBlocks)
                {
                    var block = m_grid.GetCubeBlock(position);
                    Debug.Assert(block != null, "Block was null when trying to remove a grid split. Desync?");
                    if (block == null)
                    {
                        MySandboxGame.Log.WriteLine("Block was null when trying to remove a grid split. Desync?");
                        continue;
                    }

                    m_tmpBlockListReceive.Add(block);
                }

                MyCubeGrid.RemoveSplit(m_grid, m_tmpBlockListReceive, 0, m_tmpBlockListReceive.Count, sync: false);
                m_tmpBlockListReceive.Clear();
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:23,代码来源:MySyncGrid.cs

示例7: OnBuildBlockRequest

        private static void OnBuildBlockRequest(MySyncGrid sync, ref BuildBlockMsg msg, MyNetworkClient sender)
        {
            MyCubeGrid.MyBlockLocation? builtBlock = null;

            MyEntity builder = null;
            MyEntities.TryGetEntityById(msg.BuilderEntityId, out builder);

            var buildHandler = sync.BlockBuilt;
            if (buildHandler != null) buildHandler(ColorExtensions.UnpackHSVFromUint(msg.ColorMaskHsv), msg.Location, msg.BlockObjectBuilder, ref builtBlock, builder);
            
            if (Sync.IsServer)
            {
                Sync.Layer.SendMessageToAll(ref msg);
            }
            
            var afterHandler = sync.AfterBlockBuilt;
            if (afterHandler != null && builtBlock != null) afterHandler(builtBlock.Value);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:18,代码来源:MySyncGrid.cs

示例8: OnModifyGroupSuccess

 private static void OnModifyGroupSuccess(MySyncGrid sync, ref ModifyBlockGroupMsg msg, MyNetworkClient sender)
 {
     if (msg.Blocks == null || msg.Blocks.Count() == 0)
         foreach (var group in sync.Entity.BlockGroups)
         {
             if (group.Name.ToString().Equals(msg.Name))
             {
                 sync.Entity.RemoveGroup(group);
                 break;
             }
         }
     else
     {
         MyBlockGroup group = new MyBlockGroup(sync.Entity);
         group.Name.Clear().Append(msg.Name);
         foreach (var blockId in msg.Blocks)
         {
             MyTerminalBlock block = null;
             if (MyEntities.TryGetEntityById(blockId, out block))
                 group.Blocks.Add(block);
         }
         sync.Entity.AddGroup(group);
     }
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:24,代码来源:MySyncGrid.cs

示例9: OnConvertedToShipRequest

        private static void OnConvertedToShipRequest(MySyncGrid sync, ref ConvertToShipMsg msg, MyNetworkClient sender)
        {
            if (!sync.Entity.IsStatic)
            {
                Debug.Assert(false, "Grid was not static!");
                return;
            }

            if (Sync.IsServer)
                Sync.Layer.SendMessageToAllAndSelf(ref msg, MyTransportMessageEnum.Success);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:11,代码来源:MySyncGrid.cs

示例10: OnStockpileFillRequest

        private static void OnStockpileFillRequest(MySyncGrid sync, ref StockpileFillRequestMsg msg, MyNetworkClient sender)
        {
            var block = sync.Entity.GetCubeBlock(msg.BlockPosition);
            Debug.Assert(block != null, "Could not find block whose stockpile fill was requested");
            if (block == null) return;

            MyEntity ownerEntity = null;
            if (!MyEntities.TryGetEntityById(msg.OwnerEntityId, out ownerEntity))
            {
                Debug.Assert(false, "Stockpile fill inventory owner entity was null");
                return;
            }

            var owner = (ownerEntity as IMyInventoryOwner);
            Debug.Assert(owner != null, "Stockpile fill inventory owner was not an inventory owner");

            var inventory = owner.GetInventory(msg.InventoryIndex);
            Debug.Assert(inventory != null, "Stockpile fill inventory owner did not have the given inventory");

            block.MoveItemsToConstructionStockpile(inventory);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:21,代码来源:MySyncGrid.cs

示例11: OnSetToConstructionRequest

        private static void OnSetToConstructionRequest(MySyncGrid sync, ref SetToConstructionRequestMsg msg, MyNetworkClient sender)
        {
            var block = sync.Entity.GetCubeBlock(msg.BlockPosition);
            Debug.Assert(block != null, "Could not find block to set to construction site");
            if (block == null) return;

            block.SetToConstructionSite();

            MyEntity ownerEntity = null;
            if (!MyEntities.TryGetEntityById(msg.OwnerEntityId, out ownerEntity))
            {
                Debug.Assert(false, "Set to construction site inventory owner entity was null");
                return;
            }

            var owner = (ownerEntity as IMyInventoryOwner);
            Debug.Assert(owner != null, "Set to construction site inventory owner was not an inventory owner");

            var inventory = owner.GetInventory(msg.InventoryIndex);
            Debug.Assert(inventory != null, "Set to construction site inventory owner did not have the given inventory");

            block.MoveItemsToConstructionStockpile(inventory);
            block.IncreaseMountLevel(MyWelder.WELDER_AMOUNT_PER_SECOND * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS, msg.RequestingPlayer);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:24,代码来源:MySyncGrid.cs

示例12: OnStockpileChanged

 private static void OnStockpileChanged(MySyncGrid sync, ref StockpileChangedMsg msg, MyNetworkClient sender)
 {
     if (sync.BlockStockpileChanged != null)
         sync.BlockStockpileChanged(msg.BlockPosition, msg.SubBlockId, msg.Changes);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:5,代码来源:MySyncGrid.cs

示例13: OnIntegrityChanged

 private static void OnIntegrityChanged(MySyncGrid sync, ref IntegrityChangedMsg msg, MyNetworkClient sender)
 {
     if (sync.BlockIntegrityChanged != null)
         sync.BlockIntegrityChanged(msg.BlockPosition, msg.SubBlockId, msg.BuildIntegrity, msg.Integrity, msg.IntegrityChangeType, msg.ToolOwner);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:5,代码来源:MySyncGrid.cs

示例14: OnThrustReceived

 private static void OnThrustReceived(MySyncGrid sync, ref ThrustMsg msg, MyNetworkClient sender)
 {
     sync.Entity.GridSystems.ThrustSystem.ControlThrust = msg.Thrust;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:4,代码来源:MySyncGrid.cs

示例15: OnChangeDisplayName

 private static void OnChangeDisplayName(MySyncGrid grid, ref ChangeDisplayNameMsg msg, MyNetworkClient sender)
 {
     MyCubeGrid m_grid;
     if (MyEntities.TryGetEntityById(msg.GridEntityId, out m_grid))
         m_grid.DisplayName = msg.DisplayName;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:6,代码来源:MySyncGrid.cs


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