Ejemplo n.º 1
0
 /// <summary>\cond internal</summary>
 /// <summary>
 /// Internal method to make sure <see cref="active"/> is set to this object and that <see cref="data"/> is not null.
 /// Also calls OnEnable for the <see cref="colorSettings"/> and initializes data.userConnections if it wasn't initialized before
 ///
 /// Warning: This is mostly for use internally by the system.
 /// </summary>
 public void ConfigureReferencesInternal()
 {
     active        = this;
     data          = data ?? new AstarData();
     colorSettings = colorSettings ?? new AstarColor();
     colorSettings.PushToStatic(this);
 }
Ejemplo n.º 2
0
 public Hasher(AstarPath active)
 {
     hash                  = 0;
     this.debugData        = active.debugPathData;
     includePathSearchInfo = debugData != null && (active.debugMode == GraphDebugMode.F || active.debugMode == GraphDebugMode.G || active.debugMode == GraphDebugMode.H || active.showSearchTree);
     includeAreaInfo       = active.debugMode == GraphDebugMode.Areas;
     AddHash((int)active.debugMode);
     AddHash(active.debugFloor.GetHashCode());
     AddHash(active.debugRoof.GetHashCode());
     AddHash(AstarColor.ColorHash());
 }
Ejemplo n.º 3
0
 public NodeHasher(AstarPath active)
 {
     hasher                = default;
     this.debugData        = active.debugPathData;
     includePathSearchInfo = debugData != null && (active.debugMode == GraphDebugMode.F || active.debugMode == GraphDebugMode.G || active.debugMode == GraphDebugMode.H || active.showSearchTree);
     includeAreaInfo       = active.debugMode == GraphDebugMode.Areas;
     hasher.Add(active.debugMode);
     hasher.Add(active.debugFloor);
     hasher.Add(active.debugRoof);
     hasher.Add(AstarColor.ColorHash());
 }
Ejemplo n.º 4
0
        // Token: 0x060029E0 RID: 10720 RVA: 0x001C4A90 File Offset: 0x001C2C90
        public Color NodeColor(GraphNode node)
        {
            if (this.showSearchTree && !GraphGizmoHelper.InSearchTree(node, this.debugData, this.debugPathID))
            {
                return(Color.clear);
            }
            Color result;

            if (node.Walkable)
            {
                switch (this.debugMode)
                {
                case GraphDebugMode.Areas:
                    return(AstarColor.GetAreaColor(node.Area));

                case GraphDebugMode.Penalty:
                    return(Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (node.Penalty - this.debugFloor) / (this.debugRoof - this.debugFloor)));

                case GraphDebugMode.Connections:
                    return(AstarColor.NodeConnection);

                case GraphDebugMode.Tags:
                    return(AstarColor.GetAreaColor(node.Tag));
                }
                if (this.debugData == null)
                {
                    result = AstarColor.NodeConnection;
                }
                else
                {
                    PathNode pathNode = this.debugData.GetPathNode(node);
                    float    num;
                    if (this.debugMode == GraphDebugMode.G)
                    {
                        num = pathNode.G;
                    }
                    else if (this.debugMode == GraphDebugMode.H)
                    {
                        num = pathNode.H;
                    }
                    else
                    {
                        num = pathNode.F;
                    }
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (num - this.debugFloor) / (this.debugRoof - this.debugFloor));
                }
            }
            else
            {
                result = AstarColor.UnwalkableNode;
            }
            return(result);
        }
        /// <summary>
        /// Color to use for gizmos.
        /// Returns a color to be used for the specified node with the current debug settings (editor only).
        ///
        /// Version: Since 3.6.1 this method will not handle null nodes
        /// </summary>
        public Color NodeColor(GraphNode node)
        {
            if (showSearchTree && !InSearchTree(node, debugData, debugPathID))
            {
                return(Color.clear);
            }

            Color color;

            if (node.Walkable)
            {
                switch (debugMode)
                {
                case GraphDebugMode.Areas:
                    color = AstarColor.GetAreaColor(node.Area);
                    break;

                case GraphDebugMode.HierarchicalNode:
                    color = AstarColor.GetTagColor((uint)node.HierarchicalNodeIndex);
                    break;

                case GraphDebugMode.Penalty:
                    color = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp,
                                       ((float)node.Penalty - debugFloor) / (debugRoof - debugFloor));
                    break;

                case GraphDebugMode.Tags:
                    color = AstarColor.GetTagColor(node.Tag);
                    break;

                case GraphDebugMode.SolidColor:
                    color = AstarColor.SolidColor;
                    break;

                default:
                    if (debugData == null)
                    {
                        color = AstarColor.SolidColor;
                        break;
                    }

                    PathNode pathNode = debugData.GetPathNode(node);
                    float    value;
                    if (debugMode == GraphDebugMode.G)
                    {
                        value = pathNode.G;
                    }
                    else if (debugMode == GraphDebugMode.H)
                    {
                        value = pathNode.H;
                    }
                    else
                    {
                        // mode == F
                        value = pathNode.F;
                    }

                    color = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp,
                                       (value - debugFloor) / (debugRoof - debugFloor));
                    break;
                }
            }
            else
            {
                color = AstarColor.UnwalkableNode;
            }

            return(color);
        }