public static void RemoveBlockedEdgesForPlayer(Tuple <MyWayPoint, MyWayPoint> blockedEdges) { using (BlockedEdgesLock.AcquireExclusiveUsing()) { if (BlockedEdgesForPlayer.Remove(blockedEdges)) { } } }
public static void AddBlockedEdgesForPlayer(Tuple <MyWayPoint, MyWayPoint> blockedEdges) { using (BlockedEdgesLock.AcquireExclusiveUsing()) { if (!BlockedEdgesForPlayer.Contains(blockedEdges)) { BlockedEdgesForPlayer.Add(blockedEdges); } } }
public static void CleanBlockedEdges() { MyMwcLog.WriteLine("MyWayPoint.CleanBlockedEdges - START"); MyMwcLog.IncreaseIndent(); using (BlockedEdgesLock.AcquireExclusiveUsing()) { BlockedEdgesForBots.Clear(); BlockedEdgesForPlayer.Clear(); } MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyWayPoint.CleanBlockedEdges - END"); }
public override bool DebugDraw() { /* * int i = MyWayPointGraph.GetConnectedComponentId(this); * var vertexColor = HsvToRgb((0.36f + i * 0.618034f) % 1.0f, 0.8f, 0.75f); * * DrawWaypointVertex(WorldMatrix.Translation, vertexColor); // draw only edges for generated waypoints * * * // draw edges * foreach (var neighbor in Neighbors) * { * //DrawWaypointEdge(wp.WorldMatrix.Translation, neighbor.WorldMatrix.Translation, Color.Red, Color.Green); // selected path: red-green edges * * if (neighbor.WorldMatrix.Translation != WorldMatrix.Translation) * { * Vector3 direction = neighbor.WorldMatrix.Translation - WorldMatrix.Translation; * float lineLength = direction.Length(); * direction.Normalize(); * MyTransparentGeometry.AddLineBillboard(MyTransparentMaterialEnum.ProjectileTrailLine, Color.Yellow.ToVector4(), WorldMatrix.Translation, direction, lineLength, 0.25f); * } * * } */ if (((MyHud.ShowDebugWaypoints) || (MyGuiScreenGamePlay.Static.IsEditorActive() && !MyGuiScreenGamePlay.Static.IsIngameEditorActive())) && (MyFakes.ENABLE_GENERATED_WAYPOINTS_IN_EDITOR || MyHud.ShowDebugGeneratedWaypoints || Save)) { // color by connected components int i = MyWayPointGraph.GetConnectedComponentId(this); var vertexColor = HsvToRgb((0.36f + i * 0.618034f) % 1.0f, 0.8f, 0.75f); if (MyWayPointGraph.SelectedPath != null && MyWayPointGraph.SelectedPath.WayPoints.Contains(this)) { vertexColor = Color.Orange.ToVector3(); // selected path: orange vertices } if (IsSecret) { vertexColor *= 0.25f; } // draw vertices if (MyEditorGizmo.SelectedEntities.Contains(this)) { DrawWaypointVertex(WorldMatrix.Translation, vertexColor + (IsSecret ? 1 : 3) * GetHighlightColor()); var name = new StringBuilder(); if (MyWayPointGraph.SelectedPath != null && MyWayPointGraph.SelectedPath.WayPoints.Contains(this)) { name.Append(MyWayPointGraph.SelectedPath.Name).Append(": ").Append(MyWayPointGraph.SelectedPath.WayPoints.IndexOf(this) + 1); } else { name.Append(MyWayPoint.FilterWayPoints(MyEditorGizmo.SelectedEntities).IndexOf(this) + 1); } MyDebugDraw.DrawText(WorldMatrix.Translation, name, Color.White, 1); } else { if (Save) { DrawWaypointVertex(WorldMatrix.Translation, vertexColor); // for generated waypoints, draw only edges } } // draw edges if (Save || MyHud.ShowDebugGeneratedWaypoints) { using (MyWayPoint.NeighborsLock.AcquireSharedUsing()) { foreach (var neighbor in Neighbors) { if (MyWayPointGraph.SelectedPath != null && MyWayPointGraph.SelectedPath.ContainsEdge(this, neighbor)) { DrawWaypointEdge(WorldMatrix.Translation, neighbor.WorldMatrix.Translation, Color.Yellow, Color.White); // on selected path: yellow-white continue; } if (neighbor.Save || MyHud.ShowDebugGeneratedWaypoints) { using (MyWayPoint.BlockedEdgesLock.AcquireSharedUsing()) { // blocked for player (by a locked indestructible door: white-gray) if (BlockedEdgesForPlayer.Contains(Tuple.Create(this, neighbor)) || BlockedEdgesForPlayer.Contains(Tuple.Create(neighbor, this))) { DrawWaypointEdge(WorldMatrix.Translation, neighbor.WorldMatrix.Translation, Color.White, Color.Gray); continue; } // blocked for bots by a locked door: black-gray if (BlockedEdgesForBots.Contains(Tuple.Create(this, neighbor)) || BlockedEdgesForBots.Contains(Tuple.Create(neighbor, this))) { DrawWaypointEdge(WorldMatrix.Translation, neighbor.WorldMatrix.Translation, Color.Black, Color.Gray); continue; } } // obstructed: violet-white if (MyHud.ShowDebugWaypointsCollisions && Position != neighbor.Position) { var line = new MyLine(Position, neighbor.Position, true); if (MyEntities.GetAnyIntersectionWithLine(ref line, null, null, true, true, true, false) != null) { DrawWaypointEdge(WorldMatrix.Translation, neighbor.WorldMatrix.Translation, Color.Violet, Color.White); continue; } } // normal-normal: red-green // generated-normal: orange-green (normally invisible) // generated-generated: yellow-green (normally invisible) bool generated = !(Save && neighbor.Save); bool fullyGenerated = !Save && !neighbor.Save; DrawWaypointEdge(WorldMatrix.Translation, neighbor.WorldMatrix.Translation, generated ? fullyGenerated ? Color.Yellow : Color.Orange : Color.Red, Color.Green); continue; } } } } } return(base.DebugDraw()); }