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


C# MyCubeGrid.GetFatBlocks方法代码示例

本文整理汇总了C#中Sandbox.Game.Entities.MyCubeGrid.GetFatBlocks方法的典型用法代码示例。如果您正苦于以下问题:C# MyCubeGrid.GetFatBlocks方法的具体用法?C# MyCubeGrid.GetFatBlocks怎么用?C# MyCubeGrid.GetFatBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sandbox.Game.Entities.MyCubeGrid的用法示例。


在下文中一共展示了MyCubeGrid.GetFatBlocks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollectRecieversFromGrid

 //Collects data recievers from single grid <playerId> has acces to
 private static void CollectRecieversFromGrid(MyCubeGrid grid, long playerId, HashSet<MyDataReceiver> output)
 {
     foreach (var block in grid.GetFatBlocks())
     {
         MyDataReceiver receiver;
         if (block.Components.TryGet<MyDataReceiver>(out receiver))
         {
             MyIDModule module;
             if ((block as IMyComponentOwner<MyIDModule>).GetComponent(out module))
             {
                 if ((block as MyTerminalBlock).HasPlayerAccess(playerId) && module.Owner != 0)
                     output.Add(receiver);
             }
         }
     }
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:17,代码来源:MyDataReceiver.cs

示例2: GetGridRadioReceivers

 public static HashSet<MyDataReceiver> GetGridRadioReceivers(MyCubeGrid grid, long playerId)
 {
     HashSet<MyDataReceiver> output = new HashSet<MyDataReceiver>();
     foreach (var block in grid.GetFatBlocks())
     {
         MyDataReceiver receiver;
         if (block.Components.TryGet<MyDataReceiver>(out receiver))
         {
             MyIDModule module;
             if ((block as IMyComponentOwner<MyIDModule>).GetComponent(out module))
             {
                 if ((block as MyTerminalBlock).HasPlayerAccess(playerId) && module.Owner != 0)
                     output.Add(receiver);
             }
         }
     }
     return output;
 }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:18,代码来源:MyDataReceiver.cs

示例3: CheckConcealBlockRules

        private static bool CheckConcealBlockRules( MyCubeGrid grid )
        {
            var blocks = grid.GetFatBlocks();

            int beaconCount = 0;

            var players = MySession.Static.Players.GetOnlinePlayers();

            foreach ( MyCubeBlock cubeBlock in blocks )
            {
                var beacon = cubeBlock as IMyBeacon;
                if ( beacon != null)
                {
                    //beaconCount++;
                    // Keep this return here, as 4 beacons always means true
                    //DON'T TELL ME WHAT TO DO
                    //if ( beaconCount >= 4 )
                    //{
                    //	return true;
                    //}

                    if ( !beacon.Enabled )
                        continue;

                    if ( players.Any( x => Vector3D.Distance( x.GetPosition(), beacon.GetPosition() ) < beacon.Radius ) )
                        return true;
                }

                var antenna = cubeBlock as IMyRadioAntenna;
                if ( antenna != null )
                {
                    if ( !antenna.Enabled )
                        continue;

                    if ( players.Any( x => Vector3D.Distance( x.GetPosition(), antenna.GetPosition() ) < antenna.Radius ) )
                        return true;
                }

                var medical = cubeBlock as IMyMedicalRoom;
                if ( medical != null )
                {
                    if ( !medical.Enabled )
                        continue;

                    if ( PluginSettings.Instance.DynamicConcealIncludeMedBays )
                    {
                        lock ( Online )
                        {
                            foreach ( ulong connectedPlayer in Online )
                            {
                                long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId( connectedPlayer );

                                if (medical.HasPlayerAccess(playerId))
                                    return true;
                            }
                        }
                    }
                    else
                    {
                        return true;
                    }
                }

                var cryo = cubeBlock as MyCryoChamber;
                if ( cryo?.Pilot != null )
                    return true;

                var production = cubeBlock as IMyProductionBlock;
                if ( production != null && PluginSettings.Instance.DynamicConcealProduction )
                {
                    if ( !production.Enabled )
                        continue;

                    if ( !production.IsQueueEmpty )
                        return true;
                }

                if ( PluginSettings.Instance.DynamicConcealIgnoreSubTypeList.Any( subType => cubeBlock.BlockDefinition.Id.SubtypeName.Contains( subType ) ) )
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:rexxar-tc,项目名称:EssentialsPlugin,代码行数:85,代码来源:EntityManagement.cs

示例4: CheckRevealBlockRules

        private static bool CheckRevealBlockRules( MyCubeGrid grid, out string reason )
        {
            reason = "";

            var players = MySession.Static.Players.GetOnlinePlayers();

            foreach ( var cubeBlock in grid.GetFatBlocks() )
            {
                var beacon = cubeBlock as IMyBeacon;
                if ( beacon != null )
                {
                    if ( !beacon.Enabled )
                        continue;

                    foreach ( var player in players )
                    {
                        var distance = Vector3D.Distance( player.GetPosition(), beacon.GetPosition() );

                        if ( distance < beacon.Radius )
                        {
                            reason = $"{player.DisplayName} distance to beacon broadcast: {distance}";
                            return true;
                        }
                    }
                }

                var antenna = cubeBlock as IMyRadioAntenna;
                if ( antenna != null )
                {
                    if ( !antenna.Enabled )
                        continue;

                    foreach ( var player in players )
                    {
                        var distance = Vector3D.Distance( player.GetPosition(), antenna.GetPosition() );

                        if ( distance < antenna.Radius )
                        {
                            reason = $"{player.DisplayName} distance to antenna broadcast: {distance}";
                            return true;
                        }
                    }
                }

                var medical = cubeBlock as IMyMedicalRoom;
                if ( medical != null )
                {
                    if ( !medical.Enabled || !medical.IsFunctional )
                        continue;

                    if ( PluginSettings.Instance.DynamicConcealIncludeMedBays )
                    {
                        lock ( Online )
                        {
                            foreach ( ulong connectedPlayer in Online )
                            {
                                long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId( connectedPlayer );

                                if ( medical.OwnerId == playerId )
                                {
                                    reason = $"Grid has medbay and player is logged in - playerid: {playerId}";
                                    return true;
                                }

                                if ( medical.HasPlayerAccess( playerId ) )
                                {
                                    reason = $"Grid has medbay and player has access - playerid: {playerId}";
                                    return true;
                                }
                            }
                        }
                    }
                    else
                    {
                        reason = "Grid has medbay and conceal can not include medbays";
                        return true;
                    }
                }

                var cryo = cubeBlock as MyCryoChamber;
                if ( cryo != null )
                {
                    if ( cryo.Pilot == null )
                        continue;

                    if ( !cryo.IsFunctional )
                        continue;

                    reason = $"Grid has cryopod and player is inside - player: {cryo.Pilot.DisplayName}";
                    return true;
                }

                //don't check conceal settings for production blocks, we always want them to reveal
                var production = cubeBlock as MyProductionBlock;
                if ( production != null )
                {
                    if ( !production.Enabled )
                        continue;

                    if ( !production.IsQueueEmpty )
//.........这里部分代码省略.........
开发者ID:rexxar-tc,项目名称:EssentialsPlugin,代码行数:101,代码来源:EntityManagement.cs

示例5: DoesGridHavePowerSupply

 public static bool DoesGridHavePowerSupply( MyCubeGrid grid )
 {
     return grid.GetFatBlocks(  ).Any( DoesBlockSupplyPower );
 }
开发者ID:rexxar-tc,项目名称:EssentialsPlugin,代码行数:4,代码来源:CubeGrid.cs


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