Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

  • Sign in to follow this  

    Pather & general ideas for WRobot classes / profiles


    reapler
    • Version: All Product: WRobot General Type: Suggestion Status: Not Added

    I would like to suggest to add a continent name as a new parameter to the class "Grinderzone" it would allow to easier travelling between continents & taking the right path.

    At the current state of the Grinder product for example it doesn't check the continent and taking vectors from a different continent. I've also written methods to check whether vector is on continent by Z axis:

            /// <summary>
            /// Load specific tiles to define the pather by the given location.
            /// </summary>
            /// <param name="from">The location.</param>
            /// <param name="maxDistance">The maximum allowed z-distance.</param>
            public Pather GetPatherByLocation(Vector3 from, float maxDistance = float.PositiveInfinity)
            {
                float d = float.PositiveInfinity;
                Pather p = null;
                try
                {
                    Pather pc = null;
                    Logging.log("Load tiles to define continent...");
                    foreach (MainContinents continent in Enum.GetValues(typeof(MainContinents)))
                    {
                        pc = GetPather(from, continent);
                        if (Math.Abs(pc.FindZ(from) - from.Z) < d)
                        {
                            p = pc;
                            d = Math.Abs(p.FindZ(from) - from.Z);
                        }
                        pc.Dispose();
                    }
                    if (d < maxDistance)
                    {
                        Logging.log("Pather for " + from + " found\nContinent: " + p.Continent + "\nDeviation: " + d);
                        return p;
                    }
                }
                catch (Exception ex)
                {
                    Logging.logex("GetPatherByLocation(...):\n" + ex);
                }
                Logging.log("GetPatherByLocation(...) failed to load suitable continent: " + d + " < " + maxDistance + " is invalid.\nSuspected continent: " + p.Continent);
                return GetPather(from, Usefuls.ContinentNameMpq);
            }
                  
                  
                  
                  
                  
            /// <summary>
            /// Initialize new pather.
            /// </summary>
            /// <param name="loc">Initial location.</param>
            /// <param name="continent">Pather's continent.</param>
            public Pather GetPather(Vector3 loc, MainContinents continent)
            {
                try
                {
                    if (loc != Vector3.Empty)
                    {
                        float x1;
                        float y1;
                        return new Pather(continent.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Logging.logex("GetPather(Vector3 loc, MainContinents continent):\nContinent: " + continent + "\nLocation: " + loc + "\nThrow an Exception:\n" + ex);
                }
                Logging.log("GetPather(Vector3 loc, MainContinents continent) failed to load desired continent: " + Usefuls.ContinentNameMpq);
                return new Pather(Usefuls.ContinentNameMpq);
            }

    It works so far (i can put a position from a other continent & can get the string from Pather.Continent). But it needs to load the tiles. That's the down-side of it(If there's a better method to define it, let me know please)

    i also have written classes to use the returned pather for connections between boats, Zeppelins & portals and have a general algorithm to take the path with the shortest distance with these connections.

    But the mentioned method is the only thing left which is a thorn in my eye.

    I would like also to suggest to add a continent property to the Vector3 class. So if someone calls this class it will also get the continent & can be saved in profiles

    In the end the pather knows exactly where to go on which continent.

     

    ps: i can also upload the classes, if you need them but it has a bit work left.


    Sign in to follow this  


    User Feedback

    Recommended Comments



    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...