public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { foreach (var actor in avoidance.Actors) { if (actor == null || !actor.IsValid) { continue; } var part = avoidance.Definition.GetPart(actor.Animation); if (part == null) { continue; } var radius = Math.Max(part.Radius, actor.Radius); var finalRadius = radius * avoidance.Settings.DistanceMultiplier; var nodes = grid.GetNodesInRadius(actor.Position, finalRadius); if (actor.Animation != part.Animation) { continue; } if (avoidance.Settings.Prioritize) { Core.DBGridProvider.AddCellWeightingObstacle(actor.ActorSnoId, finalRadius); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance | AvoidanceFlags.CriticalAvoidance, avoidance, 50); } else { grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance, avoidance, 10); } } }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { foreach (var actor in avoidance.Actors) { if (actor == null) { continue; } var part = avoidance.Definition.GetPart(actor.ActorSnoId); try { if (part.Type == PartType.Telegraph) { var nodes = new List <AvoidanceNode>(); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(Math.PI / 2)))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(2 * Math.PI)))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(3 * Math.PI / 2)))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(Math.PI)))); grid.FlagAvoidanceNodes(nodes.SelectMany(n => n.AdjacentNodes), AvoidanceFlags.Avoidance, avoidance, 10); } else { var nodes = grid.GetRayLineAsNodes(actor.Position, avoidance.StartPosition).SelectMany(n => n.AdjacentNodes); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance, avoidance, 10); } } catch (Exception ex) { Core.Logger.Error("Exception {0}", ex); } } }
public static void UpdateLineOfSight(TrinityActor actor) { var grid = TrinityGrid.GetUnsafeGrid(); if (grid == null) { return; } if (actor.Position != Vector3.Zero && grid.GridBounds != 0) { var inLineOfSight = grid.CanRayCast(Core.Player.Position, actor.Position); actor.IsInLineOfSight = inLineOfSight; if (!actor.HasBeenInLoS && inLineOfSight) { actor.HasBeenInLoS = true; } if (inLineOfSight) { actor.IsWalkable = grid.CanRayWalk(actor); if (actor.IsWalkable) { actor.HasBeenWalkable = true; } } else { actor.IsWalkable = false; } } }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var checkActors = avoidance.Actors.Where(a => a != null && a.IsValid).ToArray(); foreach (var actor in checkActors) { try { var part = avoidance.Definition.GetPart(actor.Animation); if (actor.Animation != part?.Animation) { continue; } var radius = Math.Max(part.Radius, actor.Radius) * avoidance.Settings.DistanceMultiplier; var nonCachedRotation = actor.Rotation; var nodes = grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, radius, nonCachedRotation)).SelectMany(n => n.AdjacentNodes); grid.FlagAvoidanceNodes(nodes.SelectMany(n => n.AdjacentNodes), AvoidanceFlags.Avoidance, avoidance, 10); } catch (Exception) { Core.Logger.Debug($"AnimationBeamAvoidanceHandler Exception reading Animation/Rotation for actor: {actor.InternalName}"); avoidance.Actors.Remove(actor); } } }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { foreach (var actor in avoidance.Actors) { if (actor == null || !actor.IsValid) { //Core.Logger.Log(LogCategory.Avoidance, $"<CircularAvoidanceHandler> actor is null or invalid for {avoidance.Definition.Name}"); continue; } var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (part == null) { continue; } var radius = Math.Max(part.Radius, actor.Radius); var finalRadius = radius * avoidance.Settings.DistanceMultiplier; var nodes = grid.GetNodesInRadius(actor.Position, finalRadius); if (avoidance.Settings.Prioritize) { //Core.Logger.Log(LogCategory.Avoidance, $"<CircularAvoidanceHandler> marking {nodes.Count} nodes critical for actor {actor}, def={avoidance.Definition.Name}"); Core.DBGridProvider.AddCellWeightingObstacle(actor.ActorSnoId, finalRadius); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance | AvoidanceFlags.CriticalAvoidance, avoidance, 50); } else { //Core.Logger.Log(LogCategory.Avoidance, $"<CircularAvoidanceHandler> marking {nodes.Count} nodes for actor {actor}, def={avoidance.Definition.Name}"); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance, avoidance, 10); } } }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { foreach (var actor in avoidance.Actors) { if (actor == null) { continue; } var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (actor.IsDead || actor.CommonData == null || !actor.CommonData.IsValid || actor.CommonData.IsDisposed) { Core.Logger.Verbose("Actor {0} CommonData Invalid ({1})", actor.InternalName, part.Name); continue; } if (part.Type == PartType.VisualEffect) { if (actor.Attributes.GetAttribute <bool>(part.Attribute, (int)part.Power)) { Core.Logger.Log("Power {0} on {1} ({1}) in Attribute {2}", part.Power, actor.InternalName, part.Name, part.Attribute); var nodes = grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 30f, actor.Rotation)).SelectMany(n => n.AdjacentNodes).Distinct(); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance, avoidance, 10); } } else { var obstacleNodes = grid.GetNodesInRadius(actor.Position, part.Radius); grid.FlagAvoidanceNodes(obstacleNodes, AvoidanceFlags.NavigationBlocking, avoidance, 5); } } }
public override bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = Core.Actors.RactorByRactorId <TrinityActor>(avoidance.RActorId); if (actor == null || !actor.IsValid) { return(false); } CleanUpRotators(); var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (part?.MovementType == MovementType.Rotation) { Rotator rotator; if (!_rotators.TryGetValue(actor.RActorId, out rotator)) { rotator = CreateNewRotator(actor); _rotators.Add(actor.RActorId, rotator); Task.FromResult(rotator.Rotate()); } var centerNodes = grid.GetNodesInRadius(actor.Position, 8f); var radAngle = MathUtil.ToRadians(rotator.Angle); var nodes = grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 28f, radAngle)).SelectMany(n => n.AdjacentNodes).ToList(); var futureRadAngle = MathUtil.ToRadians((float)rotator.GetFutureAngle(TimeSpan.FromMilliseconds(500))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 28f, futureRadAngle)).SelectMany(n => n.AdjacentNodes)); nodes.AddRange(centerNodes); nodes = nodes.Distinct().ToList(); const int defaultWeightModification = 32; HandleNavigationGrid(grid, nodes, avoidance, actor, 0f, defaultWeightModification); } else { var telegraphNodes = grid.GetNodesInRadius(actor.Position, 12f); const int defaultWeightModification = 12; HandleNavigationGrid(grid, telegraphNodes, avoidance, actor, 0f, defaultWeightModification); } Core.DBGridProvider.AddCellWeightingObstacle(actor.RActorId, ObstacleFactory.FromActor(actor)); return(true); }
public override bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = Core.Actors.RactorByRactorId <TrinityActor>(avoidance.RActorId); if (actor == null || !actor.IsValid) { return(false); } var part = avoidance.Definition.GetPart(actor.Animation); var radius = Math.Max(part.Radius, actor.Radius) * avoidance.Settings.DistanceMultiplier; var nonCachedRotation = actor.Rotation; var nodes = grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, radius, nonCachedRotation)).SelectMany(n => n.AdjacentNodes); HandleNavigationGrid(grid, nodes.SelectMany(n => n.AdjacentNodes), avoidance, actor, radius); return(true); }
public bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = Core.Actors.RactorByRactorId <TrinityActor>(avoidance.RActorId); if (actor == null || !actor.IsValid) { return(false); } var fireChainFriendList = Core.Avoidance.CurrentAvoidances.Where(c => c != avoidance && c.ActorSno == avoidance.ActorSno) .ToList(); var appliedAvoidanceNode = false; foreach (var fireChainFriend in fireChainFriendList) { var friend = Core.Actors.RactorByRactorId <TrinityActor>(fireChainFriend.RActorId); if (friend == null || !friend.IsValid) { continue; } var nodes = grid.GetRayLineAsNodes(actor.Position, friend.Position).SelectMany(n => n.AdjacentNodes); AvoidanceFlags flags = AvoidanceFlags.Avoidance; int weightModification = BaseAvoidanceHandler.DefaultWeightModification; if (avoidance.Settings.Prioritize) { flags |= AvoidanceFlags.CriticalAvoidance; weightModification = BaseAvoidanceHandler.CriticalWeightModification; } grid.FlagAvoidanceNodes(nodes, flags, avoidance, weightModification); appliedAvoidanceNode = true; } if (appliedAvoidanceNode) { Core.DBGridProvider.AddCellWeightingObstacle(actor.RActorId, ObstacleFactory.FromActor(actor)); return(true); } return(false); }
protected void HandleNavigationGrid(AvoidanceFlags defaultFlags, TrinityGrid grid, IEnumerable <AvoidanceNode> nodes, Structures.Avoidance avoidance, TrinityActor actor, float radius, int normalWeightModificationOverride = 0) { AvoidanceFlags flags = defaultFlags; int weightModification = DefaultWeightModification; if (normalWeightModificationOverride != 0) { weightModification = normalWeightModificationOverride; } if (avoidance.Settings.Prioritize) { weightModification = CriticalWeightModification; flags |= AvoidanceFlags.CriticalAvoidance; } grid.FlagAvoidanceNodes(nodes, flags, avoidance, weightModification); Core.DBGridProvider.AddCellWeightingObstacle(actor.RActorId, ObstacleFactory.FromActor(actor, radius)); }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { CleanUpRotators(); foreach (var actor in avoidance.Actors) { if (actor == null || !actor.IsValid || actor.IsDead || actor.CommonData == null || actor.CommonData.IsDisposed) { continue; } var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (part.MovementType == MovementType.Rotation) { Rotator rotator; if (!_rotators.TryGetValue(actor.RActorId, out rotator)) { rotator = CreateNewRotator(actor); _rotators.Add(actor.RActorId, rotator); Task.FromResult(rotator.Rotate()); } var centerNodes = grid.GetNodesInRadius(actor.Position, 6f); var radAngle = MathUtil.ToRadians(rotator.Angle); var nodes = grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 26f, radAngle)).SelectMany(n => n.AdjacentNodes).ToList(); var futureRadAngle = MathUtil.ToRadians((float)rotator.GetFutureAngle(TimeSpan.FromMilliseconds(500))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 26f, futureRadAngle)).SelectMany(n => n.AdjacentNodes)); nodes.AddRange(centerNodes); nodes = nodes.Distinct().ToList(); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance, avoidance, 30); } else { var telegraphNodes = grid.GetNodesInRadius(actor.Position, 10f); grid.FlagAvoidanceNodes(telegraphNodes, AvoidanceFlags.Avoidance, avoidance, 10); } } }
public override bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = Core.Actors.RactorByRactorId <TrinityActor>(avoidance.RActorId); if (actor == null || !actor.IsValid || actor.IsDead) { return(false); } var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (part == null) { return(false); } if (part.Type == PartType.VisualEffect) { if (actor.Attributes.GetAttribute <bool>(part.Attribute, (int)part.Power)) { Core.Logger.Log("Power {0} on {1} ({1}) in Attribute {2}", part.Power, actor.InternalName, part.Name, part.Attribute); var nodes = grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 30f, actor.Rotation)).SelectMany(n => n.AdjacentNodes).Distinct(); HandleNavigationGrid(grid, nodes, avoidance, actor, 0f); return(true); } } else { var obstacleNodes = grid.GetNodesInRadius(actor.Position, part.Radius); const int weightOverride = 5; HandleNavigationGrid(AvoidanceFlags.NavigationBlocking, grid, obstacleNodes, avoidance, actor, 0f, weightOverride); return(true); } return(false); }
public override bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = Core.Actors.RactorByRactorId <TrinityActor>(avoidance.RActorId); if (actor == null || !actor.IsValid) { return(false); } var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (part == null) { return(false); } if (part.Type == PartType.Telegraph) { var nodes = new List <AvoidanceNode>(); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(Math.PI / 2)))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(2 * Math.PI)))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(3 * Math.PI / 2)))); nodes.AddRange(grid.GetRayLineAsNodes(actor.Position, MathEx.GetPointAt(actor.Position, 60f, (float)(Math.PI)))); HandleNavigationGrid(grid, nodes.SelectMany(n => n.AdjacentNodes), avoidance, actor, 0f); } else { var nodes = grid.GetRayLineAsNodes(actor.Position, avoidance.StartPosition).SelectMany(n => n.AdjacentNodes); HandleNavigationGrid(grid, nodes, avoidance, actor, 0f); } return(true); }
public override bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = Core.Actors.RactorByRactorId <TrinityActor>(avoidance.RActorId); if (actor == null || !actor.IsValid) { return(false); } var part = avoidance.Definition.GetPart(actor.ActorSnoId); if (part == null) { return(false); } var radius = Math.Max(part.Radius, actor.Radius); var finalRadius = radius * avoidance.Settings.DistanceMultiplier; var nodes = grid.GetNodesInRadius(actor.Position, finalRadius); HandleNavigationGrid(grid, nodes, avoidance, actor, finalRadius); return(true); }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { foreach (var actor in avoidance.Actors) { try { var part = avoidance.Definition.GetPart(actor.Animation); if (actor.Animation != part.Animation) { continue; } var radius = Math.Max(part.Radius, actor.Radius) * avoidance.Settings.DistanceMultiplier; var nonCachedRotation = actor.Rotation; var arcDegrees = Math.Max(15, part.AngleDegrees); var nodes = grid.GetConeAsNodes(actor.Position, arcDegrees, radius, nonCachedRotation); grid.FlagAvoidanceNodes(nodes.SelectMany(n => n.AdjacentNodes), AvoidanceFlags.Avoidance, avoidance, 10); } catch (Exception ex) { Core.Logger.Debug($"AnimationConeAvoidanceHandler Exception for Actor: {actor.InternalName}. {ex}"); } } }
public void UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance) { var actor = avoidance.Actors.FirstOrDefault(); if (actor == null) { return; } foreach (var otherAvoidance in Core.Avoidance.CurrentAvoidances) { if (otherAvoidance == avoidance) { continue; } var fireChainFriend = otherAvoidance.Actors.FirstOrDefault(a => a.ActorSnoId == actor.ActorSnoId); if (fireChainFriend != null) { var nodes = grid.GetRayLineAsNodes(actor.Position, fireChainFriend.Position).SelectMany(n => n.AdjacentNodes); grid.FlagAvoidanceNodes(nodes, AvoidanceFlags.Avoidance, avoidance, 10); } } }
public abstract bool UpdateNodes(TrinityGrid grid, Structures.Avoidance avoidance);
protected void HandleNavigationGrid(TrinityGrid grid, IEnumerable <AvoidanceNode> nodes, Structures.Avoidance avoidance, TrinityActor actor, float radius, int normalWeightModificationOverride = 0) { HandleNavigationGrid(AvoidanceFlags.Avoidance, grid, nodes, avoidance, actor, radius, normalWeightModificationOverride); }