Пример #1
0
 public Nav RightNav(string activeIdentifier, NavSettings settings = null)
 {
     settings             = settings ?? new NavSettings();
     settings.Style       = NavStyle.Navbar;
     settings.NavbarRight = true;
     return(new Nav(_writer, activeIdentifier, settings));
 }
Пример #2
0
            /// <summary>
            /// be sure to get a new one after a reset, CNS changes will not be respected
            /// </summary>
            /// <param name="stopFromDestGrid">how close to centreDestination grid to stop, if centreDestination is a grid</param>
            /// <returns></returns>
            public CollisionAvoidance(ref NavSettings CNS, GridDimensions gridDims)
            {
                VRage.Exceptions.ThrowIf <ArgumentNullException>(CNS == null, "CNS");
                VRage.Exceptions.ThrowIf <ArgumentNullException>(gridDims == null, "gridDims");

                this.CNS             = CNS;
                this.wayDest         = (Vector3D)CNS.getWayDest();
                this.myGridDims      = gridDims;
                this.ignoreAsteroids = CNS.ignoreAsteroids;
                myLogger             = new Logger(gridDims.myGrid.DisplayName, "CollisionAvoidance");

                // decide whether to use collision avoidance or slowdown
                switch (CNS.getTypeOfWayDest())
                {
                case NavSettings.TypeOfWayDest.BLOCK:
                case NavSettings.TypeOfWayDest.GRID:
                    // run slowdown. see Navigator.calcMoveAndRotate()
                    this.destGrid = CNS.CurrentGridDest.Grid;
                    break;

                case NavSettings.TypeOfWayDest.LAND:
                default:
                    if (CNS.landingState != NavSettings.LANDING.OFF && CNS.CurrentGridDest != null)
                    {
                        this.destGrid = CNS.CurrentGridDest.Grid;
                    }
                    break;
                }

                log(myLogger, "created CollisionAvoidance", ".ctor()", Logger.severity.TRACE);
                currentStage = stage.S0_start;
            }
Пример #3
0
        private void readFromFile()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(NavSettings));

            using (FileStream stream = File.OpenRead(c_strXmlPath))
            {
                c_objNavSettings = (NavSettings)serializer.Deserialize(stream);
            }
        }
Пример #4
0
        internal void Run(NavSettings CNS, IMyCubeBlock NavigationBlock)
        {
            Vector3D destination     = (Vector3D)CNS.getWayDest(false);
            Vector3D?waypoint        = CNS.myWaypoint;
            bool     ignoreAsteroids = CNS.ignoreAsteroids;

            NavSettings.SpecialFlying SpecialFyingInstructions = CNS.SpecialFlyingInstructions;
            if (waypoint == destination)
            {
                waypoint = null;
            }

            // if something has changed, interrupt previous
            if (this.Destination != destination || this.Waypoint != waypoint || this.NavigationBlock != NavigationBlock || this.IgnoreAsteroids != ignoreAsteroids || this.SpecialFyingInstructions != SpecialFyingInstructions || myOutput == null)
            {
                if (myPathChecker != null)
                {
                    myPathChecker.Interrupt = true;
                }
                this.CNS                      = CNS;
                this.Destination              = destination;
                this.Waypoint                 = waypoint;
                this.NavigationBlock          = NavigationBlock;
                this.IgnoreAsteroids          = ignoreAsteroids;
                this.SpecialFyingInstructions = SpecialFyingInstructions;

                // decide whether to use collision avoidance or slowdown
                this.DestGrid = null;
                switch (CNS.getTypeOfWayDest())
                {
                case NavSettings.TypeOfWayDest.BLOCK:
                case NavSettings.TypeOfWayDest.GRID:
                    // run slowdown. see Navigator.calcMoveAndRotate()
                    this.DestGrid = CNS.CurrentGridDest.Grid;
                    break;

                case NavSettings.TypeOfWayDest.LAND:
                default:
                    if (CNS.landingState != NavSettings.LANDING.OFF && CNS.CurrentGridDest != null)
                    {
                        this.DestGrid = CNS.CurrentGridDest.Grid;
                    }
                    break;
                }
            }

            // not a race, this function is only called from one thread
            if (DateTime.UtcNow < nextRun)
            {
                return;
            }
            nextRun = DateTime.MaxValue;

            PathFinderThread.EnqueueAction(Wrapper_CheckPath);
        }
