Exemplo n.º 1
0
            public sortableLastSeen(Vector3D myPos, LastSeen seen, IMyCubeBlockExtensions.Relations relations)
            {
                this.seen      = seen;
                this.relations = relations;
                TimeSpan sinceLastSeen;

                predictedPos = seen.predictPosition(out sinceLastSeen);
                distance     = (int)(predictedPos - myPos).Length();
                seconds      = (int)sinceLastSeen.TotalSeconds;
            }
Exemplo n.º 2
0
        public static void doShowoff(IMyCubeBlock showoff, IEnumerator <LastSeen> toDisplay, int toDisplayCount)
        {
            LinkedList <Ingame.IMyTextPanel> textPanels = findTextPanel(showoff);

            if (textPanels == null)
            {
                return;
            }

            log("building toDisplay", "findTextPanel()", Logger.severity.TRACE);
            Vector3D myPos = showoff.GetPosition();
            List <sortableLastSeen> sortableSeen = new List <sortableLastSeen>();

            while (toDisplay.MoveNext())
            {
                IMyCubeGrid grid = toDisplay.Current.Entity as IMyCubeGrid;
                if (grid == null || AttachedGrids.isGridAttached(grid, showoff.CubeGrid))
                {
                    continue;
                }

                IMyCubeBlockExtensions.Relations relations = showoff.getRelationsTo(grid, IMyCubeBlockExtensions.Relations.Enemy).mostHostile();
                sortableSeen.Add(new sortableLastSeen(myPos, toDisplay.Current, relations));
            }
            sortableSeen.Sort();

            int           count       = 0;
            StringBuilder displayText = new StringBuilder();

            foreach (sortableLastSeen sortable in sortableSeen)
            {
                displayText.Append(sortable.ToStringBuilder(count++));
                if (count >= 50)
                {
                    break;
                }
            }

            string displayString = displayText.ToString();

            foreach (Ingame.IMyTextPanel panel in textPanels)
            {
                log("writing to panel: " + panel.DisplayNameText, "findTextPanel()", Logger.severity.TRACE);
                panel.WritePublicText(displayString);
                if (panel.GetPublicTitle() != publicTitle)
                {
                    panel.WritePublicTitle(publicTitle);
                    panel.AddImageToSelection(radarId);
                    panel.ShowTextureOnScreen();
                }
            }
        }
Exemplo n.º 3
0
        private void replaceEntityIdsWithLastSeen(string[] instructions)
        {
            if (!findAntenna())
            {
                return;
            }

            Vector3D      myPos   = myCubeBlock.GetPosition();
            int           count   = 0;
            StringBuilder newText = new StringBuilder();

            newText.Append(timeString);
            newText.Append(DateTime.Now.ToLongTimeString());
            writeTime = DateTime.Now;
            newText.Append('\n');
            for (int d = 1; d < instructions.Length; d++)             // skip first
            {
                if (string.IsNullOrWhiteSpace(instructions[d]))
                {
                    continue;
                }

                myLogger.debugLog("checking id: " + instructions[d], "replaceEntityIdsWithLastSeen()");
                long entityId = long.Parse(instructions[d]);
                //myLogger.debugLog("got long: " + entityId, "replaceEntityIdsWithLastSeen()");
                LastSeen seen;
                if (myAntenna.tryGetLastSeen(entityId, out seen))
                {
                    myLogger.debugLog("got last seen: " + seen, "replaceEntityIdsWithLastSeen()");
                    IMyCubeGrid cubeGrid = seen.Entity as IMyCubeGrid;
                    if (cubeGrid == null)
                    {
                        myLogger.log("cubeGrid from LastSeen is null", "replaceEntityIdsWithLastSeen()", Logger.severity.WARNING);
                        continue;
                    }
                    IMyCubeBlockExtensions.Relations relations = myCubeBlock.getRelationsTo(cubeGrid, IMyCubeBlockExtensions.Relations.Enemy).mostHostile();
                    newText.Append((new sortableLastSeen(myPos, seen, relations)).TextForPlayer(count++));
                    //myLogger.debugLog("append OK", "replaceEntityIdsWithLastSeen()");
                }
            }
            myTextPanel.WritePublicText(newText.ToString());
            myTextPanel.WritePublicTitle(publicTitle_fromProgramParsed);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Display text either for player or for program
        /// </summary>
        private void displayLastSeen()
        {
            bool   forProgram;
            string instruction = myCubeBlock.getInstructions();

            if (instruction == null)
            {
                return;
            }

            if (instruction.looseContains(command_forProgram))
            {
                if (sentToProgram && myTextPanel.GetPublicTitle() == publicTitle_forProgram && !string.IsNullOrWhiteSpace(myTextPanel.GetPublicText()))
                {
                    //myLogger.debugLog("public text is not clear", "displayLastSeen()");
                    runProgram();
                    return;
                }
                forProgram = true;
            }
            else if (instruction.looseContains(command_forPlayer))
            {
                forProgram = false;
            }
            else
            {
                return;
            }

            if (!findAntenna())
            {
                return;
            }

            IEnumerator <LastSeen> toDisplay = myAntenna.getLastSeenEnum();

            if (forProgram)
            {
                myLogger.debugLog("building display list for program", "informPlayer()", Logger.severity.TRACE);
            }
            else
            {
                myLogger.debugLog("building display list for player", "informPlayer()", Logger.severity.TRACE);
            }
            Vector3D myPos = myCubeBlock.GetPosition();
            List <sortableLastSeen> sortableSeen = new List <sortableLastSeen>();

            while (toDisplay.MoveNext())
            {
                IMyCubeGrid grid = toDisplay.Current.Entity as IMyCubeGrid;
                if (grid == null || AttachedGrids.isGridAttached(grid, myCubeBlock.CubeGrid))
                {
                    continue;
                }

                IMyCubeBlockExtensions.Relations relations = myCubeBlock.getRelationsTo(grid, IMyCubeBlockExtensions.Relations.Enemy).mostHostile();
                sortableSeen.Add(new sortableLastSeen(myPos, toDisplay.Current, relations));
            }
            sortableSeen.Sort();

            int           count       = 0;
            StringBuilder displayText = new StringBuilder();

            if (forProgram)
            {
                foreach (sortableLastSeen sortable in sortableSeen)
                {
                    displayText.Append(sortable.TextForProgram());
                }
            }
            else
            {
                displayText.Append(timeString);
                displayText.Append(DateTime.Now.ToLongTimeString());
                writeTime = DateTime.Now;
                displayText.Append('\n');
                foreach (sortableLastSeen sortable in sortableSeen)
                {
                    displayText.Append(sortable.TextForPlayer(count++));
                    if (count >= 50)
                    {
                        break;
                    }
                }
            }

            string displayString = displayText.ToString();

            myLogger.debugLog("writing to panel " + myTextPanel.DisplayNameText, "findTextPanel()", Logger.severity.TRACE);
            myTextPanel.WritePublicText(displayText.ToString());

            // set public title
            if (forProgram)
            {
                if (myTextPanel.GetPublicTitle() != publicTitle_forProgram)
                {
                    myTextPanel.WritePublicTitle(publicTitle_forProgram);
                    myTextPanel.AddImageToSelection(radarIconId);
                    //myTextPanel.ShowTextureOnScreen();
                }

                runProgram();
            }
            else
            if (myTextPanel.GetPublicTitle() != publicTitle_forPlayer)
            {
                myTextPanel.WritePublicTitle(publicTitle_forPlayer);
                myTextPanel.AddImageToSelection(radarIconId);
                //myTextPanel.ShowTextureOnScreen();
            }
        }