示例#1
0
        public void UpdateBroadcastersInRange(HashSet <MyDataBroadcaster> relayedBroadcasters, long localPlayerId, HashSet <long> gridsQueued)
        {
            m_broadcastersInRange.Clear();

            if (!MyFakes.ENABLE_RADIO_HUD || !Enabled)
            {
                return;
            }

            VRage.ProfilerShort.Begin("Relay");
            MyDataBroadcaster radioBroadcaster;

            if (Entity.Components.TryGet <MyDataBroadcaster>(out radioBroadcaster))
            {
                relayedBroadcasters.Add(radioBroadcaster);
            }
            VRage.ProfilerShort.End();

            VRage.ProfilerShort.Begin("UpdateBroadcasters");
            //add all from same grid:
            MyCubeGrid grid = Entity.GetTopMostParent() as MyCubeGrid;

            if (grid != null && !gridsQueued.Contains(grid.EntityId)) //astronaut has no grid
            {
                gridsQueued.Add(grid.EntityId);
                foreach (var block in grid.GetFatBlocks())
                {
                    MyDataBroadcaster broadcaster;
                    if (block.Components.TryGet <MyDataBroadcaster>(out broadcaster))
                    {
                        MyIDModule module;
                        if ((block as IMyComponentOwner <MyIDModule>).GetComponent(out module))
                        {
                            if ((block as MyTerminalBlock).HasPlayerAccess(localPlayerId) && module.Owner != 0 &&
                                !relayedBroadcasters.Contains(broadcaster))
                            {
                                relayedBroadcasters.Add(broadcaster);
                                if (!CanIUseIt(broadcaster, localPlayerId))
                                {
                                    continue;
                                }
                                MyDataReceiver radioReceiver;
                                if (broadcaster.Container.TryGet <MyDataReceiver>(out radioReceiver))
                                {
                                    VRage.ProfilerShort.Begin("UpdateReceiver");
                                    radioReceiver.UpdateBroadcastersInRange(relayedBroadcasters, localPlayerId, gridsQueued);
                                    VRage.ProfilerShort.End();
                                }
                            }
                        }
                    }
                }
            }
            VRage.ProfilerShort.End();

            VRage.ProfilerShort.Begin("GetAllBroadcastersInMyRange");
            GetAllBroadcastersInMyRange(ref relayedBroadcasters, localPlayerId, gridsQueued);
            VRage.ProfilerShort.End();
        }
示例#2
0
 //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);
             }
         }
     }
 }
示例#3
0
        private static MyTerminalBlock GetRemoteConrolForGrid(MyCubeGrid cubeGrid)
        {
            if (cubeGrid.HasMainRemoteControl())
            {
                return(cubeGrid.MainRemoteControl);
            }
            MyFatBlockReader <MyRemoteControl> fatBlocks = cubeGrid.GetFatBlocks <MyRemoteControl>();

            if (!fatBlocks.MoveNext())
            {
                return(null);
            }
            MyRemoteControl current = fatBlocks.Current;

            return(fatBlocks.MoveNext() ? null : current);
        }
示例#4
0
 //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))
             {
                 //AB in broadcast window I need to access to all antenas in range
                 //if ((block as MyTerminalBlock).HasPlayerAccess(playerId) && module.Owner != 0)
                 output.Add(receiver);
             }
         }
     }
 }
示例#5
0
 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;
 }
        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);
        }
示例#7
0
        public void UpdateBroadcastersInRange(HashSet <MyDataBroadcaster> relayedBroadcasters, long localPlayerId, HashSet <long> gridsQueued)
        {
            m_broadcastersInRange.Clear();

            if (!MyFakes.ENABLE_RADIO_HUD || !Enabled)
            {
                return;
            }

            if (Parent is IMyComponentOwner <MyDataBroadcaster> )
            {
                MyDataBroadcaster radioBroadcaster;
                if ((Parent as IMyComponentOwner <MyDataBroadcaster>).GetComponent(out radioBroadcaster))
                {
                    relayedBroadcasters.Add(radioBroadcaster);
                }
            }

            //add all from same grid:
            MyCubeGrid grid = Parent.GetTopMostParent() as MyCubeGrid;

            if (grid != null && //astronaut has no grid
                !gridsQueued.Contains(grid.EntityId))
            {
                gridsQueued.Add(grid.EntityId);
                foreach (var block in grid.GetFatBlocks <MyCubeBlock>())
                {
                    if (block is IMyComponentOwner <MyDataBroadcaster> )
                    {
                        MyDataBroadcaster broadcaster;
                        if ((block as IMyComponentOwner <MyDataBroadcaster>).GetComponent(out broadcaster))
                        {
                            MyIDModule module;
                            if ((block as IMyComponentOwner <MyIDModule>).GetComponent(out module))
                            {
                                if ((block as MyTerminalBlock).HasPlayerAccess(localPlayerId) && module.Owner != 0 &&
                                    !relayedBroadcasters.Contains(broadcaster))
                                {
                                    relayedBroadcasters.Add(broadcaster);
                                    if (!CanIUseIt(broadcaster, localPlayerId))
                                    {
                                        continue;
                                    }
                                    if (broadcaster.Parent is IMyComponentOwner <MyDataReceiver> )
                                    {
                                        MyDataReceiver radioReceiver;
                                        if ((broadcaster.Parent as IMyComponentOwner <MyDataReceiver>).GetComponent(out radioReceiver))
                                        {
                                            radioReceiver.UpdateBroadcastersInRange(relayedBroadcasters, localPlayerId, gridsQueued);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //
            GetAllBroadcastersInMyRange(ref relayedBroadcasters, localPlayerId, gridsQueued);
        }
        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 )
                    {
                        reason = "Grid has production facility that has a queue";
                        return true;
                    }
                }
            }

            return false;
        }
        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;
        }
示例#10
0
 public static bool DoesGridHavePowerSupply( MyCubeGrid grid )
 {
     return grid.GetFatBlocks(  ).Any( DoesBlockSupplyPower );
 }