Example #1
0
        private void updateRadar()
        {
            m_radar = null;
            if (cockpit.CustomName == null)
            {
                return;
            }
            string title = cockpit.CustomName;
            Regex  reg   = new Regex("(.*?)!(.*)");

            if (title == null || title.Length == 0)
            {
                return;
            }
            var res = reg.Split(title);

            if (res.Length > 2)
            {
                foreach (var word in res)
                {
                    Log.DebugWrite(DebugLevel.Info, word);
                }
                radarname = res[2].ToLowerInvariant().Trim();
            }
            else
            {
                return;                //nothing
            }
            system = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid((IMyCubeGrid)cockpit.CubeGrid);
            List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

            system.GetBlocksOfType <IMySensorBlock>(blocks, null);
            //getRadarValues();
            foreach (var block in blocks)
            {
                var sens = (IMySensorBlock)block;
                if (sens.OwnerId == cockpit.OwnerId)
                {
                    if (sens.CustomName.ToLowerInvariant().Trim() == radarname)
                    {
                        ent = sens.EntityId;
                        //ActiveAdjust = PrivateAdjust;
                        break;
                    }
                }
            }
            Log.DebugWrite(DebugLevel.Verbose, "Entityid " + ent.ToString());
            if (ent != 0)
            {
                m_radar = CoreHolo.GetRadar(ent);
            }
        }
Example #2
0
 private void calcComplete()
 {
     //MyAPIGateway.Utilities.ShowMessage("CalcDone", T_result.ColorData.Count.ToString());
     _result = new RadarResult(T_result);
     T_result.Clear();
     if (!Entity.MarkedForClose || Entity.Closed)
     {
         foreach (KeyValuePair <Vector3I, IMySensorBlock> pingblocks in pingResult)
         {
             var radar = CoreHolo.GetRadar(pingblocks.Value.EntityId);
             if (radar != null)
             {
                 radar.Notify(Term.WorldMatrix.Translation, Term);
             }
         }
         pingResult.Clear();
         //projection = p_grid;
     }
 }
Example #3
0
        public override void UpdateBeforeSimulation10()
        {
            if (Entity == null)
            {
                return;
            }
            if (panel == null)
            {
                return;
            }
            if (CoreHolo.instance == null)
            {
                return;
            }
            if (!valid)
            {
                return;
            }
            if (CoreHolo.instance.isDedicated)
            {
                //cleanProjections();
                return;
            }
            if (!panel.IsWorking)
            {
                //cleanProjections();
                return;
            }
            if (!CoreHolo.ClosetoPlayer(Entity.WorldMatrix.Translation, 30))
            {
                //cleanProjections();
                return;
            }
            long ent = 0;

            //refresh
            system = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid((IMyCubeGrid)panel.CubeGrid);
            List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

            system.GetBlocksOfType <IMySensorBlock>(blocks, null);
            getRadarValues();
            foreach (var block in blocks)
            {
                var sens = (IMySensorBlock)block;
                if (sens.OwnerId == panel.OwnerId)
                {
                    if (sens.CustomName.ToLowerInvariant().Trim() == privateradarid)
                    {
                        ent          = sens.EntityId;
                        ActiveAdjust = PrivateAdjust;
                        break;
                    }
                    if (sens.CustomName.ToLowerInvariant().Trim() == publicradarid)
                    {
                        //allow public title to get the entity id as well.
                        ActiveAdjust = PublicAdjust;
                        ent          = sens.EntityId;
                    }
                }
            }
            Log.DebugWrite(DebugLevel.Verbose, "Entityid " + ent.ToString());
            if (ent != 0)
            {
                var data = CoreHolo.GetRadar(ent);
                //MyAPIGateway.Utilities.ShowMessage("Radar?", (data?.RadarData == null).ToString());
                if (data != null && data.RadarData != null)
                {
                    color = data.RadarData.ColorData;
                    //MyAPIGateway.Utilities.ShowMessage("Count", color.Count.ToString());
                }
                else
                {
                    cleanDraws();
                }
            }
            else
            {
                cleanDraws();
            }
        }