Пример #5
0
        public collisionAvoidResult avoidCollisions(ref NavSettings CNS, long updateCount, byte tryCount = 10)
        {
            //log("entered avoidCollisions update: "+updateCount);
            if (updateCount < nextUpdate)
            {
                return(collisionAvoidResult.NOT_PERFORMED);
            }
            if (myCA == null || nextUpdate != updateCount)
            {
                //log("update should be " + (lastUpdate + 1) + " is " + updateCount);
                this.CNS = CNS;
                myCA     = new CollisionAvoidance(ref CNS, myGridDim);             //(ref CNS, myRC, collisionLength, distance_from_RC_to_front, lengthOfGrid);
            }
            collisionAvoidResult result;

            if (!myCA.next(out result))
            {
                // will end up here after NO_COLLISION
                if (tryCount <= 0)
                {
                    myLogger.log(Logger.severity.ERROR, "avoidCollisions", "Error: too many tries", "avoidCollisions(CNS, " + updateCount + ", " + tryCount + ")");
                    nextUpdate = updateCount + 10;
                    return(collisionAvoidResult.NO_WAY_FORWARD);
                }
                myCA = null;
                return(avoidCollisions(ref CNS, updateCount, (byte)(tryCount - 1)));
            }
            if (result == collisionAvoidResult.NO_WAY_FORWARD)
            {
                nextUpdate = updateCount + 10;
                myCA       = null;
            }
            else
            {
                nextUpdate = updateCount + 1;
            }
            //log("time to avoidCollisions: " + (DateTime.UtcNow - startOfMethod).TotalMilliseconds+" spheres checked: "+spheresChecked);
            return(result);
        }
Пример #6
0
        public MainPage()
        {
            MAINPAGE = this;

            ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.BackgroundColor               = Colors.Black;
            titleBar.ForegroundColor               = Colors.White;
            titleBar.ButtonBackgroundColor         = Colors.Black;
            titleBar.ButtonForegroundColor         = Colors.White;
            titleBar.InactiveBackgroundColor       = Colors.Black;
            titleBar.InactiveForegroundColor       = App.Colors.BUTTON_CLICK.Color;
            titleBar.ButtonInactiveBackgroundColor = Colors.Black;
            titleBar.ButtonHoverBackgroundColor    = App.Colors.BUTTON_IDLE_LEFT.Color;
            titleBar.ButtonHoverForegroundColor    = Colors.White;

            InitializeComponent();
            NavCharacter.SetPageType(PageType.CHARACTER);
            NavBase.SetPageType(PageType.BASE);
            NavCombat.SetPageType(PageType.COMBAT);
            NavSkills.SetPageType(PageType.SKILLS);
            NavFeats.SetPageType(PageType.FEATS);
            NavInventory.SetPageType(PageType.INVENTORY);
            NavSpells.SetPageType(PageType.SPELLS);
            NavParty.SetPageType(PageType.PARTY);
            NavSettings.SetPageType(PageType.SETTINGS);
            NavSettings1.SetPageType(PageType.SETTINGS);

            NewCharacter.SetLoadType(LoadType.NEW);
            LoadCharacter.SetLoadType(LoadType.LOAD);
            DeleteCharacter.SetLoadType(LoadType.DELETE);
            SortOptions.SetLoadType(LoadType.SORT);
            NavCharactersMenu.SetLoadType(LoadType.MENU);

            LoadCharacters();

            //ChangePage(NavCharacter);
        }
        static void HandleCompletePath(ComponentDataFromEntity <LocalToWorld> localToWorldFromEntity, Entity entity, Rotation rotation, ref NavAgent agent, Parent surface, Translation translation, PhysicsWorld physicsWorld, float elapsedSeconds, EntityCommandBuffer.ParallelWriter commandBuffer, int entityInQueryIndex, NavSettings settings)
        {
            var rayInput = new RaycastInput
            {
                Start  = localToWorldFromEntity[entity].Position + agent.Offset,
                End    = math.forward(rotation.Value) * settings.ObstacleRaycastDistanceMax,
                Filter = new CollisionFilter
                {
                    BelongsTo    = NavUtil.ToBitMask(settings.ColliderLayer),
                    CollidesWith = NavUtil.ToBitMask(settings.ObstacleLayer)
                }
            };

            if (
                !surface.Value.Equals(agent.DestinationSurface) &&
                !NavUtil.ApproxEquals(translation.Value, agent.LocalDestination, settings.StoppingDistance) &&
                !physicsWorld.CastRay(rayInput, out _)
                )
            {
                agent.JumpSeconds = elapsedSeconds;

                commandBuffer.RemoveComponent <NavWalking>(entityInQueryIndex, entity);
                commandBuffer.RemoveComponent <NavSteering>(entityInQueryIndex, entity);
                commandBuffer.AddComponent <NavJumping>(entityInQueryIndex, entity);
                commandBuffer.AddComponent <NavPlanning>(entityInQueryIndex, entity);

                return;
            }

            commandBuffer.RemoveComponent <NavWalking>(entityInQueryIndex, entity);
            commandBuffer.RemoveComponent <NavSteering>(entityInQueryIndex, entity);
            commandBuffer.RemoveComponent <NavDestination>(entityInQueryIndex, entity);
        }
Пример #8
0
 public Nav RightNav(NavSettings settings = null)
 {
     return(RightNav(null, settings));
 }
Пример #9
0
 public Nav Nav(NavSettings settings = null)
 {
     return(Nav(null, settings));
 }
Пример #10
0
 //This constructor is used to show tiles when clicked on button
 public PromotedLinkListClass(NavSettings m_objNavSettings, int m_intActiveButton)
 {
     c_intActiveButton = m_intActiveButton;
     c_objPackage      = m_objNavSettings.c_objPackList[c_intActiveButton];
 }