예제 #1
0
        private void getRadarValues()
        {
            var privatetitle = panel.CustomData;
            var publictitle  = panel.GetPublicTitle();

            try
            {
                HoloSetting PlayerAdjust;
                privateradarid = parseSettingsString(privatetitle, out PlayerAdjust);
                PrivateAdjust  = PlayerAdjust;
                publicradarid  = parseSettingsString(publictitle, out PlayerAdjust);
                PublicAdjust   = PlayerAdjust;
            }
            catch
            {
                //do nothing.
            }
        }
예제 #2
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();
            }
        }
예제 #3
0
        private string parseSettingsString(string title, out HoloSetting Adjust)
        {
            //Log.DebugWrite(DebugLevel.Info, "parseSettingsString");
            HoloSetting adj        = new HoloSetting();
            Regex       reg        = new Regex("(.*?)\\[(.*?)\\]");
            Regex       regcom     = new Regex(";");
            Regex       regeq      = new Regex("=");
            string      foundtitle = "";

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

            //Log.DebugWrite(DebugLevel.Info, res.Length);
            if (res.Length > 2)
            {
                foreach (var word in res)
                {
                    Log.DebugWrite(DebugLevel.Info, word);
                }
                foundtitle = res[1];
                //Log.DebugWrite(DebugLevel.Info, "settings:" + res[2]);
                var search = regcom.Split(res[2]);
                if (search == null)
                {
                    return(foundtitle.ToLowerInvariant().Trim());
                }
                foreach (string parts in search)
                {
                    var dataeq = regeq.Split(parts);
                    if (dataeq.Length == 0)
                    {
                        continue;
                    }
                    try
                    {
                        switch (dataeq[0].ToLower())
                        {
                        case "u":
                        case "up":
                        case "offsetup":
                            Adjust.U = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;

                        case "d":
                        case "down":
                        case "offsetdown":
                            Adjust.D = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;

                        case "l":
                        case "left":
                        case "offsetleft":
                            Adjust.L = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;

                        case "r":
                        case "right":
                        case "offsetright":
                            Adjust.R = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;

                        case "f":
                        case "forward":
                        case "offsetforward":
                            Adjust.F = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;

                        case "b":
                        case "backward":
                        case "offsetbackward":
                            Adjust.B = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;

                        case "s":
                        case "scale":
                            Adjust.S = Convert.ToDouble(dataeq[1], new CultureInfo("en-US"));
                            break;
                        }
                    }
                    catch
                    {
                        //catching stupid.
                    }
                }
            }
            else
            if (res.Length >= 1)
            {
                foundtitle = res[0];
            }
            return(foundtitle.ToLowerInvariant().Trim());
        }